Skip to content

Commit

Permalink
Allow multiple gnulib generated include files to be combined.
Browse files Browse the repository at this point in the history
* gnulib-tool (func_compute_include_guard_prefix): New function.
(func_emit_lib_Makefile_am, func_emit_tests_Makefile_am): Resolve also
${gl_include_guard_prefix} references.
(func_import, func_create_testdir): Invoke
func_compute_include_guard_prefix.
* lib/arpa_inet.in.h: Use the @GUARD_PREFIX@ placeholder.
* lib/ctype.in.h: Likewise.
* lib/dirent.in.h: Likewise.
* lib/errno.in.h: Likewise.
* lib/fcntl.in.h: Likewise.
* lib/float.in.h: Likewise.
* lib/getopt.in.h: Likewise.
* lib/iconv.in.h: Likewise.
* lib/langinfo.in.h: Likewise.
* lib/locale.in.h: Likewise.
* lib/math.in.h: Likewise.
* lib/netdb.in.h: Likewise.
* lib/netinet_in.in.h: Likewise.
* lib/poll.in.h: Likewise.
* lib/pthread.in.h: Likewise.
* lib/pty.in.h: Likewise.
* lib/sched.in.h: Likewise.
* lib/se-selinux.in.h: Likewise.
* lib/search.in.h: Likewise.
* lib/signal.in.h: Likewise.
* lib/spawn.in.h: Likewise.
* lib/stdarg.in.h: Likewise.
* lib/stddef.in.h: Likewise.
* lib/stdint.in.h: Likewise.
* lib/stdio.in.h: Likewise.
* lib/stdlib.in.h: Likewise.
* lib/string.in.h: Likewise.
* lib/strings.in.h: Likewise.
* lib/sys_file.in.h: Likewise.
* lib/sys_ioctl.in.h: Likewise.
* lib/sys_select.in.h: Likewise.
* lib/sys_socket.in.h: Likewise.
* lib/sys_stat.in.h: Likewise.
* lib/sys_time.in.h: Likewise.
* lib/sys_times.in.h: Likewise.
* lib/sys_uio.in.h: Likewise.
* lib/sys_utsname.in.h: Likewise.
* lib/sys_wait.in.h: Likewise.
* lib/sysexits.in.h: Likewise.
* lib/termios.in.h: Likewise.
* lib/time.in.h: Likewise.
* lib/unistd.in.h: Likewise.
* lib/wchar.in.h: Likewise.
* lib/wctype.in.h: Likewise.
* modules/arpa_inet (Makefile.am): Substitute @GUARD_PREFIX@.
* modules/ctype (Makefile.am): Likewise.
* modules/dirent (Makefile.am): Likewise.
* modules/errno (Makefile.am): Likewise.
* modules/fcntl-h (Makefile.am): Likewise.
* modules/float (Makefile.am): Likewise.
* modules/getopt-posix (Makefile.am): Likewise.
* modules/iconv-h (Makefile.am): Likewise.
* modules/langinfo (Makefile.am): Likewise.
* modules/locale (Makefile.am): Likewise.
* modules/math (Makefile.am): Likewise.
* modules/netdb (Makefile.am): Likewise.
* modules/netinet_in (Makefile.am): Likewise.
* modules/poll-h (Makefile.am): Likewise.
* modules/pthread (Makefile.am): Likewise.
* modules/pty (Makefile.am): Likewise.
* modules/sched (Makefile.am): Likewise.
* modules/search (Makefile.am): Likewise.
* modules/selinux-h (Makefile.am): Likewise.
* modules/signal (Makefile.am): Likewise.
* modules/spawn (Makefile.am): Likewise.
* modules/stdarg (Makefile.am): Likewise.
* modules/stddef (Makefile.am): Likewise.
* modules/stdint (Makefile.am): Likewise.
* modules/stdio (Makefile.am): Likewise.
* modules/stdlib (Makefile.am): Likewise.
* modules/string (Makefile.am): Likewise.
* modules/strings (Makefile.am): Likewise.
* modules/sys_file (Makefile.am): Likewise.
* modules/sys_ioctl (Makefile.am): Likewise.
* modules/sys_select (Makefile.am): Likewise.
* modules/sys_socket (Makefile.am): Likewise.
* modules/sys_stat (Makefile.am): Likewise.
* modules/sys_time (Makefile.am): Likewise.
* modules/sys_times (Makefile.am): Likewise.
* modules/sys_uio (Makefile.am): Likewise.
* modules/sys_utsname (Makefile.am): Likewise.
* modules/sys_wait (Makefile.am): Likewise.
* modules/sysexits (Makefile.am): Likewise.
* modules/termios (Makefile.am): Likewise.
* modules/time (Makefile.am): Likewise.
* modules/unistd (Makefile.am): Likewise.
* modules/wchar (Makefile.am): Likewise.
* modules/wctype-h (Makefile.am): Likewise.
* modules/assert-h (Makefile.am): Replace _GL_VERIFY_H specially.
  • Loading branch information
