diff --git a/camlibs/ptp2/ptpcam.c b/camlibs/ptp2/ptpcam.c index f002abd65..f81b1fc9f 100644 --- a/camlibs/ptp2/ptpcam.c +++ b/camlibs/ptp2/ptpcam.c @@ -20,9 +20,12 @@ #include #include #include -#include #include +#ifdef HAVE_GETOPT_H +#include +#endif + #ifdef ENABLE_NLS # include # undef _ @@ -914,8 +917,12 @@ main(int argc, char ** argv) short force=0; uint16_t property=0; char* value=NULL; - /* parse options */ + +/* parse options */ +#ifdef HAVE_GETOPT int option_index = 0,opt; + char *optstr = "hlpfrs:D:B:v::"; +#ifdef HAVE_GETOPT_LONG static struct option loptions[] = { {"help",0,0,'h'}, {"bus",1,0,'B'}, @@ -930,9 +937,16 @@ main(int argc, char ** argv) {"verbose",2,0,'v'}, {0,0,0,0} }; +#endif +#endif while(1) { - opt = getopt_long (argc, argv, "hlpfrs:D:B:v::", loptions, &option_index); +#ifdef HAVE_GETOPT +#ifdef HAVE_GETOPT_LONG + opt = getopt_long (argc, argv, optstr, loptions, &option_index); +#else + opt = getopt (argc, argv, optstr); +#endif if (opt==-1) break; switch (opt) { diff --git a/configure.in b/configure.in index 7fe5d2753..ef7b6a2f6 100644 --- a/configure.in +++ b/configure.in @@ -95,7 +95,7 @@ dnl Checks for header files. dnl --------------------------------------------------------------------------- AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS(unistd.h mcheck.h) +AC_CHECK_HEADERS(getopt.h unistd.h mcheck.h) AC_INLINE AC_CONST @@ -134,7 +134,7 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T dnl Checks for library functions. -AC_CHECK_FUNCS(mkdir strdup strncpy strcpy snprintf sprintf vsnprintf) +AC_CHECK_FUNCS([getopt getopt_long mkdir strdup strncpy strcpy snprintf sprintf vsnprintf]) dnl Find out how to get struct tm AC_STRUCT_TM