summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Seplowitz <mseplowitz@bloomberg.net>2015-01-12 20:53:14 -0500
committerMike Seplowitz <mseplowitz@bloomberg.net>2015-08-19 08:43:59 -0400
commitcdab57de00ab7ce157f1fdd601ce242588fcadce (patch)
treee22fc97286d2766c596108f13ba49d27a30f8c37
parent94c10a6a18ceadf78d27245ce389610c67a7cf2e (diff)
downloadninja-cdab57de00ab7ce157f1fdd601ce242588fcadce.tar.gz
Fix getopt for AIX
AIX supplies getopt but not getopt_long. We can't use the embedded getopt implementation, since the constness of its arguments doesn't match the AIX system routine.
-rwxr-xr-xconfigure.py2
-rw-r--r--src/getopt.c2
-rw-r--r--src/getopt.h2
-rw-r--r--src/ninja.cc3
-rw-r--r--src/ninja_test.cc3
5 files changed, 12 insertions, 0 deletions
diff --git a/configure.py b/configure.py
index fcea72a..611030f 100755
--- a/configure.py
+++ b/configure.py
@@ -494,6 +494,8 @@ if platform.is_windows():
objs += cc('getopt')
else:
objs += cxx('subprocess-posix')
+if platform.is_aix():
+ objs += cc('getopt')
if platform.is_msvc():
ninja_lib = n.build(built('ninja.lib'), 'ar', objs)
else:
diff --git a/src/getopt.c b/src/getopt.c
index 3350fb9..0c2ef35 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -385,11 +385,13 @@ getopt_internal (int argc, char **argv, char *shortopts,
return optopt;
}
+#ifndef _AIX
int
getopt (int argc, char **argv, char *optstring)
{
return getopt_internal (argc, argv, optstring, NULL, NULL, 0);
}
+#endif
int
getopt_long (int argc, char **argv, const char *shortopts,
diff --git a/src/getopt.h b/src/getopt.h
index b4247fb..965dc29 100644
--- a/src/getopt.h
+++ b/src/getopt.h
@@ -39,7 +39,9 @@ extern "C"
extern int optopt;
/* function prototypes */
+#ifndef _AIX
int getopt (int argc, char **argv, char *optstring);
+#endif
int getopt_long (int argc, char **argv, const char *shortopts,
const GETOPT_LONG_OPTION_T * longopts, int *longind);
int getopt_long_only (int argc, char **argv, const char *shortopts,
diff --git a/src/ninja.cc b/src/ninja.cc
index a3d963f..f71f6dc 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -22,6 +22,9 @@
#include "getopt.h"
#include <direct.h>
#include <windows.h>
+#elif defined(_AIX)
+#include "getopt.h"
+#include <unistd.h>
#else
#include <getopt.h>
#include <unistd.h>
diff --git a/src/ninja_test.cc b/src/ninja_test.cc
index 54d8784..11087b6 100644
--- a/src/ninja_test.cc
+++ b/src/ninja_test.cc
@@ -17,6 +17,9 @@
#ifdef _WIN32
#include "getopt.h"
+#elif defined(_AIX)
+#include "getopt.h"
+#include <unistd.h>
#else
#include <getopt.h>
#endif