bhaible committed May 29, 2011
1 parent 606b7ac commit 0ab583c
Show file tree
Hide file tree
Showing 92 changed files with 439 additions and 266 deletions.
98 changes: 98 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,101 @@
2011-05-29 Bruno Haible <[email protected]>

Allow multiple gnulib generated include files to be combined.
* gnulib-tool (func_compute_include_guard_prefix): New function.
(func_emit_lib_Makefile_am, func_emit_tests_Makefile_am): Resolve also
${gl_include_guard_prefix} references.
(func_import, func_create_testdir): Invoke
func_compute_include_guard_prefix.
* lib/arpa_inet.in.h: Use the @GUARD_PREFIX@ placeholder.
* lib/ctype.in.h: Likewise.
* lib/dirent.in.h: Likewise.
* lib/errno.in.h: Likewise.
* lib/fcntl.in.h: Likewise.
* lib/float.in.h: Likewise.
* lib/getopt.in.h: Likewise.
* lib/iconv.in.h: Likewise.
* lib/langinfo.in.h: Likewise.
* lib/locale.in.h: Likewise.
* lib/math.in.h: Likewise.
* lib/netdb.in.h: Likewise.
* lib/netinet_in.in.h: Likewise.
* lib/poll.in.h: Likewise.
* lib/pthread.in.h: Likewise.
* lib/pty.in.h: Likewise.
* lib/sched.in.h: Likewise.
* lib/se-selinux.in.h: Likewise.
* lib/search.in.h: Likewise.
* lib/signal.in.h: Likewise.
* lib/spawn.in.h: Likewise.
* lib/stdarg.in.h: Likewise.
* lib/stddef.in.h: Likewise.
* lib/stdint.in.h: Likewise.
* lib/stdio.in.h: Likewise.
* lib/stdlib.in.h: Likewise.
* lib/string.in.h: Likewise.
* lib/strings.in.h: Likewise.
* lib/sys_file.in.h: Likewise.
* lib/sys_ioctl.in.h: Likewise.
* lib/sys_select.in.h: Likewise.
* lib/sys_socket.in.h: Likewise.
* lib/sys_stat.in.h: Likewise.
* lib/sys_time.in.h: Likewise.
* lib/sys_times.in.h: Likewise.
* lib/sys_uio.in.h: Likewise.
* lib/sys_utsname.in.h: Likewise.
* lib/sys_wait.in.h: Likewise.
* lib/sysexits.in.h: Likewise.
* lib/termios.in.h: Likewise.
* lib/time.in.h: Likewise.
* lib/unistd.in.h: Likewise.
* lib/wchar.in.h: Likewise.
* lib/wctype.in.h: Likewise.
* modules/arpa_inet (Makefile.am): Substitute @GUARD_PREFIX@.
* modules/ctype (Makefile.am): Likewise.
* modules/dirent (Makefile.am): Likewise.
* modules/errno (Makefile.am): Likewise.
* modules/fcntl-h (Makefile.am): Likewise.
* modules/float (Makefile.am): Likewise.
* modules/getopt-posix (Makefile.am): Likewise.
* modules/iconv-h (Makefile.am): Likewise.
* modules/langinfo (Makefile.am): Likewise.
* modules/locale (Makefile.am): Likewise.
* modules/math (Makefile.am): Likewise.
* modules/netdb (Makefile.am): Likewise.
* modules/netinet_in (Makefile.am): Likewise.
* modules/poll-h (Makefile.am): Likewise.
* modules/pthread (Makefile.am): Likewise.
* modules/pty (Makefile.am): Likewise.
* modules/sched (Makefile.am): Likewise.
* modules/search (Makefile.am): Likewise.
* modules/selinux-h (Makefile.am): Likewise.
* modules/signal (Makefile.am): Likewise.
* modules/spawn (Makefile.am): Likewise.
* modules/stdarg (Makefile.am): Likewise.
* modules/stddef (Makefile.am): Likewise.
* modules/stdint (Makefile.am): Likewise.
* modules/stdio (Makefile.am): Likewise.
* modules/stdlib (Makefile.am): Likewise.
* modules/string (Makefile.am): Likewise.
* modules/strings (Makefile.am): Likewise.
* modules/sys_file (Makefile.am): Likewise.
* modules/sys_ioctl (Makefile.am): Likewise.
* modules/sys_select (Makefile.am): Likewise.
* modules/sys_socket (Makefile.am): Likewise.
* modules/sys_stat (Makefile.am): Likewise.
* modules/sys_time (Makefile.am): Likewise.
* modules/sys_times (Makefile.am): Likewise.
* modules/sys_uio (Makefile.am): Likewise.
* modules/sys_utsname (Makefile.am): Likewise.
* modules/sys_wait (Makefile.am): Likewise.
* modules/sysexits (Makefile.am): Likewise.
* modules/termios (Makefile.am): Likewise.
* modules/time (Makefile.am): Likewise.
* modules/unistd (Makefile.am): Likewise.
* modules/wchar (Makefile.am): Likewise.
* modules/wctype-h (Makefile.am): Likewise.
* modules/assert-h (Makefile.am): Replace _GL_VERIFY_H specially.

