-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·108 lines (108 loc) · 3.07 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
#!/bin/sh
set -e
nothreads=0
fopenx=2
gitdescribe=1
version=
[ -z "$CC" ] && CC=cc
for arg; do case "$arg" in
--disable-threading) nothreads=1;;
--enable-fopen-x) fopenx=1;;
--disable-fopen-x) fopenx=0;;
--disable-git-describe) gitdescribe=0;;
--help)
echo 'usage: ./configure [flags]'
echo flags are passed to libpng and libwebp\'s configures
echo
echo --disable-threading: force single-threaded build
echo default is to follow libwebp\'s threading test
echo
echo '--enable-fopen-x: force use of C11 fopen("wbx")'
echo '--disable-fopen-x: force use of POSIX fdopen()'
echo default is to compile and run conf/fopenx.c
echo
echo --disable-git-describe: don\'t name non-release versions
exit 1;;
*) echo "warning: unknown configure option '$arg'";;
esac; done
origCPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I$PWD/zlib -I$PWD/libpng -I$PWD/libwebp -I$PWD/libwebp/src"
CPPFLAGS="$CPPFLAGS -DWEBP_REDUCE_SIZE $origCPPFLAGS"
echo configuring zlib...
cd zlib
./configure --static --solo --const
echo configured zlib
echo configuring libpng...
cd ../libpng
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
./configure --enable-static=yes --enable-shared=no \
--enable-hardware-optimizations ac_cv_lib_z_zlibVersion=yes "$@"
echo configured libpng
echo configuring libwebp...
cd ../libwebp
./autogen.sh
./configure --enable-static=yes --enable-shared=no --disable-near-lossless "$@"
echo configured libwebp
cd ..
CPPFLAGS="$origCPPFLAGS"
if [ $gitdescribe -eq 1 ]; then
echo checking PNG2WebP version
if ! command -v git >/dev/null; then
echo git is not installed
elif ! git rev-parse >/dev/null; then
echo not a git repository
else
version="$(git describe --tags 2>/dev/null || true)"
[ -z "$version" ] && echo '`git describe --tags` failed'
fi
else
echo version check disabled
fi
if [ -n "$version" ]; then
echo "PNG2WebP $version"
else
echo using default version string
echo "PNG2WebP $(grep '^#define VERSION "' png2webp.c | cut '-d"' -f2)"
fi
if [ $nothreads -eq 0 ] &&
! grep -Fxq '#define WEBP_USE_THREAD 1' libwebp/src/webp/config.h
then
echo threading disabled by libwebp
nothreads=2
fi
if [ $fopenx -eq 2 ]; then
echo 'testing C11 fopen("wbx") support'
cd conf
if $CC $CFLAGS $CPPFLAGS $LDFLAGS fopenx.c $LDLIBS -o fopenx && ./fopenx
then
echo test succeeded
fopenx=1
else
echo test failed
fopenx=0
fi
rm -f fopenx
cd ..
fi
echo '// p2wconf.h; see README.md' >p2wconf.h
[ -n "$version" ] && echo "#define VERSION \"$version\"" >>p2wconf.h
if [ $nothreads -ge 1 ]; then
[ $nothreads -eq 1 ] && echo threading disabled by user
echo '#define NOTHREADS 1' >>p2wconf.h
echo '# PTHREAD_CC =' >conf/pthread.mk
echo '# PTHREAD_CFLAGS =' >>conf/pthread.mk
echo '# PTHREAD_LIBS =' >>conf/pthread.mk
else
echo threading enabled
echo '// #undef NOTHREADS' >>p2wconf.h
grep -E '^PTHREAD_(CC|CFLAGS|LIBS)[^[:alnum:]_]' \
libwebp/Makefile >conf/pthread.mk
fi
if [ $fopenx -eq 1 ]; then
echo 'using C11 fopen("wbx")'
echo '// #undef NOFOPENX' >>p2wconf.h
else
echo 'using POSIX fdopen() instead of C11 fopen("wbx")'
echo '#define NOFOPENX 1' >>p2wconf.h
fi
echo PNG2WebP configure done