[vlc-devel] commit: Always build and use "our" getopt ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Feb 28 16:02:23 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 28 14:58:26 2010 +0200| [b3a59c07e71c74191c2d1524dbd2f5412dd762db] | committer: Rémi Denis-Courmont 

Always build and use "our" getopt

(We still need -lgnugetopt for cachegen)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b3a59c07e71c74191c2d1524dbd2f5412dd762db
---

 bin/Makefile.am      |    1 +
 configure.ac         |   21 ++++++++-------------
 src/Makefile.am      |   14 +++-----------
 src/config/cmdline.c |   10 ++--------
 src/extras/getopt.c  |    4 ----
 src/extras/getopt.h  |    4 ++--
 src/extras/getopt1.c |    6 +-----
 7 files changed, 17 insertions(+), 43 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index dfeaee2..2bb4294 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -57,5 +57,6 @@ vlc_win32_rc.$(OBJEXT): vlc_win32_rc.rc
 
 vlc_cache_gen_SOURCES = cachegen.c
 vlc_cache_gen_LDADD = \
+	$(GNUGETOPT_LIBS) \
 	../compat/libcompat.la \
 	../src/libvlc.la ../src/libvlccore.la
diff --git a/configure.ac b/configure.ac
index 31ff8c8..206b269 100644
--- a/configure.ac
+++ b/configure.ac
@@ -646,19 +646,14 @@ AC_CHECK_FUNCS(inet_aton,,[
   ])
 ])
 
