From: Sami Kerola Date: Sun, 21 Aug 2016 18:32:38 +0000 (+0100) Subject: build-sys: use system getopt_long() when it is available X-Git-Tag: v0.88~29^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c6fe5e6dc6635fbafffd6ba1aaea72c31f2e31d;p=thirdparty%2Fmtr.git build-sys: use system getopt_long() when it is available And move the getopt sources to portability support directory. --- diff --git a/Makefile.am b/Makefile.am index 3e926cd..cb4d2f4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,12 +13,18 @@ mtr_SOURCES = mtr.c mtr.h \ split.c split.h \ display.c display.h \ report.c report.h \ - getopt.c getopt1.c getopt.h \ select.c select.h \ mtr-curses.h \ img/mtr_icon.xpm \ mtr-gtk.h +if WITH_GETOPT +mtr_SOURCES += \ + portability/getopt.h \ + portability/getopt.c \ + portability/getopt1.c +endif + if WITH_IPINFO mtr_SOURCES += asn.c asn.h endif diff --git a/configure.ac b/configure.ac index 98f0c63..9fceaa9 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,12 @@ AC_CHECK_FUNCS([ \ fcntl \ ]) +AC_CHECK_FUNC([getopt_long], [with_getopt=no], [with_getopt=yes]) +AS_IF([test "x$with_getopt" = "xno"], [ + AC_DEFINE([HAVE_GETOPT], [1], [Define if libc has getopt_long]) +]) +AM_CONDITIONAL([WITH_GETOPT], [test "x$with_getopt" = "xyes"]) + AC_CHECK_LIB([m], [floor], [], [AC_MSG_ERROR([No math library found])]) # Find GTK diff --git a/mtr.c b/mtr.c index fd254ba..c471904 100644 --- a/mtr.c +++ b/mtr.c @@ -40,13 +40,17 @@ #include "mtr.h" #include "mtr-curses.h" -#include "getopt.h" #include "display.h" #include "dns.h" #include "report.h" #include "net.h" #include "asn.h" +#ifdef HAVE_GETOPT +#include +#else +#include "portability/getopt.h" +#endif #ifdef ENABLE_IPV6 #define DEFAULT_AF AF_UNSPEC diff --git a/getopt.c b/portability/getopt.c similarity index 100% rename from getopt.c rename to portability/getopt.c diff --git a/getopt.h b/portability/getopt.h similarity index 100% rename from getopt.h rename to portability/getopt.h diff --git a/getopt1.c b/portability/getopt1.c similarity index 100% rename from getopt1.c rename to portability/getopt1.c