From 966b92bfbae617987535116545783abdd7e734a4 Mon Sep 17 00:00:00 2001 From: joerg Date: Fri, 21 Mar 2008 23:28:08 +0000 Subject: libnbcompat-20080322: Add an option to force a BSDish getopt (e.g. one with optreset). Use the correct macros to decide when to define optind and friends. --- pkgtools/libnbcompat/Makefile | 4 +- pkgtools/libnbcompat/files/configure | 308 ++++++++++++++------------- pkgtools/libnbcompat/files/configure.ac | 25 ++- pkgtools/libnbcompat/files/nbcompat/unistd.h | 10 +- 4 files changed, 190 insertions(+), 157 deletions(-) (limited to 'pkgtools/libnbcompat') diff --git a/pkgtools/libnbcompat/Makefile b/pkgtools/libnbcompat/Makefile index 2071ebcdfdc..839bdb586dc 100644 --- a/pkgtools/libnbcompat/Makefile +++ b/pkgtools/libnbcompat/Makefile @@ -1,11 +1,11 @@ -# $NetBSD: Makefile,v 1.57 2008/02/21 16:50:07 tnn Exp $ +# $NetBSD: Makefile,v 1.58 2008/03/21 23:28:08 joerg Exp $ # # NOTE: If you update this package, it is *mandatory* that you update # pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual # list of tested and supported platforms. # -DISTNAME= libnbcompat-20080221 +DISTNAME= libnbcompat-20080322 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/libnbcompat/files/configure b/pkgtools/libnbcompat/files/configure index c40f8003e3e..5c55ddc7826 100755 --- a/pkgtools/libnbcompat/files/configure +++ b/pkgtools/libnbcompat/files/configure @@ -1269,6 +1269,11 @@ if test -n "$ac_init_help"; then esac cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-bsd-getopt force use of BSDish getopt implementation + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -5618,6 +5623,158 @@ esac fi +# Check whether --enable-bsd-getopt was given. +if test "${enable_bsd_getopt+set}" = set; then + enableval=$enable_bsd_getopt; +fi + + +{ echo "$as_me:$LINENO: checking whether optind is declared" >&5 +echo $ECHO_N "checking whether optind is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_optind+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + #include + #include + + +int +main () +{ +#ifndef optind + (void) optind; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_optind=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_optind=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_optind" >&5 +echo "${ECHO_T}$ac_cv_have_decl_optind" >&6; } +if test $ac_cv_have_decl_optind = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_OPTIND 1 +_ACEOF + +: +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_OPTIND 0 +_ACEOF + +: +fi +{ echo "$as_me:$LINENO: checking whether optreset is declared" >&5 +echo $ECHO_N "checking whether optreset is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_optreset+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + #include + #include + + +int +main () +{ +#ifndef optreset + (void) optreset; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_optreset=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_optreset=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_optreset" >&5 +echo "${ECHO_T}$ac_cv_have_decl_optreset" >&6; } +if test $ac_cv_have_decl_optreset = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_OPTRESET 1 +_ACEOF + +: +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_OPTRESET 0 +_ACEOF + +: +fi + + + + pkg_use_nbcompat_getopt_long=yes for ac_header in getopt.h @@ -5825,6 +5982,12 @@ fi done +if test "$enable_bsd_getopt" = yes; then + if test "$ac_cv_have_decl_optreset" = no; then + pkg_use_nbcompat_getopt_long=yes + fi +fi + if test $pkg_use_nbcompat_getopt_long = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_NBCOMPAT_GETOPT_LONG 1 @@ -12086,151 +12249,6 @@ esac fi -{ echo "$as_me:$LINENO: checking whether optind is declared" >&5 -echo $ECHO_N "checking whether optind is declared... $ECHO_C" >&6; } -if test "${ac_cv_have_decl_optind+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - - #include - #include - #include - - -int -main () -{ -#ifndef optind - (void) optind; -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_have_decl_optind=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_have_decl_optind=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_optind" >&5 -echo "${ECHO_T}$ac_cv_have_decl_optind" >&6; } -if test $ac_cv_have_decl_optind = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_OPTIND 1 -_ACEOF - -: -else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_OPTIND 0 -_ACEOF - -: -fi -{ echo "$as_me:$LINENO: checking whether optreset is declared" >&5 -echo $ECHO_N "checking whether optreset is declared... $ECHO_C" >&6; } -if test "${ac_cv_have_decl_optreset+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - - #include - #include - #include - - -int -main () -{ -#ifndef optreset - (void) optreset; -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_have_decl_optreset=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_have_decl_optreset=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_optreset" >&5 -echo "${ECHO_T}$ac_cv_have_decl_optreset" >&6; } -if test $ac_cv_have_decl_optreset = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_OPTRESET 1 -_ACEOF - -: -else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_OPTRESET 0 -_ACEOF - -: -fi - - - diff --git a/pkgtools/libnbcompat/files/configure.ac b/pkgtools/libnbcompat/files/configure.ac index e77ff96cbbe..b11d839687e 100644 --- a/pkgtools/libnbcompat/files/configure.ac +++ b/pkgtools/libnbcompat/files/configure.ac @@ -1,4 +1,4 @@ -dnl $NetBSD: configure.ac,v 1.59 2008/02/21 16:50:08 tnn Exp $ +dnl $NetBSD: configure.ac,v 1.60 2008/03/21 23:28:08 joerg Exp $ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.52) @@ -135,6 +135,17 @@ AC_CHECK_FUNC(SHA512_File, [:], [ AC_LIBOBJ(sha2hl) ]) +AC_ARG_ENABLE([bsd-getopt], + [AS_HELP_STRING([--enable-bsd-getopt], + [force use of BSDish getopt implementation])]) + +AC_CHECK_DECLS([optind, optreset], [:], [:], [ + #include + #include + #include +]) + + pkg_use_nbcompat_getopt_long=yes AC_CHECK_HEADERS([getopt.h], [ AC_MSG_TRY_COMPILE([for struct option], pkg_cv_have_struct_option, @@ -143,6 +154,12 @@ AC_CHECK_HEADERS([getopt.h], [ [pkg_use_nbcompat_getopt_long=yes]) ]) +if test "$enable_bsd_getopt" = yes; then + if test "$ac_cv_have_decl_optreset" = no; then + pkg_use_nbcompat_getopt_long=yes + fi +fi + if test $pkg_use_nbcompat_getopt_long = yes; then AC_DEFINE(HAVE_NBCOMPAT_GETOPT_LONG) AH_TEMPLATE([HAVE_NBCOMPAT_GETOPT_LONG], [ @@ -437,12 +454,6 @@ if test $have_std_vsnprintf = no; then AC_LIBOBJ(snprintf) fi -AC_CHECK_DECLS([optind, optreset], [:], [:], [ - #include - #include - #include -]) - AH_BOTTOM([ /* NBCOMPAT template section follows. */ diff --git a/pkgtools/libnbcompat/files/nbcompat/unistd.h b/pkgtools/libnbcompat/files/nbcompat/unistd.h index 653722c75af..d4b50add871 100644 --- a/pkgtools/libnbcompat/files/nbcompat/unistd.h +++ b/pkgtools/libnbcompat/files/nbcompat/unistd.h @@ -1,4 +1,4 @@ -/* $NetBSD: unistd.h,v 1.2 2004/08/23 03:32:13 jlam Exp $ */ +/* $NetBSD: unistd.h,v 1.3 2008/03/21 23:28:09 joerg Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -47,14 +47,18 @@ * Declare functions and macros that may be missing in . */ -#if !HAVE_OPTARG_D +#if !HAVE_DECL_OPTARG extern char *optarg; #endif -#if !HAVE_OPTIND_D +#if !HAVE_DECL_OPTIND extern int optind; #endif +#if !HAVE_DECL_OPTRESET +extern int optreset; +#endif + #if !HAVE_GETPASS_D char *getpass(const char *); #endif -- cgit v1.2.3