better xlC support on AIX; added option to use bundled getopt on UNIX
authorVictor Kirhenshtein <victor@netxms.org>
Sat, 11 Feb 2012 12:45:35 +0000 (12:45 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 11 Feb 2012 12:45:35 +0000 (12:45 +0000)
configure.ac
include/netxms_getopt.h
include/nms_common.h
include/nms_util.h
src/agent/core/extagent.cpp
src/agent/subagents/aix/proc.cpp
src/libnetxms/Makefile.am
src/libnetxms/getopt.c
src/tools/nxdevcfg/nxdevcfg.cpp

index bbb5e4d..adafe2c 100644 (file)
@@ -64,6 +64,7 @@ FORCE_INTERNAL_LIBTRE="no"
 USE_INTERNAL_ZLIB="no"
 FORCE_INTERNAL_ZLIB="no"
 FORCE_32BIT_BUILD="no"
+FORCE_INTERNAL_GETOPT="no"
 LDFLAGS_PREFIX=""
 LDFLAGS_SUFFIX=""
 LTINIT_CC=""
@@ -147,6 +148,12 @@ AC_ARG_WITH(internal-zlib,
        FORCE_INTERNAL_ZLIB="yes"
 ])
 
+AC_ARG_WITH(internal-getopt,
+[AS_HELP_STRING(--with-internal-getopt,force use of bundled getopt)],
+[
+       FORCE_INTERNAL_GETOPT="yes"
+])
+
 AC_ARG_WITH(sqlite,
 [AS_HELP_STRING(--with-sqlite,build SQLite database driver)],
 [ if test "x$withval" != "xno" ; then
@@ -531,7 +538,10 @@ fi
 if test "x$PLATFORM" = "xHP-UX"; then
        AC_CHECK_PROG([CCC], [aCC], [aCC])
 fi
-AC_PROG_CC(aCC gcc cc cl)
+if test "x$PLATFORM" = "xAIX"; then
+       AC_CHECK_PROG([CCC], [xlC_r], [xlC_r])
+fi
+AC_PROG_CC(aCC xlC_r gcc cc cl)
 AC_PROG_CPP
 AC_PROG_CXX
 if test "x$CXX" = "xg++"; then
@@ -732,7 +742,7 @@ if test "x$CXX" = "xaCC" ; then
        fi
 fi
 
-if test "x$CXX" = "xxlC" ; then
+if test "x$CXX" = "xxlC_r" ; then
         if test "x$FORCE_32BIT_BUILD" = "xyes"; then
                 AC_MSG_CHECKING(whether C compiler accepts -q32)
                 OLD_CPPFLAGS="$CPPFLAGS"
@@ -740,6 +750,7 @@ if test "x$CXX" = "xxlC" ; then
                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
                         [
                                 LDFLAGS="-q32 $LDFLAGS"
+                               OBJECT_MODE=32
                                 AC_MSG_RESULT(yes)
                         ],
                         [
@@ -753,6 +764,7 @@ if test "x$CXX" = "xxlC" ; then
                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
                         [
                                 LDFLAGS="-q64 $LDFLAGS"
+                               OBJECT_MODE=64
                                 AC_MSG_RESULT(yes)
                         ],
                         [
@@ -958,7 +970,7 @@ AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h net/nh.h sys/socket.h])
 AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h poll.h termios.h])
 AC_CHECK_HEADERS([inttypes.h memory.h stdint.h stdlib.h strings.h string.h])
 AC_CHECK_HEADERS([readline/readline.h byteswap.h sys/select.h dlfcn.h])
-AC_CHECK_HEADERS([sys/sysctl.h sys/param.h sys/user.h vm/vm_param.h syslog.h getopt.h])
+AC_CHECK_HEADERS([sys/sysctl.h sys/param.h sys/user.h vm/vm_param.h syslog.h])
 AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h],,,
 [[#ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
@@ -980,7 +992,6 @@ AC_CHECK_LIB(xnet, accept)
 AC_CHECK_LIB(socket, if_nameindex)
 AC_CHECK_LIB(dl, dlopen)
 AC_CHECK_LIB(kstat, kstat_open)
-AC_CHECK_LIB(gnugetopt, getopt_long)
 
 if test "x$BUILD_SERVER" = "xyes" ; then
    AC_CHECK_LIB(termcap, tgetstr, [], [AC_CHECK_LIB(ncurses, tgetstr, [], AC_CHECK_LIB(curses, tgetstr))])
@@ -1117,7 +1128,7 @@ AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([gettimeofday memmove memset bcopy strchr strcspn strdup strerror])
 AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
 AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname poll])
-AC_CHECK_FUNCS([usleep nanosleep getopt_long gmtime_r localtime_r lstat64])
+AC_CHECK_FUNCS([usleep nanosleep gmtime_r localtime_r lstat64])
 
 AC_CHECK_DECLS([nanosleep])
 
@@ -1195,12 +1206,6 @@ AC_DEFINE(HAVE_TM_GMTOFF,1,Define to 1 if struct tm has tm_gmtoff member)
 AC_MSG_RESULT(no)
 ])
 
