From: Mike Frysinger Date: Sun, 15 Oct 2023 16:39:43 +0000 (+0545) Subject: gnulib: support building for --build [PR sim/30882] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba0eff81c4a57253b3263c5df497eb935eff2445;p=thirdparty%2Fbinutils-gdb.git gnulib: support building for --build [PR sim/30882] The sim tree has some build-time programs for generating source files that are a bit complicated and expect a POSIX-compatible system. But some targets (e.g. mingw) might not provide up-to-date support. Since we already have gnulib in the tree, leverage that to also build for the --build system. The top-level configure logic will pass down --with-build-subdir when the subdir is built for it. Use that to adjust the output variable names and paths. This allows us to include the gnulib makefile frags for both --host and --build simultaneously. --- diff --git a/gnulib/Makefile.gnulib.inc.in b/gnulib/Makefile.gnulib.inc.in index 777a99c58d1..755516632f7 100644 --- a/gnulib/Makefile.gnulib.inc.in +++ b/gnulib/Makefile.gnulib.inc.in @@ -31,16 +31,20 @@ # # INCGNU: A list of -I.... include paths that should be passed to the # compiler, these are where the gnulib headers can be found. +# +# When building for --build, the variables will be prefixed with BUILD_. # Packages must define the relative path to gnulib's parent dir. ifndef GNULIB_PARENT_DIR $(error missing GNULIB_PARENT_DIR) endif -LIBGNU = $(GNULIB_PARENT_DIR)/gnulib/import/libgnu.a -LIBGNU_EXTRA_LIBS = @FREXPL_LIBM@ @FREXP_LIBM@ @INET_NTOP_LIB@ \ - @LIBTHREAD@ @LIB_GETLOGIN@ @LIB_GETRANDOM@ \ - @LIB_HARD_LOCALE@ @LIB_MBRTOWC@ \ - @LIB_SETLOCALE_NULL@ @LIBINTL@ @LIB_SELECT@ @LIBSOCKET@ -INCGNU = -I$(srcdir)/$(GNULIB_PARENT_DIR)/gnulib/import \ - -I$(GNULIB_PARENT_DIR)/gnulib/import +@VAR_PREFIX@LIBGNU = $(GNULIB_PARENT_DIR)/@BUILD_SUBDIR@gnulib/import/libgnu.a +@VAR_PREFIX@LIBGNU_EXTRA_LIBS = \ + @FREXPL_LIBM@ @FREXP_LIBM@ @INET_NTOP_LIB@ \ + @LIBTHREAD@ @LIB_GETLOGIN@ @LIB_GETRANDOM@ \ + @LIB_HARD_LOCALE@ @LIB_MBRTOWC@ \ + @LIB_SETLOCALE_NULL@ @LIBINTL@ @LIB_SELECT@ @LIBSOCKET@ +@VAR_PREFIX@INCGNU = \ + -I$(srcdir)/$(GNULIB_PARENT_DIR)/gnulib/import \ + -I$(GNULIB_PARENT_DIR)/@BUILD_SUBDIR@gnulib/import diff --git a/gnulib/Makefile.in b/gnulib/Makefile.in index 02886fe877a..3b4c97a5114 100644 --- a/gnulib/Makefile.in +++ b/gnulib/Makefile.in @@ -366,6 +366,7 @@ BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@ BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@ BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@ BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@ +BUILD_SUBDIR = @BUILD_SUBDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -1674,6 +1675,7 @@ UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_SYS_RANDOM_H = @UNISTD_H_HAVE_SYS_RANDOM_H@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ +VAR_PREFIX = @VAR_PREFIX@ VERSION = @VERSION@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ diff --git a/gnulib/configure b/gnulib/configure index cb2a11359a1..b667694b37b 100755 --- a/gnulib/configure +++ b/gnulib/configure @@ -635,6 +635,8 @@ gl_LTLIBOBJS gl_LIBOBJS LTLIBOBJS LIBOBJS +VAR_PREFIX +BUILD_SUBDIR LN_S AM_BACKSLASH AM_DEFAULT_VERBOSITY @@ -2219,6 +2221,7 @@ enable_threads enable_cross_guesses enable_dependency_tracking enable_silent_rules +with_build_subdir ' ac_precious_vars='build_alias host_alias @@ -2866,6 +2869,12 @@ Optional Features: --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-build-subdir=SUBDIR + Configuring in a subdirectory for build + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -13813,8 +13822,8 @@ rm -f core conftest.err conftest.$ac_objext \ LIBS=$save_LIBS test $gl_pthread_api = yes && break done - echo "$as_me:13816: gl_pthread_api=$gl_pthread_api" >&5 - echo "$as_me:13817: LIBPTHREAD=$LIBPTHREAD" >&5 + echo "$as_me:13825: gl_pthread_api=$gl_pthread_api" >&5 + echo "$as_me:13826: LIBPTHREAD=$LIBPTHREAD" >&5 gl_pthread_in_glibc=no # On Linux with glibc >= 2.34, libc contains the fully functional @@ -13839,7 +13848,7 @@ rm -f conftest* ;; esac - echo "$as_me:13842: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 + echo "$as_me:13851: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 # Test for libpthread by looking for pthread_kill. (Not pthread_self, # since it is defined as a macro on OSF/1.) @@ -13993,7 +14002,7 @@ fi fi fi - echo "$as_me:13996: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 + echo "$as_me:14005: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5 $as_echo_n "checking whether POSIX threads API is available... " >&6; } @@ -17070,8 +17079,8 @@ rm -f core conftest.err conftest.$ac_objext \ LIBS=$save_LIBS test $gl_pthread_api = yes && break done - echo "$as_me:17073: gl_pthread_api=$gl_pthread_api" >&5 - echo "$as_me:17074: LIBPTHREAD=$LIBPTHREAD" >&5 + echo "$as_me:17082: gl_pthread_api=$gl_pthread_api" >&5 + echo "$as_me:17083: LIBPTHREAD=$LIBPTHREAD" >&5 gl_pthread_in_glibc=no # On Linux with glibc >= 2.34, libc contains the fully functional @@ -17096,7 +17105,7 @@ rm -f conftest* ;; esac - echo "$as_me:17099: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 + echo "$as_me:17108: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 # Test for libpthread by looking for pthread_kill. (Not pthread_self, # since it is defined as a macro on OSF/1.) @@ -17250,7 +17259,7 @@ fi fi fi - echo "$as_me:17253: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 + echo "$as_me:17262: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5 $as_echo_n "checking whether POSIX threads API is available... " >&6; } @@ -17476,8 +17485,8 @@ rm -f core conftest.err conftest.$ac_objext \ LIBS=$save_LIBS test $gl_pthread_api = yes && break done - echo "$as_me:17479: gl_pthread_api=$gl_pthread_api" >&5 - echo "$as_me:17480: LIBPTHREAD=$LIBPTHREAD" >&5 + echo "$as_me:17488: gl_pthread_api=$gl_pthread_api" >&5 + echo "$as_me:17489: LIBPTHREAD=$LIBPTHREAD" >&5 gl_pthread_in_glibc=no # On Linux with glibc >= 2.34, libc contains the fully functional @@ -17502,7 +17511,7 @@ rm -f conftest* ;; esac - echo "$as_me:17505: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 + echo "$as_me:17514: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 # Test for libpthread by looking for pthread_kill. (Not pthread_self, # since it is defined as a macro on OSF/1.) @@ -17656,7 +17665,7 @@ fi fi fi - echo "$as_me:17659: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 + echo "$as_me:17668: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5 $as_echo_n "checking whether POSIX threads API is available... " >&6; } @@ -36621,6 +36630,23 @@ fi # Checks for libraries. # # ---------------------- # + +# Check whether --with-build-subdir was given. +if test "${with_build_subdir+set}" = set; then : + withval=$with_build_subdir; +fi + + +VAR_PREFIX= +BUILD_SUBDIR= +if test -n "${with_build_subdir}"; then : + VAR_PREFIX="BUILD_" + BUILD_SUBDIR="${with_build_subdir}/" + +fi + + + ac_config_files="$ac_config_files Makefile.gnulib.inc" diff --git a/gnulib/configure.ac b/gnulib/configure.ac index 9f081614efd..72a16d5ae6e 100644 --- a/gnulib/configure.ac +++ b/gnulib/configure.ac @@ -56,6 +56,18 @@ AC_CHECK_TOOL(AR, ar) # Checks for libraries. # # ---------------------- # +AC_ARG_WITH(build-subdir, + [AS_HELP_STRING([--with-build-subdir=SUBDIR], [Configuring in a subdirectory for build])]) + +VAR_PREFIX= +BUILD_SUBDIR= +AS_IF([test -n "${with_build_subdir}"], [dnl + VAR_PREFIX="BUILD_" + BUILD_SUBDIR="${with_build_subdir}/" +]) +AC_SUBST(BUILD_SUBDIR) +AC_SUBST(VAR_PREFIX) + AC_CONFIG_FILES(Makefile.gnulib.inc) AC_OUTPUT(Makefile import/Makefile, diff --git a/gnulib/import/Makefile.in b/gnulib/import/Makefile.in index 1899bebba36..323cbb87708 100644 --- a/gnulib/import/Makefile.in +++ b/gnulib/import/Makefile.in @@ -700,6 +700,7 @@ BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@ BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@ BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@ BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@ +BUILD_SUBDIR = @BUILD_SUBDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -2008,6 +2009,7 @@ UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_SYS_RANDOM_H = @UNISTD_H_HAVE_SYS_RANDOM_H@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ +VAR_PREFIX = @VAR_PREFIX@ VERSION = @VERSION@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@