2011-05-29 Bruno Haible <[email protected]>

assert-h: Allow multiple gnulib generated replacements to coexist.
Expand Down
6 changes: 3 additions & 3 deletions STATUS-libposix
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ Bruno Haible says:
Discussion:
<http://lists.gnu.org/archive/html/bug-gnulib/2010-10/msg00289.html>

Half of the work has been done, but not yet pushed.
<http://lists.gnu.org/archive/html/bug-gnulib/2010-11/msg00199.html>
<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00078.html>
Still missing: dealing with include_next and old compilers, cf.
<http://lists.gnu.org/archive/html/bug-gnulib/2010-10/msg00269.html>
<http://lists.gnu.org/archive/html/bug-gnulib/2010-10/msg00285.html>

2) Allow using libgnu's file name in module descriptions.
<http://lists.gnu.org/archive/html/bug-gnulib/2010-10/msg00284.html>
Expand Down
34 changes: 32 additions & 2 deletions gnulib-tool
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,24 @@ func_modules_to_filelist_separately ()
fi
}

# func_compute_include_guard_prefix
# Determine include_guard_prefix.
# Input:
# - macro_prefix prefix of gl_LIBOBJS macros to use
# Output:
# - include_guard_prefix replacement for ${gl_include_guard_prefix}
# - sed_replace_include_guard_prefix
# sed expression for resolving ${gl_include_guard_prefix}
func_compute_include_guard_prefix ()
{
if test "$macro_prefix" = gl; then
include_guard_prefix='GL'
else
include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
fi
sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
}