-AC_CHECK_DECLS([getopt_long],,,[
-#if HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-])
-
 AC_CHECK_FUNCS([sysctlbyname sysctlnametomib])
 AC_CHECK_FUNCS([tcgetattr tcsetattr cfsetospeed cfsetispeed])
 
@@ -1287,12 +1292,33 @@ AC_CHECK_DECLS([va_copy, __va_copy],,,[
 
 
 #--------------------------------------------------------------------
+# getopt
+#--------------------------------------------------------------------
+
+if test "x$FORCE_INTERNAL_GETOPT" = "xyes"; then
+       AC_DEFINE([USE_BUNDLED_GETOPT], [1], [Define to 1 if bundled getopt must be used])
+else
+       AC_CHECK_HEADERS([getopt.h])
+       AC_CHECK_LIB(gnugetopt, getopt_long)
+       AC_CHECK_DECLS([getopt_long],,,[
+#if HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+       ])
+fi
+
+
+#--------------------------------------------------------------------
 # AIX specific checks
 #--------------------------------------------------------------------
 
 if test "x$PLATFORM" = "xAIX"; then
        AC_CHECK_HEADERS([procinfo.h],,,[[ ]])
-       AC_CHECK_DECLS([getkerninfo])
+       AC_CHECK_DECLS([getkerninfo, getprocs, getprocs64],,,[
+#if HAVE_PROCINFO_H
+#include <procinfo.h>
+#endif
+       ])
        AC_CHECK_FUNCS([getprocs64],,,[
 #if HAVE_PROCINFO_H
 #include <procinfo.h>
index 90b801c..c0dbc52 100644 (file)
 #ifndef _GETOPT_H
 #define _GETOPT_H 1
 
+#undef HAVE_GETOPT_LONG
+#define HAVE_GETOPT_LONG 1
+
+#undef HAVE_DECL_GETOPT_LONG
+#define HAVE_DECL_GETOPT_LONG 1
+
 #ifdef _WIN32
 #ifdef LIBNETXMS_EXPORTS
 #define GETOPT_EXPORTABLE __declspec(dllexport)
index 114e58e..7020275 100644 (file)
@@ -155,6 +155,7 @@ typedef int bool;
 #define WITH_IPV6               1
 
 #define USE_BUNDLED_LIBTRE      1
+#define USE_BUNDLED_GETOPT      1
 
 #define FS_PATH_SEPARATOR       _T("\\")
 #define FS_PATH_SEPARATOR_CHAR  _T('\\')
index 8f46266..3cde65e 100644 (file)
@@ -505,7 +505,7 @@ typedef struct  __CODE_TO_TEXT
 // getopt() prototype if needed
 //
 
-#ifdef _WIN32
+#if USE_BUNDLED_GETOPT
 #include <netxms_getopt.h>
 #endif
 
index 8e7ffb8..6b50f79 100644 (file)
@@ -389,6 +389,7 @@ cleanup:
 
 static THREAD_RESULT THREAD_CALL ExternalSubagentConnector(void *arg)
 {
+       return THREAD_OK;
 }
 
 #endif
index f04361b..401a82d 100644 (file)
 #if HAVE_GETPROCS64
 typedef struct procentry64 PROCENTRY;
 #define GETPROCS getprocs64
+#if !HAVE_DECL_GETPROCS64
 extern "C" int getprocs64(struct procentry64 *, int, struct fdsinfo64 *, int, pid_t *, int);
+#endif
 #else
 typedef struct procsinfo PROCENTRY;
 #define GETPROCS getprocs
+#if !HAVE_DECL_GETPROCS
 extern "C" int getprocs(struct procsinfo *, int, struct fdsinfo *, int, pid_t *, int);
 #endif
+#endif
 
 
 //
index 6f47426..62a6149 100644 (file)
@@ -3,7 +3,7 @@ if USE_INTERNAL_EXPAT
 INCLUDES += -I@top_srcdir@/src/libexpat/libexpat
 endif
 SOURCES = agent.cpp array.cpp base64.cpp config.cpp crypto.cpp gen_uuid.c \
-         geolocation.cpp dload.cpp hash.cpp ice.c icmp.cpp \
+         geolocation.cpp getopt.c dload.cpp hash.cpp ice.c icmp.cpp \
          log.cpp main.cpp md5.cpp message.cpp msgwq.cpp net.cpp \
          nxcp.cpp qsort.c queue.cpp rwlock.cpp scandir.c serial.cpp \
          sha1.cpp string.cpp stringlist.cpp strmap.cpp strtoll.c strtoull.c \
@@ -25,5 +25,5 @@ endif
 EXTRA_DIST = \
        libnetxms.vcproj libnetxmsw.vcproj \
        libnetxms.h ice.h md5.h sha1.h uuidP.h \
-       dir.c dirw.c getopt.c \
+       dir.c dirw.c \
        seh.cpp StackWalker.cpp StackWalker.h
index 1a1382b..15c2362 100644 (file)
@@ -21,7 +21,9 @@
    Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
 */
 
-#ifdef _WIN32
+#include <config.h>
+
+#if USE_BUNDLED_GETOPT
 
 #ifndef __STDC__
 #  ifndef const
index e30b426..d3fedc6 100644 (file)
@@ -21,7 +21,7 @@
 **
 **/
 
-#include <nms_common.h>
+#include <nms_util.h>
 
 #if HAVE_GETOPT_H
 #include <getopt.h>