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,$@'
119 exec_prefix
="$optarg"
144 CFLAGS
="$CFLAGS --sysroot=$optarg"
145 LDFLAGS
="$LDFLAGS --sysroot=$optarg"
167 error_exit
"unknown option $opt"
172 test -n "$prefix" || prefix
="/usr/local"
173 test -n "$exec_prefix" || exec_prefix
='${prefix}'
174 test -n "$bindir" || bindir
='${exec_prefix}/bin'
175 test -n "$libdir" || libdir
='${exec_prefix}/lib'
176 test -n "$includedir" || includedir
='${prefix}/include'
182 RANLIB
="${CROSS}${RANLIB}"
183 STRIP
="${CROSS}${STRIP}"
184 for f
in "$CC" "$AR" "$LD" "$RANLIB" "$STRIP"; do
185 test -n "$(which $f 2> /dev/null)" || error_exit
"$f is not executable"
189 MAJVER
=$
(grep -e '#define LSMASH_VERSION_MAJOR' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MAJOR //;s/ //g')
190 MINVER
=$
(grep -e '#define LSMASH_VERSION_MINOR' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MINOR //;s/ //g')
191 MICVER
=$
(grep -e '#define LSMASH_VERSION_MICRO' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MICRO //;s/ //g')
193 if test -n "$TARGET_OS"; then
194 TARGET_OS
=$
(echo $TARGET_OS |
tr '[A-Z]' '[a-z]')
196 TARGET_OS
=$
($CC -dumpmachine |
tr '[A-Z]' '[a-z]')
202 IMPLIB
="liblsmash.dll.a"
203 SO_LDFLAGS
="-shared -Wl,--out-implib,$IMPLIB"
204 CFLAGS
="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
208 SHARED_NAME
="cyglsmash"
210 IMPLIB
="liblsmash.dll.a"
211 SO_LDFLAGS
="-shared -Wl,--out-implib,$IMPLIB"
215 SO_LDFLAGS
="-dynamiclib -Wl,-undefined,suppress -Wl,-read_only_relocs,suppress -Wl,-flat_namespace"
222 SHARED_NAME
="liblsmash"
223 SHARED_EXT
=".so.$MAJVER"
224 if test -n "$SHAREDLIB"; then
225 CFLAGS
="$CFLAGS -fPIC"
226 LDFLAGS
="$LDFLAGS -fPIC"
232 STATICLIBNAME
="${STATIC_NAME}${STATIC_EXT}"
233 SHAREDLIBNAME
="${SHARED_NAME}${SHARED_EXT}"
234 test -n "$STATICLIB" && STATICLIB
="$STATICLIBNAME"
235 test -n "$SHAREDLIB" && SHAREDLIB
="$SHAREDLIBNAME"
236 test -z "$STATICLIB" -a -z "$SHAREDLIB" && \
237 error_exit
"--disable-static requires --enable-shared were specified"
238 test -z "$SHAREDLIB" && SO_LDFLAGS
=""
241 CFLAGS
="$CFLAGS $XCFLAGS"
242 LDFLAGS
="$LDFLAGS $XLDFLAGS"
246 # In order to avoid some compiler bugs, we don't use "-O3" for the default.
247 # "-Os" unites "-O2" and "-finline-funtions" on x86/x86_64 in the latest GCC.
248 # As a result of taking these into consideration, we make "-Os" a rated value.
249 # And, we don't care about architecture related options.
250 # If you want them, set up by yourself like --extra-cflags="-O3 -march=native".
251 if test -n "$DEBUG"; then
252 CFLAGS
="$CFLAGS -g3 -O0"
255 CFLAGS
="-Os -ffast-math $CFLAGS"
259 if ! cc_check
"$CFLAGS" "$LDFLAGS"; then
260 error_exit
"invalid CFLAGS/LDFLAGS"
263 if cc_check
"$CFLAGS -fexcess-precision=fast" "$LDFLAGS"; then
264 CFLAGS
="$CFLAGS -fexcess-precision=fast"
267 if cc_check
"$CFLAGS" "$LDFLAGS -Wl,--large-address-aware"; then
268 LDFLAGS
="$LDFLAGS -Wl,--large-address-aware"
272 #=============================================================================
273 # Notation for developpers.
274 # Be sure to modified this block when you add/delete source files.
328 for src
in $SRC_COMMON; do
329 SRCS
="$SRCS common/$src"
332 for src
in $SRC_CODECS; do
333 SRCS
="$SRCS codecs/$src"
336 for src
in $SRC_IMPORTER; do
337 SRCS
="$SRCS importer/$src"
340 for src
in $SRC_CORE; do
341 SRCS
="$SRCS core/$src"
349 for src
in $SRC_CLI; do
350 SRC_TOOLS
="$SRC_TOOLS cli/$src"
353 for src
in $SRC_TOOLS; do
354 OBJ_TOOLS
="$OBJ_TOOLS ${src%.c}.o"
357 TOOLS_ALL
="muxer remuxer boxdumper timelineeditor"
361 for tool
in $TOOLS; do
362 SRC_TOOLS
="$SRC_TOOLS cli/${tool}.c"
363 TOOLS_NAME
="$TOOLS_NAME cli/${tool}${EXT}"
365 #=============================================================================
369 VER
=$MAJVER.
$MINVER.
$MICVER
370 REV
="$(git rev-list HEAD 2> /dev/null | wc -l)"
371 if test $REV -ne 0; then
372 VER_STRING
="$VER rev.$REV"
376 HASH
="$(git describe --always 2> /dev/null)"
378 cat >> config.h
<< EOF
379 #define LSMASH_REV "$REV"
380 #define LSMASH_GIT_HASH "$HASH"
384 cat >> liblsmash.pc
<< EOF
386 exec_prefix=$exec_prefix
388 includedir=$includedir
391 Description: Loyal to Spec of MPEG4, and Ad-hock Simple Hackwork
394 URL: https://github.com/l-smash/l-smash
395 Libs: -L${libdir} -llsmash $LIBS
397 Cflags: -I${includedir}
401 cat >> config.mak
<< EOF
405 exec_prefix = $exec_prefix
408 includedir = $includedir
414 STATICLIBNAME = $STATICLIBNAME
415 STATICLIB = $STATICLIB
416 SHAREDLIBNAME = $SHAREDLIBNAME
417 SHAREDLIB = $SHAREDLIB
421 SO_LDFLAGS = $SO_LDFLAGS
427 cat >> config.mak
<< EOF
429 SRC_TOOLS = $SRC_TOOLS
430 TOOLS_ALL = $TOOLS_ALL
436 for tool
in $TOOLS; do
437 cat >> config.mak2
<< EOF
438 cli/${tool}${EXT}: cli/${tool}.o $OBJ_TOOLS $STATICLIB $SHAREDLIB
439 \$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$< $OBJ_TOOLS -llsmash \$(LIBS)
440 -@ \$(if \$(STRIP), \$(STRIP) \$@)
446 test "$SRCDIR" = "." ||
ln -sf ${SRCDIR}/Makefile .
447 mkdir
-p cli codecs common core importer
454 type 'make' : compile library and tools
455 type 'make install' : install all into system
456 type 'make lib' : compile library only
457 type 'make install-lib' : install library and header into system