From: Guus Sliepen Date: Fri, 8 Apr 2016 15:49:49 +0000 (+0200) Subject: Don't compile getopt*.c if the system provides getopt_long(). X-Git-Tag: release-1.0.27~13 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=c40c99592b9512049e85323c59432a380239151f;p=tinc Don't compile getopt*.c if the system provides getopt_long(). --- diff --git a/configure.ac b/configure.ac index 5cdd6422..3b781ba5 100644 --- a/configure.ac +++ b/configure.ac @@ -160,7 +160,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. 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 time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.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 time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.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 netpacket/packet.h], [], [], [#include "src/have.h"] ) @@ -191,6 +191,9 @@ AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name get [], [], [#include "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 AC_CHECK_FUNC(socket, [], [ diff --git a/src/Makefile.am b/src/Makefile.am index ebd52abc..a5a96922 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,8 +17,6 @@ tincd_SOURCES = \ fake-gai-errnos.h \ fake-getaddrinfo.c fake-getaddrinfo.h \ fake-getnameinfo.c fake-getnameinfo.h \ - getopt.c getopt.h \ - getopt1.c \ graph.c graph.h \ ipv4.h \ ipv6.h \ @@ -49,6 +47,12 @@ tincd_SOURCES = \ xalloc.h \ xmalloc.c +if !GETOPT +tincd_SOURCES += \ + getopt.c getopt.h \ + getopt1.c +endif + if LINUX tincd_SOURCES += linux/device.c endif diff --git a/src/tincd.c b/src/tincd.c index ed0cee93..db18dc57 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -49,7 +49,12 @@ #include #endif +#ifdef HAVE_GETOPT_LONG #include +#else +#include "getopt.h" +#endif + #include "pidfile.h" #include "conf.h"