]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
build-sys: use system getopt_long() when it is available
authorSami Kerola <kerolasa@iki.fi>
Sun, 21 Aug 2016 18:32:38 +0000 (19:32 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 21 Aug 2016 19:10:43 +0000 (20:10 +0100)
And move the getopt sources to portability support directory.

Makefile.am
configure.ac
mtr.c
portability/getopt.c [moved from getopt.c with 100% similarity]
portability/getopt.h [moved from getopt.h with 100% similarity]
portability/getopt1.c [moved from getopt1.c with 100% similarity]

index 3e926cdb0f62fe4e27f6fda0648042e7da0ae6a2..cb4d2f4d313741170cd6e5caebe46627f5d73fe0 100644 (file)
@@ -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
index 98f0c6375bc9ab0f30b9d5420b92f63187ad60be..9fceaa9242a900939a667a91d7714b28b972f8cd 100644 (file)
@@ -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 fd254baae9944c99e1ed41d63f20101893bf4496..c47190406180ed40812e900973f85af50bdcd9ba 100644 (file)
--- a/mtr.c
+++ b/mtr.c
 
 #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 <getopt.h>
+#else
+#include "portability/getopt.h"
+#endif
 
 #ifdef ENABLE_IPV6
 #define DEFAULT_AF AF_UNSPEC
similarity index 100%
rename from getopt.c
rename to portability/getopt.c
similarity index 100%
rename from getopt.h
rename to portability/getopt.h
similarity index 100%
rename from getopt1.c
rename to portability/getopt1.c