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.
358 for src
in $SRC_COMMON; do
359 SRCS
="$SRCS common/$src"
362 for src
in $SRC_CODECS; do
363 SRCS
="$SRCS codecs/$src"
366 for src
in $SRC_IMPORTER; do
367 SRCS
="$SRCS importer/$src"
370 for src
in $SRC_CORE; do
371 SRCS
="$SRCS core/$src"
379 for src
in $SRC_CLI; do
380 SRC_TOOLS
="$SRC_TOOLS cli/$src"
383 for src
in $SRC_TOOLS; do
384 OBJ_TOOLS
="$OBJ_TOOLS ${src%.c}.o"
387 TOOLS_ALL
="muxer remuxer boxdumper timelineeditor"
391 for tool
in $TOOLS; do
392 SRC_TOOLS
="$SRC_TOOLS cli/${tool}.c"
393 TOOLS_NAME
="$TOOLS_NAME cli/${tool}${EXT}"
395 #=============================================================================
399 VER
=$MAJVER.
$MINVER.
$MICVER
400 if test -d .git
&& type git
> /dev
/null
2>&1 ; then
401 REV
="$(git rev-list HEAD 2> /dev/null | wc -l)"
402 HASH
="$(git describe --always 2> /dev/null)"
407 if test $REV -ne 0; then
408 VER_STRING
="$VER rev.$REV"
413 cat >> config.h
<< EOF
414 #define LSMASH_REV "$REV"
415 #define LSMASH_GIT_HASH "$HASH"
419 sed "s/\\\$MAJOR/$MAJVER/" $SRCDIR/liblsmash.v
> liblsmash.ver
420 # Add non-public symbols which have lsmash_* prefix to local.
421 find $SRCDIR/common
/ $SRCDIR/importer
/ -name "*.h" |
xargs sed -e 's/^[ ]*//g' | \
422 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\).*lsmash_" | \
423 sed -e "s/.*\(lsmash_.*\)(.*/\1/g" -e "s/.*\(lsmash_.*\)/\1;/g" |
xargs -I% sed -i "/^};$/i \ %" liblsmash.ver
424 # Get rid of non-public symbols for the cli tools from local.
425 sed -i -e '/lsmash_win32_fopen/d' \
426 -e '/lsmash_string_from_wchar/d' \
427 -e '/lsmash_importer_open/d' \
428 -e '/lsmash_importer_close/d' \
429 -e '/lsmash_importer_get_access_unit/d' \
430 -e '/lsmash_importer_get_last_delta/d' \
431 -e '/lsmash_importer_construct_timeline/d' \
432 -e '/lsmash_importer_get_track_count/d' \
433 -e '/lsmash_duplicate_summary/d' liblsmash.ver
436 cat >> liblsmash.pc
<< EOF
438 exec_prefix=$exec_prefix
440 includedir=$includedir
443 Description: Loyal to Spec of MPEG4, and Ad-hock Simple Hackwork
446 URL: https://github.com/l-smash/l-smash
447 Libs: -L${libdir} -llsmash $(test -z "$SHAREDLIB" && echo $LIBS)
448 Libs.private: $(test -n "$SHAREDLIB" && echo $LIBS)
449 Cflags: -I${includedir}
453 cat >> config.mak
<< EOF
457 exec_prefix = $exec_prefix
460 includedir = $includedir
466 STATICLIBNAME = $STATICLIBNAME
467 STATICLIB = $STATICLIB
468 SHAREDLIBNAME = $SHAREDLIBNAME
469 SHAREDLIB = $SHAREDLIB
473 SO_LDFLAGS = $SO_LDFLAGS
482 cat >> config.mak
<< EOF
484 SRC_TOOLS = $SRC_TOOLS
485 TOOLS_ALL = $TOOLS_ALL
491 for tool
in $TOOLS; do
492 cat >> config.mak2
<< EOF
493 cli/${tool}${EXT}: cli/${tool}.o $OBJ_TOOLS $STATICLIB $SHAREDLIB
494 \$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$< $OBJ_TOOLS -llsmash \$(LIBS)
495 -@ \$(if \$(STRIP), \$(STRIP) \$@)
501 test "$SRCDIR" = "." ||
ln -sf ${SRCDIR}/Makefile .
502 mkdir
-p cli codecs common core importer
509 type 'make' : compile library and tools
510 type 'make install' : install all into system
511 type 'make lib' : compile library only
512 type 'make install-lib' : install library and header into system