forked from wxWidgets/Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbk-make-pch
executable file
·64 lines (58 loc) · 1.67 KB
/
bk-make-pch
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
#!/bin/sh
# This script is part of Bakefile (http://www.bakefile.org) autoconf
# script. It is used to generated precompiled headers.
#
# Permission is given to use this file in any way.
outfile="${1}"
header="${2}"
shift
shift
builddir=`echo $outfile | sed -e 's,/\.pch/.*$,,g'`
compiler=""
headerfile=""
while test ${#} -gt 0; do
add_to_cmdline=1
case "${1}" in
-I* )
incdir=`echo ${1} | sed -e 's/-I\(.*\)/\1/g'`
if test "x${headerfile}" = "x" -a -f "${incdir}/${header}" ; then
headerfile="${incdir}/${header}"
fi
;;
-use-pch|-use_pch|-pch-use )
shift
add_to_cmdline=0
;;
esac
if test $add_to_cmdline = 1 ; then
compiler="${compiler} ${1}"
fi
shift
done
if test "x${headerfile}" = "x" ; then
echo "error: can't find header ${header} in include paths" >&2
else
if test -f ${outfile} ; then
rm -f ${outfile}
else
mkdir -p `dirname ${outfile}`
fi
depsfile="${builddir}/.deps/`echo ${outfile} | tr '/.' '__'`.d"
mkdir -p ${builddir}/.deps
if test "x1" = "x1" ; then
# can do this because gcc is >= 3.4:
${compiler} -o ${outfile} -MMD -MF "${depsfile}" "${headerfile}"
elif test "x0" = "x1" ; then
filename=pch_gen-$$
file=${filename}.c
dfile=${filename}.d
cat > $file <<EOT
#include "$header"
EOT
# using -MF icc complains about differing command lines in creation/use
$compiler -c $outfile -MMD $file && \
sed -e "s,^.*:,$outfile:," -e "s, $file,," < $dfile > $depsfile && \
rm -f $file $dfile ${filename}.o
fi
exit ${?}
fi