diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2023-10-27 15:54:48 +0100 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2023-10-27 15:54:48 +0100 |
commit | e5f6a5ad7ceece5238fc3d63f7ea92574df4264d (patch) | |
tree | 5c841dfc66b6195603dadff8ee74588f58f8269e /libgm2/configure | |
parent | 7bcdb777e6a0d1a0159f25616c5d8e35e7cb5fb6 (diff) | |
download | gcc-e5f6a5ad7ceece5238fc3d63f7ea92574df4264d.zip gcc-e5f6a5ad7ceece5238fc3d63f7ea92574df4264d.tar.gz gcc-e5f6a5ad7ceece5238fc3d63f7ea92574df4264d.tar.bz2 |
PR modula2/111530: Build failure on BSD due to getopt_long_only GNU extension dependency
This patch uses the libiberty getopt long functions (wrapped up inside
libgm2/libm2pim/cgetopt.cc) and only enables this implementation if
libgm2/configure.ac detects no getopt_long and friends on the target.
gcc/m2/ChangeLog:
PR modula2/111530
* gm2-libs-ch/cgetopt.c (cgetopt_cgetopt_long): Re-format.
(cgetopt_cgetopt_long_only): Re-format.
(cgetopt_SetOption): Re-format and assign flag to NULL
if name is also NULL.
* gm2-libs/GetOpt.def (AddLongOption): Add index parameter
and change flag to be a VAR parameter rather than a pointer.
(GetOptLong): Re-format.
(GetOpt): Correct comment.
* gm2-libs/GetOpt.mod: Re-write to rely on cgetopt rather
than implement long option creation in GetOpt.
* gm2-libs/cgetopt.def (SetOption): has_arg type is INTEGER.
libgm2/ChangeLog:
PR modula2/111530
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac (AC_CHECK_HEADERS): Include getopt.h.
(GM2_CHECK_LIB): getopt_long check.
(GM2_CHECK_LIB): getopt_long_only check.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.in: Regenerate.
* libm2pim/cgetopt.cc: Re-write using conditional on configure
and long function code from libiberty/getopt.c.
gcc/testsuite/ChangeLog:
PR modula2/111530
* gm2/pimlib/run/pass/testgetopt.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'libgm2/configure')
-rwxr-xr-x | libgm2/configure | 147 |
1 files changed, 142 insertions, 5 deletions
diff --git a/libgm2/configure b/libgm2/configure index d55a7f4..a0ad71e 100755 --- a/libgm2/configure +++ b/libgm2/configure @@ -4950,8 +4950,8 @@ fi -for ac_header in limits.h stddef.h string.h strings.h stdlib.h \ - time.h \ +for ac_header in getopt.h limits.h stddef.h string.h strings.h \ + stdlib.h time.h \ fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \ sys/resource.h sys/param.h sys/times.h sys/stat.h \ sys/socket.h \ @@ -4973,7 +4973,6 @@ done - case ${build_alias} in "") build_noncanonical=${build} ;; *) build_noncanonical=${build_alias} ;; @@ -12789,7 +12788,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12792 "configure" +#line 12791 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12895,7 +12894,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12898 "configure" +#line 12897 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18061,6 +18060,144 @@ $as_echo "#define HAVE_GETGID 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking m2 front end checking c library for getopt_long" >&5 +$as_echo_n "checking m2 front end checking c library for getopt_long... " >&6; } + if test x$gcc_no_link != xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getopt_long in -lc" >&5 +$as_echo_n "checking for getopt_long in -lc... " >&6; } +if ${ac_cv_lib_c_getopt_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getopt_long (); +int +main () +{ +return getopt_long (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_getopt_long=yes +else + ac_cv_lib_c_getopt_long=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_getopt_long" >&5 +$as_echo "$ac_cv_lib_c_getopt_long" >&6; } +if test "x$ac_cv_lib_c_getopt_long" = xyes; then : + +$as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h + +else + + $as_echo "#undef HAVE_GETOPT_LONG" >>confdefs.h + +fi + + else + if test "x$ac_cv_lib_c_getopt_long" = xyes; then + +$as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h + + elif test "x$ac_cv_func_getopt_long" = xyes; then + +$as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h + + else + + $as_echo "#undef HAVE_GETOPT_LONG" >>confdefs.h + + fi + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking m2 front end checking c library for getopt_long_only" >&5 +$as_echo_n "checking m2 front end checking c library for getopt_long_only... " >&6; } + if test x$gcc_no_link != xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getopt_long_only in -lc" >&5 +$as_echo_n "checking for getopt_long_only in -lc... " >&6; } +if ${ac_cv_lib_c_getopt_long_only+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getopt_long_only (); +int +main () +{ +return getopt_long_only (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_getopt_long_only=yes +else + ac_cv_lib_c_getopt_long_only=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_getopt_long_only" >&5 +$as_echo "$ac_cv_lib_c_getopt_long_only" >&6; } +if test "x$ac_cv_lib_c_getopt_long_only" = xyes; then : + +$as_echo "#define HAVE_GETOPT_LONG_ONLY 1" >>confdefs.h + +else + + $as_echo "#undef HAVE_GETOPT_LONG_ONLY" >>confdefs.h + +fi + + else + if test "x$ac_cv_lib_c_getopt_long_only" = xyes; then + +$as_echo "#define HAVE_GETOPT_LONG_ONLY 1" >>confdefs.h + + elif test "x$ac_cv_func_getopt_long_only" = xyes; then + +$as_echo "#define HAVE_GETOPT_LONG_ONLY 1" >>confdefs.h + + else + + $as_echo "#undef HAVE_GETOPT_LONG_ONLY" >>confdefs.h + + fi + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking m2 front end checking c library for getpid" >&5 $as_echo_n "checking m2 front end checking c library for getpid... " >&6; } if test x$gcc_no_link != xyes; then |