# func_execute_command command [args...]
# Executes a command.
# Uses also the variables
Expand Down Expand Up @@ -3154,6 +3172,8 @@ func_update_file ()
# - po_domain prefix of i18n domain to use (without -gnulib suffix)
# - actioncmd (optional) command that will reproduce this invocation
# - for_test true if creating a package for testing, false otherwise
# - sed_replace_include_guard_prefix
# sed expression for resolving ${gl_include_guard_prefix}
# - destfile filename relative to destdir of makefile being generated
# Input/Output:
# - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
Expand Down Expand Up @@ -3215,7 +3235,8 @@ func_emit_lib_Makefile_am ()
-e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
-e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
-e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
-e "$sed_transform_check_PROGRAMS"
-e "$sed_transform_check_PROGRAMS" \
-e "$sed_replace_include_guard_prefix"
if test "$module" = 'alloca'; then
echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
Expand Down Expand Up @@ -3462,6 +3483,8 @@ func_emit_po_POTFILES_in ()
# - single_configure true if a single configure file should be generated,
# false for a separate configure file for the tests
# - use_libtests true if a libtests.a should be built, false otherwise
# - sed_replace_include_guard_prefix
# sed expression for resolving ${gl_include_guard_prefix}
# - destfile filename relative to destdir of makefile being generated
# Input/Output:
# - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
Expand Down Expand Up @@ -3510,7 +3533,8 @@ func_emit_tests_Makefile_am ()
-e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
-e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
-e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
-e "$sed_transform_check_PROGRAMS"
-e "$sed_transform_check_PROGRAMS" \
-e "$sed_replace_include_guard_prefix"
if $use_libtests && test "$module" = 'alloca'; then
echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
Expand Down Expand Up @@ -4715,6 +4739,9 @@ s,^\(.................................................[^ ]*\) *,
fi
func_append actioncmd " `echo $specified_modules`"

# Determine include_guard_prefix.
func_compute_include_guard_prefix

# Default the makefile name to Makefile.am.
if test -n "$makefile_name"; then
makefile_am=$makefile_name
Expand Down Expand Up @@ -5586,6 +5613,9 @@ func_create_testdir ()
exec 0<&5 5<&-
}

# Determine include_guard_prefix.
func_compute_include_guard_prefix

# Create Makefile.ams that are for testing.
for_test=true

Expand Down
10 changes: 5 additions & 5 deletions lib/arpa_inet.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */

#ifndef _GL_ARPA_INET_H
#ifndef _@GUARD_PREFIX@_ARPA_INET_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
Expand Down Expand Up @@ -47,8 +47,8 @@

#endif

#ifndef _GL_ARPA_INET_H
#define _GL_ARPA_INET_H
#ifndef _@GUARD_PREFIX@_ARPA_INET_H
#define _@GUARD_PREFIX@_ARPA_INET_H

/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */

Expand Down Expand Up @@ -111,5 +111,5 @@ _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
#endif


#endif /* _GL_ARPA_INET_H */
#endif /* _GL_ARPA_INET_H */
#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
10 changes: 5 additions & 5 deletions lib/ctype.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <http://www.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html>
*/

#ifndef _GL_CTYPE_H
#ifndef _@GUARD_PREFIX@_CTYPE_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
Expand All @@ -34,8 +34,8 @@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_CTYPE_H@

#ifndef _GL_CTYPE_H
#define _GL_CTYPE_H
#ifndef _@GUARD_PREFIX@_CTYPE_H
#define _@GUARD_PREFIX@_CTYPE_H

/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */

