summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac5
-rw-r--r--xrdb.c16
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
diff --git a/xrdb.c b/xrdb.c
index 3e01629..f6b4f05 100644
--- a/xrdb.c
+++ b/xrdb.c
@@ -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 */