-dnl Check for getopt (always use builtin one on win32)
-if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"; then
-need_getopt=:
-else
-need_getopt=false
-AC_CHECK_FUNCS(getopt_long,[AC_DEFINE(HAVE_GETOPT_LONG,1,long getopt support)],
-[ # FreeBSD has a gnugetopt library for this:
-  AC_CHECK_LIB([gnugetopt],[getopt_long],
-    [AC_DEFINE(HAVE_GETOPT_LONG,1,getopt support)
-     VLC_ADD_LIBS([libvlccore],[-lgnugetopt])],
-    [need_getopt=:])])
-fi
-AM_CONDITIONAL(BUILD_GETOPT, ${need_getopt})
+dnl FreeBSD has a gnugetopt library for this:
+GNUGETOPT_LIBS=""
+AC_CHECK_FUNC(getopt_long,, [
+  AC_CHECK_LIB([gnugetopt],[getopt_long], [
+    GNUGETOPT_LIBS="-lgnugetopt"
+  ])
+])
+AC_SUBST(GNUGETOPT_LIBS)
 
 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
 AC_CHECK_LIB(m,cos,[
diff --git a/src/Makefile.am b/src/Makefile.am
index 973979a..c265d6d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -228,7 +228,6 @@ EXTRA_libvlccore_la_SOURCES = \
 	$(SOURCES_libvlc_win32) \
 	$(SOURCES_libvlc_other) \
 	$(SOURCES_libvlc_dirent) \
-	$(SOURCES_libvlc_getopt) \
 	$(SOURCES_libvlc_httpd) \
 	$(SOURCES_libvlc_sout) \
 	$(SOURCES_libvlc_vlm) \
@@ -257,9 +256,6 @@ endif
 if BUILD_DIRENT
 libvlccore_la_SOURCES += $(SOURCES_libvlc_dirent)
 endif
-if BUILD_GETOPT
-libvlccore_la_SOURCES += $(SOURCES_libvlc_getopt)
-endif
 if BUILD_HTTPD
 libvlccore_la_SOURCES += $(SOURCES_libvlc_httpd)
 endif
@@ -302,12 +298,6 @@ SOURCES_libvlc_dirent = \
 	extras/dirent.c \
 	$(NULL)
 
-SOURCES_libvlc_getopt = \
-	extras/getopt.c \
-	extras/getopt.h \
-	extras/getopt1.c \
-	$(NULL)
-
 SOURCES_libvlc_common = \
 	libvlc.c \
 	libvlc.h \
@@ -456,6 +446,9 @@ SOURCES_libvlc_common = \
 	misc/filter_chain.c \
 	misc/http_auth.c \
 	misc/sql.c \
+	extras/getopt.c \
+	extras/getopt.h \
+	extras/getopt1.c \
 	$(NULL)
 
 SOURCES_libvlc_httpd = \
@@ -482,7 +475,6 @@ SOURCES_libvlc = \
 	$(OPT_SOURCES_libvlc_darwin) \
 	$(OPT_SOURCES_libvlc_win32) \
 	$(OPT_SOURCES_libvlc_dirent) \
-	$(OPT_SOURCES_libvlc_getopt) \
 	$(NULL)
 
 SOURCES_libvlc_control = \
diff --git a/src/config/cmdline.c b/src/config/cmdline.c
index 3878564..5316e82 100644
--- a/src/config/cmdline.c
+++ b/src/config/cmdline.c
@@ -30,13 +30,7 @@
 #include <vlc_keys.h>
 #include <vlc_charset.h>
 
-#ifdef HAVE_GETOPT_LONG
-#   ifdef HAVE_GETOPT_H
-#       include <getopt.h>                                       /* getopt() */
-#   endif
-#else
-#   include "../extras/getopt.h"
-#endif
+#include "../extras/getopt.h"
 
 #include "configuration.h"
 #include "modules/modules.h"
@@ -219,7 +213,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
      */
     opterr = 0;
     optind = 0; /* set to 0 to tell GNU getopt to reinitialize */
-    while( ( i_cmd = getopt_long( *pi_argc, (char **)ppsz_argv, psz_shortopts,
+    while( ( i_cmd = vlc_getopt_long( *pi_argc, (char **)ppsz_argv, psz_shortopts,
                                   p_longopts, &i_index ) ) != -1 )
     {
         /* A long option has been recognized */
diff --git a/src/extras/getopt.c b/src/extras/getopt.c
index fe301f4..ae4ab5e 100644
--- a/src/extras/getopt.c
+++ b/src/extras/getopt.c
@@ -61,8 +61,6 @@
 #endif
 #endif
 
-#ifndef ELIDE_CODE
-
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
 #ifdef    __GNU_LIBRARY__
@@ -937,8 +935,6 @@ int
                 (int *) 0,
                 0);
 }
-
-#endif /* Not ELIDE_CODE.  */
 

 #ifdef TEST
 
diff --git a/src/extras/getopt.h b/src/extras/getopt.h
index c05d74f..b14fe61 100644
--- a/src/extras/getopt.h
+++ b/src/extras/getopt.h
@@ -108,7 +108,7 @@ extern "C"
 #else                /* not __GNU_LIBRARY__ */
     extern int getopt();
 #endif                /* __GNU_LIBRARY__ */
-    extern int getopt_long(int argc, char *const *argv, const char *shortopts,
+    extern int vlc_getopt_long(int argc, char *const *argv, const char *shortopts,
                    const struct option *longopts, int *longind);
     extern int getopt_long_only(int argc, char *const *argv,
                     const char *shortopts,
@@ -121,7 +121,7 @@ extern "C"
                     int long_only);
 #else                /* not __STDC__ */
     extern int getopt();
-    extern int getopt_long();
+    extern int vlc_getopt_long();
     extern int getopt_long_only();
 
     extern int _getopt_internal();
diff --git a/src/extras/getopt1.c b/src/extras/getopt1.c
index c10b906..b846efc 100644
--- a/src/extras/getopt1.c
+++ b/src/extras/getopt1.c
@@ -51,8 +51,6 @@
 #endif
 #endif
 
-#ifndef ELIDE_CODE
-
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
 #ifdef __GNU_LIBRARY__
@@ -64,7 +62,7 @@
 #endif
 
 int
-    getopt_long(argc, argv, options, long_options, opt_index)
+    vlc_getopt_long(argc, argv, options, long_options, opt_index)
      int argc;
      char *const *argv;
      const char *options;
@@ -89,8 +87,6 @@ int
 {
     return _getopt_internal(argc, argv, options, long_options, opt_index, 1);
 }
-
-#endif /* Not ELIDE_CODE.  */
 

 #ifdef TEST
 




More information about the vlc-devel mailing list