Expand All @@ -54,5 +54,5 @@ _GL_WARN_ON_USE (isblank, "isblank is unportable - "
# endif
#endif

#endif /* _GL_CTYPE_H */
#endif /* _GL_CTYPE_H */
#endif /* _@GUARD_PREFIX@_CTYPE_H */
#endif /* _@GUARD_PREFIX@_CTYPE_H */
10 changes: 5 additions & 5 deletions lib/dirent.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

#ifndef _GL_DIRENT_H
#ifndef _@GUARD_PREFIX@_DIRENT_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
Expand All @@ -24,8 +24,8 @@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_DIRENT_H@

#ifndef _GL_DIRENT_H
#define _GL_DIRENT_H
#ifndef _@GUARD_PREFIX@_DIRENT_H
#define _@GUARD_PREFIX@_DIRENT_H

/* Get ino_t. Needed on some systems, including glibc 2.8. */
#include <sys/types.h>
Expand Down Expand Up @@ -168,5 +168,5 @@ _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
#endif


#endif /* _GL_DIRENT_H */
#endif /* _GL_DIRENT_H */
#endif /* _@GUARD_PREFIX@_DIRENT_H */
#endif /* _@GUARD_PREFIX@_DIRENT_H */
10 changes: 5 additions & 5 deletions lib/errno.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */

#ifndef _GL_ERRNO_H
#ifndef _@GUARD_PREFIX@_ERRNO_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
Expand All @@ -26,8 +26,8 @@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_ERRNO_H@

#ifndef _GL_ERRNO_H
#define _GL_ERRNO_H
#ifndef _@GUARD_PREFIX@_ERRNO_H
#define _@GUARD_PREFIX@_ERRNO_H


/* On native Windows platforms, many macros are not defined. */
Expand Down Expand Up @@ -163,5 +163,5 @@
# endif


#endif /* _GL_ERRNO_H */
#endif /* _GL_ERRNO_H */
#endif /* _@GUARD_PREFIX@_ERRNO_H */
#endif /* _@GUARD_PREFIX@_ERRNO_H */
10 changes: 5 additions & 5 deletions lib/fcntl.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#else
/* Normal invocation convention. */

#ifndef _GL_FCNTL_H
#ifndef _@GUARD_PREFIX@_FCNTL_H

#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
Expand All @@ -55,8 +55,8 @@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@

#ifndef _GL_FCNTL_H
#define _GL_FCNTL_H
#ifndef _@GUARD_PREFIX@_FCNTL_H
#define _@GUARD_PREFIX@_FCNTL_H

#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
# include <unistd.h>
Expand Down Expand Up @@ -320,6 +320,6 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
#endif


#endif /* _GL_FCNTL_H */
#endif /* _GL_FCNTL_H */
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif
10 changes: 5 additions & 5 deletions lib/float.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

#ifndef _GL_FLOAT_H
#ifndef _@GUARD_PREFIX@_FLOAT_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
Expand All @@ -25,8 +25,8 @@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_FLOAT_H@

#ifndef _GL_FLOAT_H
#define _GL_FLOAT_H
#ifndef _@GUARD_PREFIX@_FLOAT_H
#define _@GUARD_PREFIX@_FLOAT_H

/* 'long double' properties. */
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
Expand Down Expand Up @@ -59,5 +59,5 @@
# define LDBL_MAX_10_EXP 4932
#endif

#endif /* _GL_FLOAT_H */
#endif /* _GL_FLOAT_H */
#endif /* _@GUARD_PREFIX@_FLOAT_H */
#endif /* _@GUARD_PREFIX@_FLOAT_H */
10 changes: 5 additions & 5 deletions lib/getopt.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

#ifndef _GL_GETOPT_H
#ifndef _@GUARD_PREFIX@_GETOPT_H

#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
Expand All @@ -32,10 +32,10 @@
# undef _GL_SYSTEM_GETOPT
#endif

#ifndef _GL_GETOPT_H
#ifndef _@GUARD_PREFIX@_GETOPT_H

#ifndef __need_getopt
# define _GL_GETOPT_H 1
# define _@GUARD_PREFIX@_GETOPT_H 1
#endif

/* Standalone applications should #define __GETOPT_PREFIX to an
Expand Down Expand Up @@ -249,5 +249,5 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt

#endif /* getopt.h */
#endif /* getopt.h */
#endif /* _@GUARD_PREFIX@_GETOPT_H */
#endif /* _@GUARD_PREFIX@_GETOPT_H */
Loading

0 comments on commit 0ab583c

Please sign in to comment.