3 #----------------------------------------------------------------------------
4 # configure script for L-SMASH
6 # Currently, this script is considering only GCC.
7 # If you want to use other compiler based on C99 standerd (e.g. llvm),
8 # we just say to you "patches welcome."
9 #----------------------------------------------------------------------------
11 if test x
"$1" = x
"-h" -o x
"$1" = x
"--help" ; then
13 Usage: ./configure [options]
16 -h, --help print this message
18 --prefix=PREFIX install architecture-independent files into PREFIX
20 --exec-prefix=EPREFIX install architecture-dependent files into EPREFIX
22 --bindir=DIR install binaries in DIR [EPREFIX/bin]
23 --libdir=DIR install libs in DIR [EPREFIX/lib]
24 --includedir=DIR install headers in DIR [PREFIX/include]
26 --cc=CC use a defined compiler for compilation and linking [gcc]
27 --target-os=OS build programs to run on OS [auto]
28 --cross-prefix=PREFIX use PREFIX for compilation tools [none]
29 --sysroot=DIR specify toolchain's directory [none]
30 --disable-static doesn't compile static library
31 --enable-shared also compile shared library besides static library
32 --enable-debug compile with debug symbols and never strip
34 --extra-cflags=XCFLAGS add XCFLAGS to CFLAGS
35 --extra-ldflags=XLDFLAGS add XLDFLAGS to LDFLAGS
36 --extra-libs=XLIBS add XLIBS to LIBS
41 #-----------------------------------------------------------------------------
49 #Currently, this is used only for the flag check of compiler.
52 echo 'int main(void){return 0;}' > conftest.c
53 $CC conftest.c
$1 $2 -o conftest
2> /dev
/null
59 #-----------------------------------------------------------------------------
61 rm -f config.
* .depend conftest
* liblsmash.pc
65 echo generating config.mak ...
69 SRCDIR
=$
(dirname "$0")
70 SRCDIR
=$
(cd "$SRCDIR"; pwd)
71 test "$SRCDIR" = "$(pwd)" && SRCDIR
=.
72 test -n "$(echo $SRCDIR | grep ' ')" && \
73 error_exit
"out-of-tree builds are impossible with whitespace in source path"
96 STATIC_NAME
="liblsmash"
100 SHARED_NAME
="liblsmash"
107 CFLAGS
="-Wshadow -Wall -std=c99 -pedantic -I. -I$SRCDIR"
109 SO_LDFLAGS
='-shared -Wl,-soname,$@'
121 exec_prefix
="$optarg"
146 CFLAGS
="$CFLAGS --sysroot=$optarg"
147 LDFLAGS
="$LDFLAGS --sysroot=$optarg"
168 # "--disable-demuxer" is the special option only for developers.
173 error_exit
"unknown option $opt"
178 test -n "$prefix" || prefix
="/usr/local"
179 test -n "$exec_prefix" || exec_prefix
='${prefix}'
180 test -n "$bindir" || bindir
='${exec_prefix}/bin'
181 test -n "$libdir" || libdir
='${exec_prefix}/lib'
182 test -n "$includedir" || includedir
='${prefix}/include'
188 RANLIB
="${CROSS}${RANLIB}"
189 STRIP
="${CROSS}${STRIP}"
190 for f
in "$CC" "$AR" "$LD" "$RANLIB" "$STRIP"; do
191 test -n "$(which $f 2> /dev/null)" || error_exit
"$f is not executable"
195 MAJVER
=$
(grep -e '#define LSMASH_VERSION_MAJOR' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MAJOR //;s/ //g')
196 MINVER
=$
(grep -e '#define LSMASH_VERSION_MINOR' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MINOR //;s/ //g')
197 MICVER
=$
(grep -e '#define LSMASH_VERSION_MICRO' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MICRO //;s/ //g')
199 if test -n "$TARGET_OS"; then
200 TARGET_OS
=$
(echo $TARGET_OS |
tr '[A-Z]' '[a-z]')
202 TARGET_OS
=$
($CC -dumpmachine |
tr '[A-Z]' '[a-z]')
208 IMPLIB
="liblsmash.dll.a"
209 SO_LDFLAGS
="-shared -Wl,--out-implib,$IMPLIB"
210 CFLAGS
="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
214 SHARED_NAME
="cyglsmash"
216 IMPLIB
="liblsmash.dll.a"
217 SO_LDFLAGS
="-shared -Wl,--out-implib,$IMPLIB"
221 SO_LDFLAGS
="-dynamiclib -Wl,-undefined,suppress -Wl,-read_only_relocs,suppress -Wl,-flat_namespace"
228 SHARED_NAME
="liblsmash"
229 SHARED_EXT
=".so.$MAJVER"
230 if test -n "$SHAREDLIB"; then
231 CFLAGS
="$CFLAGS -fPIC"
232 LDFLAGS
="$LDFLAGS -fPIC"
238 STATICLIBNAME
="${STATIC_NAME}${STATIC_EXT}"
239 SHAREDLIBNAME
="${SHARED_NAME}${SHARED_EXT}"
240 test -n "$STATICLIB" && STATICLIB
="$STATICLIBNAME"
241 test -n "$SHAREDLIB" && SHAREDLIB
="$SHAREDLIBNAME"
242 test -z "$STATICLIB" -a -z "$SHAREDLIB" && \
243 error_exit
"--disable-static requires --enable-shared were specified"
244 test -z "$SHAREDLIB" && SO_LDFLAGS
=""
247 CFLAGS
="$CFLAGS $XCFLAGS"
248 LDFLAGS
="$LDFLAGS $XLDFLAGS"
252 # In order to avoid some compiler bugs, we don't use "-O3" for the default.
253 # "-Os" unites "-O2" and "-finline-funtions" on x86/x86_64 in the latest GCC.
254 # As a result of taking these into consideration, we make "-Os" a rated value.
255 # And, we don't care about architecture related options.
256 # If you want them, set up by yourself like --extra-cflags="-O3 -march=native".
257 if test -n "$DEBUG"; then
258 CFLAGS
="$CFLAGS -g3 -O0"
261 CFLAGS
="-Os -ffast-math $CFLAGS"
265 if ! cc_check
"$CFLAGS" "$LDFLAGS"; then
266 error_exit
"invalid CFLAGS/LDFLAGS"
269 if cc_check
"$CFLAGS -fexcess-precision=fast" "$LDFLAGS"; then
270 CFLAGS
="$CFLAGS -fexcess-precision=fast"
273 if cc_check
"$CFLAGS" "$LDFLAGS -Wl,--large-address-aware"; then
274 LDFLAGS
="$LDFLAGS -Wl,--large-address-aware"
278 #=============================================================================
279 # Notation for developpers.
280 # Be sure to modified this block when you add/delete source files.
281 SRCS
="common/alloc.c common/utils.c common/bstream.c common/list.c \
282 common/osdep.c codecs/mp4sys.c codecs/mp4a.c codecs/dts.c codecs/a52.c \
283 codecs/h264.c codecs/hevc.c codecs/vc1.c codecs/alac.c \
284 codecs/description.c core/isom.c core/fragment.c core/summary.c \
285 core/print.c core/read.c core/timeline.c core/chapter.c core/meta.c \
286 core/write.c core/box.c core/file.c"
287 SRC_TOOLS
="cli/cli.c cli/adts_imp.c cli/mp3_imp.c cli/amr_imp.c cli/a52_imp.c \
288 cli/als_imp.c cli/dts_imp.c cli/vc1_imp.c cli/nalu_imp.c \
292 TOOLS_ALL
="muxer remuxer boxdumper timelineeditor"
295 if test -n "$DEMUXER"; then
296 CFLAGS
="$CFLAGS -DLSMASH_DEMUXER_ENABLED"
302 for tool
in $SRC_TOOLS; do
303 OBJ_TOOLS
="$OBJ_TOOLS ${tool%.c}.o"
306 for tool
in $TOOLS; do
307 SRC_TOOLS
="$SRC_TOOLS cli/${tool}.c"
308 TOOLS_NAME
="$TOOLS_NAME cli/${tool}${EXT}"
310 #=============================================================================
314 VER
=$MAJVER.
$MINVER.
$MICVER
315 REV
="$(git rev-list HEAD 2> /dev/null | wc -l)"
316 if test $REV -ne 0; then
317 VER_STRING
="$VER rev.$REV"
321 HASH
="$(git describe --always 2> /dev/null)"
323 cat >> config.h
<< EOF
324 #define LSMASH_REV "$REV"
325 #define LSMASH_GIT_HASH "$HASH"
329 cat >> liblsmash.pc
<< EOF
331 exec_prefix=$exec_prefix
333 includedir=$includedir
336 Description: Loyal to Spec of MPEG4, and Ad-hock Simple Hackwork
339 URL: https://github.com/l-smash/l-smash
340 Libs: -L${libdir} -llsmash $LIBS
342 Cflags: -I${includedir}
346 cat >> config.mak
<< EOF
350 exec_prefix = $exec_prefix
353 includedir = $includedir
359 STATICLIBNAME = $STATICLIBNAME
360 STATICLIB = $STATICLIB
361 SHAREDLIBNAME = $SHAREDLIBNAME
362 SHAREDLIB = $SHAREDLIB
366 SO_LDFLAGS = $SO_LDFLAGS
372 cat >> config.mak
<< EOF
374 SRC_TOOLS = $SRC_TOOLS
375 TOOLS_ALL = $TOOLS_ALL
381 for tool
in $TOOLS; do
382 cat >> config.mak2
<< EOF
383 cli/${tool}${EXT}: cli/${tool}.o $OBJ_TOOLS $STATICLIB $SHAREDLIB
384 \$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$< $OBJ_TOOLS -llsmash \$(LIBS)
385 -@ \$(if \$(STRIP), \$(STRIP) \$@)
391 test "$SRCDIR" = "." ||
ln -sf ${SRCDIR}/Makefile .
392 mkdir
-p cli codecs common core
399 type 'make' : compile library and tools
400 type 'make install' : install all into system
401 type 'make lib' : compile library only
402 type 'make install-lib' : install library and header into system