Don't compile getopt*.c if the system provides getopt_long().

# Conflicts:
#	configure.ac
#	src/Makefile.am
#	src/tincd.c
This commit is contained in:
Guus Sliepen 2016-04-08 17:49:49 +02:00
parent c2726dae62
commit 9f0fb224a6
4 changed files with 26 additions and 6 deletions

View file

@ -170,7 +170,7 @@ dnl Checks for header files.
dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies. dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h]) AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h getopt.h])
AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h netpacket/packet.h], AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h netpacket/packet.h],
[], [], [#include "$srcdir/src/have.h"] [], [], [#include "$srcdir/src/have.h"]
) )
@ -202,6 +202,9 @@ AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name get
[], [], [#include "$srcdir/src/have.h"] [], [], [#include "$srcdir/src/have.h"]
) )
AC_CHECK_FUNC(getopt_long, [getopt=true; AC_DEFINE(HAVE_GETOPT_LONG, 1, [getopt_long()])], [getopt=false])
AM_CONDITIONAL(GETOPT, test "$getopt" = true)
dnl Support for SunOS dnl Support for SunOS
AC_CHECK_FUNC(socket, [], [ AC_CHECK_FUNC(socket, [], [

View file

@ -53,8 +53,6 @@ tincd_SOURCES = \
fake-gai-errnos.h \ fake-gai-errnos.h \
fake-getaddrinfo.c fake-getaddrinfo.h \ fake-getaddrinfo.c fake-getaddrinfo.h \
fake-getnameinfo.c fake-getnameinfo.h \ fake-getnameinfo.c fake-getnameinfo.h \
getopt.c getopt.h \
getopt1.c \
graph.c graph.h \ graph.c graph.h \
hash.c hash.h \ hash.c hash.h \
have.h \ have.h \
@ -149,7 +147,22 @@ sptps_speed_SOURCES = \
$(chacha_poly1305_SOURCES) $(chacha_poly1305_SOURCES)
## Conditionally compile device drivers ## Conditionally compile device drivers
if !GETOPT
tincd_SOURCES += \
getopt.c getopt.h \
getopt1.c
tinc_SOURCES += \
getopt.c getopt.h \
getopt1.cendif
sptps_test_SOURCES += \
getopt.c getopt.h \
getopt1.c
sptps_keypair_SOURCES += \
getopt.c getopt.h \
getopt1.c
endif
if LINUX if LINUX
tincd_SOURCES += linux/device.c tincd_SOURCES += linux/device.c
endif endif

View file

@ -210,6 +210,12 @@
#include <linux/if_tun.h> #include <linux/if_tun.h>
#endif #endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else
#include "getopt.h"
#endif
#ifdef STATUS #ifdef STATUS
#undef STATUS #undef STATUS
#endif #endif

View file

@ -43,8 +43,6 @@
#include <time.h> #include <time.h>
#endif #endif
#include <getopt.h>
#include "conf.h" #include "conf.h"
#include "control.h" #include "control.h"
#include "crypto.h" #include "crypto.h"