[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditionally include gnulib regex
From: |
Bruno Haible |
Subject: |
Re: conditionally include gnulib regex |
Date: |
Tue, 17 Oct 2017 20:59:06 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-96-generic; KDE/5.18.0; x86_64; ; ) |
Hi,
> The strategy is to hide
> lib/regex.h until configure requests it. If there’s a better
> way, I’d be interested to know and apologize if this
> has been covered previously.
Technically, the way you use regex here is OK.
Nevertheless, here is why few package have an option like this:
The user of 'configure', i.e. the person who builds the package, usually
for a distro, when seeing this
$ ./configure --help
...
--with-included-regex use GNU gnulib regex library included here
...
will ask themselves: Should I use this option or not? What is the benefit
(added feature?) if I use it?
Many GNU packages therefore offer to the user of 'configure' a set of
features, with a clear meaning, and the configure script then makes decisions
(in this case, whether to include the system's <regex.h>). For example:
$ ./configure --help
...
--enable-posix enable strict POSIX compliance
--enable-gnu enable GNU extensions
--enable-embedded produce binaries of minimal code size
...
Then, you can implement a logic such as:
included_regex = (enable_posix && !system_has_posix_regex)
|| (enable_gnu && !system_has_gnu_regex)
|| (!enable_embedded && system_regex_is_buggy)
This is just a hypothetical example.
> AM_CPPFLAGS += -DRE_ENABLE_I18N=1 -D__USE_GNU=1
You shouldn't set __USE_GNU. That's a glibc-internal macro. If you want
GNU extensions to be defined in glibc, define _GNU_SOURCE to 1 before
the first include file. If you want platform specific functions to be
declared on all platforms, use the gnulib module 'extensions'.
Bruno