conditional compilation of getopt*.c

This commit is contained in:
Francesco Lannutti 2012-11-17 12:22:24 +01:00 committed by rlar
parent 73a9929f0f
commit d74150ff44
3 changed files with 16 additions and 11 deletions

View File

@ -707,11 +707,14 @@ AC_CHECK_FUNCS([dirname], [],
[AC_DEFINE([HAVE_DIRNAME], [1], [Have dirname in libgen])
LIBS="$LIBS -lgen"])])
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([getopt.h], [getopt_h=true])
AM_CONDITIONAL([HAVE_GETOPT_H_WANTED], [test "x$getopt_h" = xtrue])
AC_CHECK_FUNC([getopt_long], [getopt_long=true])
if test "x$getopt_long" = xtrue; then
AC_DEFINE([HAVE_GETOPT_LONG], [1], [Have fcn getopt_long()])
fi
AM_CONDITIONAL([HAVE_GETOPT_LONG_WANTED], [test "x$getopt_long" = xtrue])
AC_DEFINE_UNQUOTED([NGSPICEBINDIR], ["`echo $dprefix/bin`"], [Define the directory for executables])
AC_DEFINE_UNQUOTED([NGSPICEDATADIR], ["`echo $dprefix/share/ngspice`"], [Define the directory for architecture independent data files])

View File

@ -4,8 +4,6 @@ noinst_LTLIBRARIES = libmisc.la
libmisc_la_SOURCES = \
getopt_long_bsd.c \
getopt_bsd.h \
alloc.c \
alloc.h \
dup2.c \
@ -27,11 +25,19 @@ libmisc_la_SOURCES = \
util.c \
util.h
## Note that the getopt files get compiled unconditionnaly but some
## magic #define away the body of their own code if the compilation environment
## provides an implementation of its own (like GNU libc)
### getopt_long_bsd.c ###
if !HAVE_GETOPT_H_WANTED
if !HAVE_GETOPT_LONG_WANTED
libmisc_la_SOURCES += getopt_long_bsd.c getopt_bsd.h
else
libmisc_la_SOURCES += getopt_long_bsd.c getopt_bsd.h
endif
else
if !HAVE_GETOPT_LONG_WANTED
libmisc_la_SOURCES += getopt_long_bsd.c getopt_bsd.h
endif
endif
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include

View File

@ -73,7 +73,6 @@
will not be used. Otherwise (as in MS Visual Studio) this file provides the fcn
getopt_long(), used in main() of ngspice
*/
#if !defined(HAVE_GETOPT_LONG) || !defined(HAVE_GETOPT_H)
#include "getopt_bsd.h"
@ -552,6 +551,3 @@ getopt_long_only(int nargc, char * const *nargv, const char *options,
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE|FLAG_LONGONLY));
}
#endif /* HAVE_GETOPT_LONG */