forked from varnishcache/varnish-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.phk
249 lines (210 loc) · 5.01 KB
/
config.phk
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/bin/sh
set -e
#######################################################################
# Adminstrative settings
ADM_PROJECT=varnish
ADM_VERSION=trunk
CONFIG_H=phk_hack/config.h
#######################################################################
# We always rebuild the config when make is run in the toplevel directory
# Otherwise, we try to use a cached config, if we have one.
#
# We know we're in the toplevel directory, because we get passed
# TOPDIR and CURDIR as arguments
if [ "x$1" = "x" -o "x$2" = "x" ] ; then
echo "Missing arguments, assuming topdir" 1>&2
set `pwd` `pwd`
fi
if [ "x$1" = "x$2" ] ; then
rm -f _.cache
elif [ "x$1" != "x" -a -d $1 ] ; then
cd $1
fi
#######################################################################
# autocrap co-existence
# We put our config.h somewhere else and delete autocraps.
# Autocrap regenerates its own config.h and doesn't know about ours
mkdir -p phk_hack
rm -f config.h
#######################################################################
if [ -f _.cache -a -f ${CONFIG_H} ] ; then
cat _.cache
exit 0
fi
echo "Building Config" 1>&2
#######################################################################
# Look for #include files for HAVE_ etc.
if true ; then
rm -f ${CONFIG_H}_
echo '' > ${CONFIG_H}_
for i in \
curses.h \
endian.h \
execinfo.h \
ncurses.h \
ncurses/curses.h \
ncursesw.h \
ncursesw/curses.h \
priv.h \
pthread_np.h \
readline/history.h \
readline/readline.h \
sys/endian.h \
sys/filio.h \
sys/mount.h \
sys/statvfs.h \
sys/vfs.h \
umem.h
do
if [ -f /usr/include/$i ] ; then
n=`echo $i | tr '[a-z/.]' '[A-Z__]'`
echo "#define HAVE_$n 1" >> ${CONFIG_H}_
fi
done
echo "#define PACKAGE_TARNAME \"${ADM_PROJECT}\"" >> ${CONFIG_H}_
echo "#define PACKAGE_VERSION \"${ADM_VERSION}\"" >> ${CONFIG_H}_
echo '
#define VARNISH_STATE_DIR "/tmp/phk/"
' >> ${CONFIG_H}_
if [ ! -f ${CONFIG_H} ] ; then
mv ${CONFIG_H}_ ${CONFIG_H}
elif ! cmp -s ${CONFIG_H} ${CONFIG_H}_ ; then
mv ${CONFIG_H}_ ${CONFIG_H}
else
rm -f ${CONFIG_H}_
fi
fi
#######################################################################
# Create files depending on VCS (git) output
VCSF=include/vcs_version.h
VMAV=include/vmod_abi.h
if [ -d ./.git ] ; then
V=`git show -s --pretty=format:%h`
else
V="NOGIT"
fi
(
echo "/* $V */"
echo "/*"
echo " * NB: This file is machine generated, DO NOT EDIT!"
echo " *"
echo " * make(1) updates this when necessary"
echo " *"
echo " */"
echo "#define VCS_Version \"$V\""
) > ${VCSF}_
if [ ! -f ${VCSF} ] ; then
mv ${VCSF}_ ${VCSF}
rm -f ${VMAV}
elif ! cmp -s ${VCSF}_ ${VCSF} ; then
mv ${VCSF}_ ${VCSF}
rm -f ${VMAV}
else
rm ${VCSF}_
fi
if [ ! -f ${VMAV} ] ; then
echo "#define VMOD_ABI_Version \"Varnish trunk $V\"" > ${VMAV}
fi
#######################################################################
# Ask the compiler about stuff
ask_compiler() {
a=`echo "$2" |
${CC-cc} -E - -DWARNS=${WARNS-1} |
sed -e '/^#/d' -e '/^$/d' -e 's/"//g' -e 's/~/"/g' `
echo "$1='" $a "'" >> _.cache
}
# Warning flags
ask_compiler CF_CWFLAGS '
#if WARNS >= 1
"-Wall"
"-Werror"
#endif
#if WARNS >= 2
"-W"
"-fstack-protector"
"-Wno-format-y2k"
"-Wno-unused-parameter"
"-Wstrict-prototypes"
"-Wmissing-prototypes"
"-Wpointer-arith"
"-Wreturn-type"
"-Wcast-qual"
"-Wwrite-strings"
"-Wswitch"
"-Wshadow"
"-Wunused-parameter"
"-Wcast-align"
"-Wchar-subscripts"
"-Winline"
"-Wnested-externs"
"-Wno-pointer-sign"
"-Wno-empty-body"
"-Wextra"
"-Wno-missing-field-initializers"
"-Wno-sign-compare"
#if defined(__clang__)
"-Wmissing-variable-declarations"
"-Wno-string-plus-int"
#endif
#endif
'
# Configuration options
ask_compiler CF_CFLAGS '
#if defined(__SVR4) && defined(sun)
// Solaris and OmniOS
"-DHAVE_GETHRTIME"
"-DHAVE_PORT_CREATE"
"-DHAVE_SETPPRIV"
#endif
#if !defined(__APPLE__)
"-DHAVE_DAEMON"
#endif
// Where does this not work ?
"-DSO_SNDTIMEO_WORKS"
"-DSO_RCVTIMEO_WORKS"
"-DHAVE_TCP_KEEP"
"-DVCC_CC=~\~exec $(CC) -D_THREAD_SAFE -std=gnu99 -g -O2 -Wall -Werror -pthread -fpic -shared -Wl,-x -o %o %s\~~"
"-DVCC_WARNS=~\~$(CF_CWFLAGS)\~~"
"-I$(TOPDIR)/phk_hack"
'
#######################################################################
# Find a Python interpreter
#
for i in 3.2 2.7 "" 2.5 2.6 3.0 3.1
do
if python$i < /dev/null > /dev/null 2>&1 ; then
echo PYTHON=python$i >> _.cache
break
fi
done
#######################################################################
# Find a rst2* tools
#
if echo | rst2html > /dev/null 2>&1 ; then
echo "HAVE_RST2HTML=1" >> _.cache
fi
cat _.cache
exit 0
# HAVE_ACCEPT_FILTERS +
# HAVE_BACKTRACE +
# HAVE_CLOCK_GETTIME +
# HAVE_DAEMON +
# HAVE_DLADDR +
# HAVE_KQUEUE +
# HAVE_NANOSLEEP +
# HAVE_PTHREAD_SET_NAME_NP +
# HAVE_SETPROCTITLE +
# HAVE_SRANDOMDEV +
# HAVE_TCP_KEEP +
# HAVE_TIMEGM +
# PACKAGE_TARNAME +
# PACKAGE_VERSION +
# SO_RCVTIMEO_WORKS +
# SO_SNDTIMEO_WORKS +
# VCC_CC +
# HAVE_EPOLL_CTL -
# HAVE_LIBUMEM -
# USE_PCRE_JIT -
# _FILE_OFFSET_BITS -
#
# #echo 'CF_CFLAGS="-Wall"'