Commit | Line | Data |
---|---|---|
61ec970d | 1 | #! /bin/sh |
61ec970d PH |
2 | |
3 | # Build the config.h file, using the buildconfig program, first ensuring that | |
4 | # it exists. | |
5 | ||
6 | # 22-May-1996: remove the use of the "-a" flag for /bin/sh because it is not | |
7 | # implemented in the FreeBSD shell. Sigh. | |
8 | ||
9 | # 12-Mar-1997: add s/#.*$// to the sed script to allow for comments on the | |
10 | # ends of settings - someone got caught. | |
11 | ||
12 | # 18-Apr-1997: put the tab character into a variable to stop it getting | |
13 | # lost by accident (which has happened a couple of times). | |
14 | ||
15 | # 19-Jan-1998: indented settings in the makefile weren't being handled | |
16 | # correctly; added [$st]* before \\([A-Z] in the pattern, to ignore leading | |
17 | # space. Oddly, the pattern previously read ^\([A-Z which didn't seem to | |
18 | # cause a problem (but did when the new bit was put in). | |
19 | ||
9176e9f0 PH |
20 | # 04-May-2005: if $1 is set, copy it into $MAKE, and then use $MAKE, if set, |
21 | # instead of "make" so that if gmake is used, it is used consistently. | |
22 | ||
23 | if [ "$1" != "" ] ; then MAKE=$1 ; fi | |
24 | if [ "$MAKE" = "" ] ; then MAKE=make ; fi | |
25 | ||
26 | $MAKE buildconfig || exit 1 | |
61ec970d PH |
27 | |
28 | # BEWARE: tab characters needed in the following sed command. They have had | |
29 | # a nasty tendency to get lost in the past, causing a problem if a tab has | |
30 | # actually been present in makefile. Use a variable to hold a space and a | |
31 | # tab to keep the tab in one place. This makes the sed option horrendous to | |
32 | # read, but the whole script is safer. | |
33 | ||
34 | st=' ' | |
35 | ||
36 | (sed -n \ | |
dde3daac | 37 | "/\\\$/d;s/#.*\$//;s/^[$st]*\\([A-Z][^:!+$st]*\\)[$st]*=[$st]*\\([^$st]*\\)[$st]*\$/\\1=\\2 export \\1/p" \ |
61ec970d PH |
38 | < Makefile ; echo "./buildconfig") | /bin/sh |
39 | ||
40 | # If buildconfig ends with an error code, it will have output an error | |
41 | # message. Ensure that a broken config.h gets deleted. | |
42 | ||
43 | if [ $? != 0 ] ; then | |
44 | rm -f config.h | |
45 | exit 1 | |
46 | fi | |
47 | ||
48 | # Double-check that config.h is complete. | |
49 | ||
50 | if [ "`tail -1 config.h`" != "/* End of config.h */" ] ; then | |
51 | echo "*** config.h appears to be incomplete" | |
52 | echo "*** unexpected failure in buildconfig program" | |
53 | exit 1 | |
54 | fi | |
55 | ||
56 | echo ">>> config.h built" | |
57 | echo "" | |
58 | ||
dde3daac | 59 | # vim: set ft=sh : |
61ec970d | 60 | # End of Configure-config.h |