diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2008-10-20 14:33:23 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2008-10-20 14:33:23 -0700 |
commit | fc0b73673a7b91b386d8a346652f9cc0c4a68d44 (patch) | |
tree | 5723b174c07b185b92ad4d16fd0500959358b566 | |
parent | 0de4f54967a7ab923817712eb96b64ca1ebe84a5 (diff) |
Allow specifying multiple paths to --with-cpp and running if none is found
Merge of code from the old Solaris xrdb that allows having cpp found at
compile time, but not erroring out if it's not found at runtime, and
if necessary, checking for it in multiple locations.
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | xrdb.c | 16 |
2 files changed, 18 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 77d56ec..6348b55 100644 --- a/configure.ac +++ b/configure.ac @@ -66,12 +66,13 @@ fi # in Imake config files for each OS AC_ARG_WITH([cpp], AC_HELP_STRING([--with-cpp=path], - [path to cpp command for xrdb to use at runtime]), + [comma-separated list of paths to cpp command for xrdb to use at runtime]), [AC_MSG_CHECKING(for cpp) CPP_PATH=$withval - AC_MSG_RESULT($CPP_PATH)], + AC_MSG_RESULT(--with-cpp specified $CPP_PATH)], [AC_PATH_PROG([CPP_PATH],[cpp], [cpp], [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])]) +CPP_PATH=`echo ${CPP_PATH} | sed 's/,/\\",\\"/g'` AC_DEFINE_UNQUOTED([CPP], "$CPP_PATH", [Path to CPP program]) # Checks for pkg-config packages @@ -129,7 +129,8 @@ char tmpname3[32]; #endif int oper = OPLOAD; char *editFile = NULL; -char *cpp_program = CPP; +const char *cpp_program = NULL; +static const char* const cpp_locations[] = { CPP }; char *backup_suffix = BACKUP_SUFFIX; Bool dont_execute = False; String defines; @@ -877,6 +878,19 @@ main(int argc, char *argv[]) filename = arg; } /* end for */ + /* If cpp to use was not specified, check for ones in default locations */ + if (cpp_program == NULL) { + int number_of_elements + = (sizeof cpp_locations) / (sizeof cpp_locations[0]); + int j; + + for (j = 0; j < number_of_elements; j++) { + if (access(cpp_locations[j], X_OK) == 0) { + cpp_program = cpp_locations[j]; + break; + } + } + } #ifndef WIN32 while ((i = open("/dev/null", O_RDONLY)) < 3) ; /* make sure later freopen won't clobber things */ |