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
61 echo 'int main(void){int a[2*(sizeof(void *)>4)-1]; return 0;}' > conftest.c
62 $CC conftest.c
-o conftest
2> /dev
/null
68 #-----------------------------------------------------------------------------
70 rm -f config.
* .depend conftest
* liblsmash.pc
*.ver
74 echo generating config.mak ...
78 SRCDIR
=$
(dirname "$0")
79 SRCDIR
=$
(cd "$SRCDIR"; pwd)
80 test "$SRCDIR" = "$(pwd)" && SRCDIR
=.
81 test -n "$(echo $SRCDIR | grep ' ')" && \
82 error_exit
"out-of-tree builds are impossible with whitespace in source path"
105 STATIC_NAME
="liblsmash"
109 SHARED_NAME
="liblsmash"
116 CFLAGS
="-Wshadow -Wall -std=c99 -pedantic -I. -I$SRCDIR"
118 SO_LDFLAGS
='-shared -Wl,-soname,$@ -Wl,--version-script,liblsmash.ver'
128 exec_prefix
="$optarg"
153 CFLAGS
="$CFLAGS --sysroot=$optarg"
154 LDFLAGS
="$LDFLAGS --sysroot=$optarg"
176 error_exit
"unknown option $opt"
181 test -n "$prefix" || prefix
="/usr/local"
182 test -n "$exec_prefix" || exec_prefix
='${prefix}'
183 test -n "$bindir" || bindir
='${exec_prefix}/bin'
184 test -n "$libdir" || libdir
='${exec_prefix}/lib'
185 test -n "$includedir" || includedir
='${prefix}/include'
191 RANLIB
="${CROSS}${RANLIB}"
192 STRIP
="${CROSS}${STRIP}"
193 for f
in "$CC" "$AR" "$LD" "$RANLIB" "$STRIP"; do
194 test -n "$(which $f 2> /dev/null)" || error_exit
"$f is not executable"
198 MAJVER
=$
(grep -e '#define LSMASH_VERSION_MAJOR' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MAJOR //;s/ //g')
199 MINVER
=$
(grep -e '#define LSMASH_VERSION_MINOR' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MINOR //;s/ //g')
200 MICVER
=$
(grep -e '#define LSMASH_VERSION_MICRO' $SRCDIR/lsmash.h |
sed -e 's/#define LSMASH_VERSION_MICRO //;s/ //g')
202 if test -n "$TARGET_OS"; then
203 TARGET_OS
=$
(echo $TARGET_OS |
tr '[A-Z]' '[a-z]')
205 TARGET_OS
=$
($CC -dumpmachine |
tr '[A-Z]' '[a-z]')
210 SHARED_NAME
="liblsmash-$MAJVER"
212 DEFNAME
="${SHARED_NAME}.def"
213 IMPLIB
="liblsmash.dll.a"
214 SO_LDFLAGS
="-shared -Wl,--output-def,$DEFNAME -Wl,--out-implib,$IMPLIB -Wl,--version-script,liblsmash.ver"
215 CFLAGS
="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
217 if lib.exe
--list > /dev
/null
2>&1 ; then
221 SLIB_CMD
='sed -i "s/ @[^ ]*//" $(DEFNAME); lib.exe -machine:$(LIBARCH) -def:$(DEFNAME) -out:lsmash.lib'
222 elif genlib
-V > /dev
/null
2>&1 ; then
228 SLIB_CMD
='sed -i "s/ @[^ ]*//" $(DEFNAME); genlib -a $(LIBARCH) -o lsmash.lib -d $(SHAREDLIBNAME) $(DEFNAME)'
229 elif ${CROSS}dlltool
--version > /dev
/null
2>&1 ; then
231 LIBARCH
="i386:x86-64"
233 SLIB_CMD
="sed -i \"s/ @[^ ]*//\" \$(DEFNAME); ${CROSS}dlltool -m \$(LIBARCH) -d \$(DEFNAME) -l lsmash.lib -D \$(SHAREDLIBNAME)"
238 SHARED_NAME
="cyglsmash"
240 IMPLIB
="liblsmash.dll.a"
241 SO_LDFLAGS
="-shared -Wl,--out-implib,$IMPLIB -Wl,--version-script,liblsmash.ver"
245 SO_LDFLAGS
="-dynamiclib -Wl,-undefined,suppress -Wl,-read_only_relocs,suppress -Wl,-flat_namespace -Wl,--version-script,liblsmash.ver"
252 SHARED_NAME
="liblsmash"
253 SHARED_EXT
=".so.$MAJVER"
254 if test -n "$SHAREDLIB"; then
255 CFLAGS
="$CFLAGS -fPIC"
256 LDFLAGS
="$LDFLAGS -fPIC"
262 STATICLIBNAME
="${STATIC_NAME}${STATIC_EXT}"
263 SHAREDLIBNAME
="${SHARED_NAME}${SHARED_EXT}"
264 test -n "$STATICLIB" && STATICLIB
="$STATICLIBNAME"
265 test -n "$SHAREDLIB" && SHAREDLIB
="$SHAREDLIBNAME"
266 test -z "$STATICLIB" -a -z "$SHAREDLIB" && \
267 error_exit
"--disable-static requires --enable-shared were specified"
268 test -z "$SHAREDLIB" && SO_LDFLAGS
=""
271 CFLAGS
="$CFLAGS $XCFLAGS"
272 LDFLAGS
="$LDFLAGS $XLDFLAGS"
276 # In order to avoid some compiler bugs, we don't use "-O3" for the default.
277 # "-Os" unites "-O2" and "-finline-funtions" on x86/x86_64 in the latest GCC.
278 # As a result of taking these into consideration, we make "-Os" a rated value.
279 # And, we don't care about architecture related options.
280 # If you want them, set up by yourself like --extra-cflags="-O3 -march=native".
281 if test -n "$DEBUG"; then
282 CFLAGS
="$CFLAGS -g3 -O0"
285 CFLAGS
="-Os -ffast-math $CFLAGS"
289 if ! cc_check
"$CFLAGS" "$LDFLAGS"; then
290 error_exit
"invalid CFLAGS/LDFLAGS"
293 if cc_check
"$CFLAGS -fexcess-precision=fast" "$LDFLAGS"; then
294 CFLAGS
="$CFLAGS -fexcess-precision=fast"
297 if cc_check
"$CFLAGS" "$LDFLAGS -Wl,--large-address-aware"; then
298 LDFLAGS
="$LDFLAGS -Wl,--large-address-aware"
302 #=============================================================================
303 # Notation for developpers.
304 # Be sure to modified this block when you add/delete source files.
360 for src
in $SRC_COMMON; do
361 SRCS
="$SRCS common/$src"
364 for src
in $SRC_CODECS; do
365 SRCS
="$SRCS codecs/$src"
368 for src
in $SRC_IMPORTER; do
369 SRCS
="$SRCS importer/$src"
372 for src
in $SRC_CORE; do
373 SRCS
="$SRCS core/$src"
381 for src
in $SRC_CLI; do
382 SRC_TOOLS
="$SRC_TOOLS cli/$src"
385 for src
in $SRC_TOOLS; do
386 OBJ_TOOLS
="$OBJ_TOOLS ${src%.c}.o"
389 TOOLS_ALL
="muxer remuxer boxdumper timelineeditor"
393 for tool
in $TOOLS; do
394 SRC_TOOLS
="$SRC_TOOLS cli/${tool}.c"
395 TOOLS_NAME
="$TOOLS_NAME cli/${tool}${EXT}"
397 #=============================================================================
401 VER
=$MAJVER.
$MINVER.
$MICVER
402 if test -d .git
&& type git
> /dev
/null
2>&1 ; then
403 REV
="$(git rev-list HEAD 2> /dev/null | wc -l)"
404 HASH
="$(git describe --always 2> /dev/null)"
409 if test $REV -ne 0; then
410 VER_STRING
="$VER rev.$REV"
415 cat >> config.h
<< EOF
416 #define LSMASH_REV "$REV"
417 #define LSMASH_GIT_HASH "$HASH"
421 sed "s/\\\$MAJOR/$MAJVER/" $SRCDIR/liblsmash.v
> liblsmash.ver
422 # Add non-public symbols which have lsmash_* prefix to local.
423 find $SRCDIR/common
/ $SRCDIR/importer
/ -name "*.h" |
xargs sed -e 's/^[ ]*//g' | \
424 grep "^\(void\|lsmash_bits_t\|uint64_t\|int\|int64_t\|lsmash_bs_t\|uint8_t\|uint16_t\|uint32_t\|lsmash_entry_list_t\|lsmash_entry_t\|lsmash_multiple_buffers_t\|double\|float\|FILE\) \+\*\{0,1\}lsmash_" | \
425 sed -e "s/.*\(lsmash_.*\)(.*/\1/g" -e "s/.*\(lsmash_.*\)/\1;/g" |
xargs -I% sed -i "/^};$/i \ %" liblsmash.ver
426 # Get rid of non-public symbols for the cli tools from local.
427 sed -i -e '/lsmash_win32_fopen/d' \
428 -e '/lsmash_string_from_wchar/d' \
429 -e '/lsmash_importer_open/d' \
430 -e '/lsmash_importer_close/d' \
431 -e '/lsmash_importer_get_access_unit/d' \
432 -e '/lsmash_importer_get_last_delta/d' \
433 -e '/lsmash_importer_construct_timeline/d' \
434 -e '/lsmash_importer_get_track_count/d' \
435 -e '/lsmash_duplicate_summary/d' liblsmash.ver
438 cat >> liblsmash.pc
<< EOF
440 exec_prefix=$exec_prefix
442 includedir=$includedir
445 Description: Loyal to Spec of MPEG4, and Ad-hock Simple Hackwork
448 URL: https://github.com/l-smash/l-smash
449 Libs: -L${libdir} -llsmash $(test -z "$SHAREDLIB" && echo $LIBS)
450 Libs.private: $(test -n "$SHAREDLIB" && echo $LIBS)
451 Cflags: -I${includedir}
455 cat >> config.mak
<< EOF
459 exec_prefix = $exec_prefix
462 includedir = $includedir
468 STATICLIBNAME = $STATICLIBNAME
469 STATICLIB = $STATICLIB
470 SHAREDLIBNAME = $SHAREDLIBNAME
471 SHAREDLIB = $SHAREDLIB
475 SO_LDFLAGS = $SO_LDFLAGS
484 cat >> config.mak
<< EOF
486 SRC_TOOLS = $SRC_TOOLS
487 TOOLS_ALL = $TOOLS_ALL
493 for tool
in $TOOLS; do
494 cat >> config.mak2
<< EOF
495 cli/${tool}${EXT}: cli/${tool}.o $OBJ_TOOLS $STATICLIB $SHAREDLIB
496 \$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$< $OBJ_TOOLS -llsmash \$(LIBS)
497 -@ \$(if \$(STRIP), \$(STRIP) \$@)
503 test "$SRCDIR" = "." ||
ln -sf ${SRCDIR}/Makefile .
504 mkdir
-p cli codecs common core importer
511 type 'make' : compile library and tools
512 type 'make install' : install all into system
513 type 'make lib' : compile library only
514 type 'make install-lib' : install library and header into system