-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure
executable file
·432 lines (411 loc) · 11.9 KB
/
configure
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
#!/bin/sh
trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
prefix="${prefix-/usr/local}"
exec_prefix="${exec_prefix-\$(prefix)}"
bindir="${bindir-\$(exec_prefix)/bin}"
mandir="${mandir-\$(prefix)/man}"
man1dir="${man1dir-\$(mandir)/man1}"
cc="${CC-gcc}"
#cc="${CC-clang}"
#cc="${CC-cc}"
cflags="$CFLAGS"
enable_debug=0
with_system_libpng=0
with_system_zlib=0
with_preconfigured_libpng=1
with_preconfigured_zlib=0
unique_file=src/optipng/optipng.c
for arg in "$@"
do
case "$arg" in
-- )
option="$arg"
;;
--* )
option=`expr "X$arg" : 'X-\(.*\)'`
;;
* )
option="$arg"
;;
esac
case "$arg" in
*=* )
optarg=`expr "X$arg" : 'X[^=]*=\(.*\)'`
;;
* )
optarg=""
;;
esac
case "$option" in
-help | -hel | -he | -h )
echo "Usage:"
echo " $0 [options]"
echo "Options:"
echo " -h, -help Show this help"
echo "Installation directories:"
echo " -prefix=PREFIX Install architecture-independent files in PREFIX"
echo " [default: $prefix]"
echo " -exec-prefix=EPREFIX Install architecture-dependent files in EPREFIX"
echo " [default: PREFIX]"
echo " -bindir=DIR Install executable in DIR [default: EPREFIX/bin]"
echo " -mandir=DIR Install manual in DIR [default: PREFIX/man]"
echo "Optional features:"
echo " -enable-debug Enable debug build flags and run-time checks"
echo "Optional packages:"
echo " -with-system-libs Use all system-supplied libraries (details below)"
echo " -with-system-libpng Use the system-supplied libpng"
echo " [default: false]"
echo " -with-system-zlib Use the system-supplied zlib"
echo " [default: with-system-libpng]"
echo "Environment variables:"
echo " CC C compiler command"
echo " LD Linker command"
echo " AR Library archiver command"
echo " RANLIB Library indexer/randomizer command"
echo " CFLAGS C compiler flags (e.g. -O3)"
echo " CPPFLAGS C preprocessor flags (e.g. -I DIR)"
echo " LDFLAGS Linker flags (e.g. -L DIR)"
echo " ARFLAGS Library archiver flags (e.g. rcu)"
echo " LIBS Additional libraries (e.g. -lfoo)"
exit 0
;;
-prefix | -prefi | -pref | -pre | -pr | -p )
prefix="$2"
shift
;;
-prefix=* | -prefi=* | -pref=* | -pre=* | -pr=* | -p=* )
prefix="$optarg"
;;
-exec-prefix | -exec_prefix | -exec-prefi | -exec_prefi \
| -exec-pref | -exec_pref | -exec-pre | -exec_pre \
| -exec-pr | -exec_pr | -exec-p | -exec_p | exec- | -exec_ \
| -exec | -exe | -ex | -e )
exec_prefix="$2"
shift
;;
-exec-prefix=* | -exec_prefix=* | -exec-prefi=* | -exec_prefi=* \
| -exec-pref=* | -exec_pref=* | -exec-pre=* | -exec_pre=* \
| -exec-pr=* | -exec_pr=* | -exec-p=* | -exec_p=* | exec-=* | -exec_=* \
| -exec=* | -exe=* | -ex=* | -e=* )
exec_prefix="$optarg"
;;
-bindir | -bindi | -bind | -bin | -bi | -b )
bindir="$2"
shift
;;
-bindir=* | -bindi=* | -bind=* | -bin=* | -bi=* | -b=* )
bindir="$optarg"
;;
-mandir | -mandi | -mand | -man | -ma | -m )
mandir="$2"
shift
;;
-mandir=* | -mandi=* | -mand=* | -man=* | -ma=* | -m=* )
mandir="$optarg"
;;
-enable-debug )
enable_debug=1
;;
-disable-debug )
enable_debug=0
;;
-with-system-libs )
with_system_libpng=1
with_system_zlib=1
;;
-without-system-libs )
with_system_zlib=0
with_system_libpng=0
;;
-with-system-libpng )
with_system_libpng=1
# Must use the system-supplied zlib with the system-supplied libpng.
with_system_zlib=1
;;
-without-system-libpng )
with_system_libpng=0
;;
-with-system-zlib )
with_system_zlib=1
;;
-without-system-zlib )
with_system_zlib=0
# Can't use the system-supplied libpng without the system-supplied zlib.
with_system_libpng=0
;;
* )
echo "$0: error: unknown option: $arg"
echo "Type \"$0 -help\" for help"
exit 64 # EX_USAGE
;;
esac
done
if test ! -f "$0"
then
echo "$0: error: cannot find myself; rerun with an absolute file name"
exit 1
fi
if test ! -r "$unique_file"
then
echo "$0: error: cannot find: $unique_file"
echo "$0: note: building outside the source directory tree is not supported"
exit 1
fi
test=conftest$$
cat > $test.c <<EOM
int hello() { return 42; }
EOM
gccish=0
case "$cc" in
*gcc* | *clang* )
echo "Checking for $cc..."
if ($cc -c $cflags $test.c) 2>/dev/null
then
gccish=1
fi
;;
esac
rm -f $test.c $test.o
if test "$gccish" -ne 0
then
CC="${CC-$cc}"
CFLAGS="${CFLAGS--O2 -Wall -Wextra}"
else
CC="${CC-cc}"
CFLAGS="${CFLAGS--O}"
fi
if test "$enable_debug" -ne 0
then
CPPFLAGS="$CPPFLAGS -DDEBUG -D_DEBUG"
CFLAGS="$CFLAGS -g"
LDFLAGS="$LDFLAGS -g"
fi
if test "$with_system_libpng" -eq 0
then
USE_SYSTEM_LIBPNG_TRUE="#"
USE_SYSTEM_LIBPNG_FALSE=""
if test "$with_preconfigured_libpng" -ne 0
then
echo "Using pre-configured libpng..."
libpng_makefile=scripts/makefile.gcc
if test ! -f src/libpng/$libpng_makefile
then
echo "$0: warning: cannot find: src/libpng/$libpng_makefile"
with_preconfigured_libpng=0
fi
fi
if test "$with_preconfigured_libpng" -ne 0
then
sed_preconfig_libpng=""
if test "$CC"
then
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^CC *=.*|CC = $CC|
"
fi
if test "$CFLAGS"
then
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^CFLAGS *=.*|CFLAGS = $CFLAGS|
"
fi
if test "$CPPFLAGS"
then
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^CPPFLAGS *=.*|CPPFLAGS = $CPPFLAGS|
"
fi
if test "$LD"
then
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^LD *=.*|LD = $LD|
"
fi
if test "$LDFLAGS"
then
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^LDFLAGS *=.*|LDFLAGS = $LDFLAGS|
"
fi
if test "$AR$ARFLAGS"
then
AR="${AR-ar}"
ARFLAGS="${ARFLAGS-cru}"
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^AR *=.*|AR = $AR|
s|^ARFLAGS *=.*|ARFLAGS = $ARFLAGS|
s|^AR_\([A-Z]*\) *=.*|AR_\1 = $AR $ARFLAGS|
"
fi
if test "$RANLIB"
then
sed_preconfig_libpng="
$sed_preconfig_libpng
s|^RANLIB *=.*|RANLIB = $RANLIB|
"
fi
sed "$sed_preconfig_libpng" \
src/libpng/$libpng_makefile > src/libpng/Makefile
LIBPNG_MK=Makefile
# The pre-configured makefiles in libpng don't do distclean.
LIBPNG_DISTCLEAN="clean"
LIBPNG_DISTCLEAN_XCMD="\$(RM_F) \$(LIBPNG_MK)"
else
echo "Configuring libpng..."
(cd src/libpng && ./configure)
if test $? -ne 0
then
echo "$0: error: could not configure: libpng"
exit 1
fi
fi
else
USE_SYSTEM_LIBPNG_TRUE=""
USE_SYSTEM_LIBPNG_FALSE="#"
echo "Checking for system libpng..."
test=conftest$$
cat > $test.c <<EOM
#include <png.h>
#if PNG_LIBPNG_VER < 10209
#error This program requires libpng version 1.2.9 or higher
#endif
int dummy;
EOM
($CC -c $CPPFLAGS $CFLAGS $test.c) 2>/dev/null
status=$?
rm -f $test.c $test.o
if test $status -ne 0
then
echo "$0: error: missing libpng or incorrect libpng version"
echo "$0: note: libpng version 1.2.9 or higher is required"
exit 1
fi
fi
ZLIB_MK=Makefile
ZLIB_DISTCLEAN=distclean
if test "$with_system_zlib" -ne 0
then
USE_SYSTEM_ZLIB_TRUE=""
USE_SYSTEM_ZLIB_FALSE="#"
else
USE_SYSTEM_ZLIB_TRUE="#"
USE_SYSTEM_ZLIB_FALSE=""
case `(uname -s) 2>/dev/null || echo unknown` in
mingw* | MINGW* | windows* | WINDOWS* )
with_preconfigured_zlib=1
ZLIB_MK=win32/Makefile.gcc
ZLIB_DISTCLEAN=clean
;;
esac
fi
if test "$with_system_zlib" -eq 0
then
USE_SYSTEM_ZLIB_TRUE="#"
USE_SYSTEM_ZLIB_FALSE=""
case `(uname -s) 2>/dev/null || echo unknown` in
mingw* | MINGW* | windows* | WINDOWS* )
# zlib configure is known to fail on MinGW.
zlib_makefile=win32/Makefile.gcc
if test -f src/zlib/$zlib_makefile
then
with_preconfigured_zlib=1
else
echo "$0: warning: cannot find: src/zlib/$zlib_makefile"
with_preconfigured_zlib=0
fi
;;
esac
if test "$with_preconfigured_zlib" -ne 0
then
echo "Using pre-configured zlib..."
ZLIB_MK="$zlib_makefile"
# The pre-configured makefiles in zlib don't do distclean.
ZLIB_DISTCLEAN=clean
else
echo "Configuring zlib..."
(cd src/zlib && ./configure --static)
if test $? -ne 0
then
echo "$0: error: could not configure: zlib"
exit 1
fi
fi
else
USE_SYSTEM_ZLIB_TRUE=""
USE_SYSTEM_ZLIB_FALSE="#"
echo "Checking for system zlib..."
test=conftest$$
cat > $test.c <<EOM
#include <zlib.h>
#if ZLIB_VERNUM < 0x1210
#error This program requires zlib version 1.2.1 or higher.
#endif
int dummy;
EOM
($CC -c $CPPFLAGS $CFLAGS $test.c) 2>/dev/null
status=$?
rm -f $test.c $test.o
if test $status -ne 0
then
echo "$0: error: missing zlib or incorrect zlib version"
echo "$0: note: zlib version 1.2.1 or higher is required"
exit 1
fi
fi
sed_config="
s|@prefix@|$prefix|g
s|@exec_prefix@|$exec_prefix|g
s|@bindir@|$bindir|g
s|@mandir@|$mandir|g
s|@man1dir@|$man1dir|g
s|@USE_SYSTEM_LIBPNG_TRUE@|$USE_SYSTEM_LIBPNG_TRUE|g
s|@USE_SYSTEM_LIBPNG_FALSE@|$USE_SYSTEM_LIBPNG_FALSE|g
s|@USE_SYSTEM_ZLIB_TRUE@|$USE_SYSTEM_ZLIB_TRUE|g
s|@USE_SYSTEM_ZLIB_FALSE@|$USE_SYSTEM_ZLIB_FALSE|g
s|@CC@|${CC-cc}|g
s|@CFLAGS@|${CFLAGS--O}|g
s|@CPP@|${CPP-\$(CC) -E}|g
s|@CPPFLAGS@|${CPPFLAGS-}|g
s|@LD@|${LD-\$(CC)}|g
s|@LDFLAGS@|${LDFLAGS--s}|g
s|@AR@|${AR-ar}|g
s|@ARFLAGS@|${ARFLAGS-cru}|g
s|@RANLIB@|${RANLIB-ranlib}|g
s|@LIBS@|${LIBS-}|g
s|@LIBM@|${LIBM--lm}|g
s|@LIBZ@|${LIBZ--lz}|g
s|@LIBPNG@|${LIBPNG--lpng}|g
s|@DIFF@|${DIFF-diff -b -u}|g
s|@RM_F@|${RM_F-rm -f}|g
s|@LIBPNG_MK@|${LIBPNG_MK-Makefile}|g
s|@LIBPNG_MK_DEF@|${LIBPNG_MK_DEF-PNGLIBCONF_H_PREBUILT=pnglibconf.h.optipng}|g
s|@LIBPNG_DISTCLEAN@|${LIBPNG_DISTCLEAN-distclean}|g
s|@LIBPNG_DISTCLEAN_XCMD@|${LIBPNG_DISTCLEAN_XCMD-true}|g
s|@ZLIB_MK@|${ZLIB_MK-Makefile}|g
s|@ZLIB_DISTCLEAN@|${ZLIB_DISTCLEAN-distclean}|g
s|@[A-Z]*_MK@|Makefile|g
s| *\$||
"
for makefile in \
./Makefile \
src/Makefile \
src/gifread/Makefile \
src/minitiff/Makefile \
src/opngreduc/Makefile \
src/optipng/Makefile \
src/optipng/man/Makefile \
src/pngxtern/Makefile \
src/pnmio/Makefile
do
sed "$sed_config" $makefile.in > $makefile
done