blob: 0fb55849226397f2b0766abea95674492deb2de1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/sh
##
## findcpp.sh -- Find out how to _directly_ run the C Pre-Processor (CPP)
## Initially written by Ralf S. Engelschall for the Apache configuration
## mechanism
##
#
# This script falls under the Apache License.
# See http://www.apache.org/docs/LICENSE
# create a test C source:
# - has to use extension ".c" because some CPP only accept this one
# - uses assert.h because this is a standard header and harmless to include
# - contains a Syntax Error to make sure it passes only the preprocessor
# but not the real compiler pass
cat >conftest.c <<EOF
#include <assert.h>
Syntax Error
EOF
# some braindead systems have a CPP define for a directory :-(
if [ "x$CPP" != "x" ]; then
if [ -d "$CPP" ]; then
CPP=''
fi
fi
if [ "x$CPP" != "x" ]; then
# case 1: user provided a default CPP variable (we only check)
(eval "$CPP conftest.c >/dev/null") 2>conftest.out
my_error=`grep -v '^ *+' conftest.out`
if [ "x$my_error" != "x" ]; then
CPP=''
fi
else
# case 2: no default CPP variable (we have to find one)
# 1. try the standard -E option
CPP="${CC-cc} -E"
(eval "$CPP conftest.c >/dev/null") 2>conftest.out
my_error=`grep -v '^ *+' conftest.out`
if [ "x$my_error" != "x" ]; then
# 2. try the -E option and GCC's -traditional-ccp option
CPP="${CC-cc} -E -traditional-cpp"
(eval "$CPP conftest.c >/dev/null") 2>conftest.out
my_error=`grep -v '^ *+' conftest.out`
if [ "x$my_error" != "x" ]; then
# 3. try a standalone cpp command in $PATH and lib dirs
CPP="`sh helpers/PrintPath cpp`"
if [ "x$CPP" = "x" ]; then
CPP="`sh helpers/PrintPath -p/lib:/usr/lib:/usr/local/lib cpp`"
fi
if [ "x$CPP" != "x" ]; then
(eval "$CPP conftest.c >/dev/null") 2>conftest.out
my_error=`grep -v '^ *+' conftest.out`
if [ "x$my_error" != "x" ]; then
# ok, we gave up...
CPP=''
fi
fi
fi
fi
fi
# cleanup after work
rm -f conftest.*
# Ok, empty CPP variable now means it's not available
if [ "x$CPP" = "x" ]; then
CPP='NOT-AVAILABLE'
fi
echo $CPP
|