3 # Minimum Profit autoconfiguration script
10 VERSION
=`cut -f2 -d\" VERSION`
12 # default installation prefix
15 # store command line args for configuring the libraries
18 # add a default value for WINDRES
19 [ -z "$WINDRES" ] && WINDRES
="windres"
25 while [ $# -gt 0 ] ; do
28 --without-curses) WITHOUT_CURSES
=1 ;;
29 --without-gtk) WITHOUT_GTK
=1 ;;
30 --without-win32) WITHOUT_WIN32
=1 ;;
31 --with-kde4) WITHOUT_KDE4
=0 ;;
32 --without-qt4) WITHOUT_QT4
=1 ;;
33 --help) CONFIG_HELP
=1 ;;
35 --mingw32) CC
=i586-mingw32msvc-cc
36 WINDRES
=i586-mingw32msvc-windres
37 AR
=i586-mingw32msvc-ar
41 --debian) BUILD_FOR_DEBIAN
=1
46 --prefix) PREFIX
=$2 ; shift ;;
47 --prefix=*) PREFIX
=`echo $1 | sed -e 's/--prefix=//'` ;;
53 if [ "$CONFIG_HELP" = "1" ] ; then
55 echo "Available options:"
56 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
57 echo "--without-curses Disable curses (text) interface detection."
58 echo "--without-gtk Disable GTK interface detection."
59 echo "--without-win32 Disable win32 interface detection."
60 echo "--with-kde4 Enable KDE4 interface detection."
61 echo "--without-qt4 Disable Qt4 interface detection."
62 echo "--without-unix-glob Disable glob.h usage (use workaround)."
63 echo "--with-included-regex Use included regex code (gnu_regex.c)."
64 echo "--with-pcre Enable PCRE library detection."
65 echo "--without-gettext Disable gettext usage."
66 echo "--without-iconv Disable iconv usage."
67 echo "--without-wcwidth Disable system wcwidth() (use workaround)."
68 echo "--with-null-hash Tell MPDM to use a NULL hashing function."
69 echo "--mingw32 Build using the mingw32 compiler."
70 echo "--debian Build for Debian ('make deb')."
73 echo "Environment variables:"
75 echo "AR Library Archiver."
76 echo "CFLAGS Compile flags (i.e., -O3)."
77 echo "WINDRES MS Windows resource compiler."
84 echo "/* automatically created by config.sh - do not modify */" > config.h
85 echo "# automatically created by config.sh - do not modify" > makefile.opts
91 if [ "$CC" = "" ] ; then
93 # if CC is unset, try if gcc is available
94 which gcc
> /dev
/null
2>&1 && CC
=gcc
97 if [ "$CPP" = "" ] ; then
99 # if CC is unset, try if gcc is available
100 which g
++ > /dev
/null
2>&1 && CPP
=g
++
104 which moc-qt4
> /dev
/null
2>&1 && MOC
=moc-qt4
106 echo "CC=$CC" >> makefile.opts
107 echo "CPP=$CPP" >> makefile.opts
108 echo "MOC=$MOC" >> makefile.opts
111 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
115 echo "CFLAGS=$CFLAGS" >> makefile.opts
121 cat VERSION
>> config.h
123 # add installation prefix and application name
124 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
125 echo "#define CONFOPT_APPNAME \"$APPNAME\"" >> config.h
127 ################################################################
130 echo -n "Looking for MPDM... "
132 for MPDM
in .
/mpdm ..
/mpdm NOTFOUND
; do
133 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h
] ; then
138 if [ "$MPDM" != "NOTFOUND" ] ; then
139 echo "-I$MPDM" >> config.cflags
140 echo "-L$MPDM -lmpdm" >> config.ldflags
147 # If MPDM is not configured, do it
148 if [ ! -f $MPDM/Makefile
] ; then
149 ( echo ; cd $MPDM ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
152 cat $MPDM/config.ldflags
>> config.ldflags
153 echo "MPDM=$MPDM" >> makefile.opts
156 echo -n "Looking for MPSL... "
158 for MPSL
in .
/mpsl ..
/mpsl NOTFOUND
; do
159 if [ -d $MPSL ] && [ -f $MPSL/mpsl.h
] ; then
164 if [ "$MPSL" != "NOTFOUND" ] ; then
165 echo "-I$MPSL" >> config.cflags
166 echo "-L$MPSL -lmpsl" >> config.ldflags
173 # If MPSL is not configured, do it
174 if [ ! -f $MPSL/Makefile
] ; then
175 ( echo ; cd $MPSL ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
178 cat $MPSL/config.ldflags
>> config.ldflags
179 echo "MPSL=$MPSL" >> makefile.opts
183 echo -n "Testing for win32... "
184 if [ "$WITHOUT_WIN32" = "1" ] ; then
187 grep CONFOPT_WIN32
${MPDM}/config.h
>/dev
/null
190 echo "-mwindows -lcomctl32" >> config.ldflags
191 echo "#define CONFOPT_WIN32 1" >> config.h
193 DRIVERS
="win32 $DRIVERS"
194 DRV_OBJS
="mpv_win32.o $DRV_OBJS"
206 # test for curses / ncurses library
207 echo -n "Testing for ncursesw... "
209 if [ "$WITHOUT_CURSES" = "1" ] ; then
212 echo "#include <ncursesw/ncurses.h>" > .tmp.c
213 echo "int main(void) { initscr(); endwin(); return 0; }" >> .tmp.c
215 TMP_CFLAGS
="-I/usr/local/include"
216 TMP_LDFLAGS
="-L/usr/local/lib -lncursesw"
218 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
220 echo "#define CONFOPT_CURSES 1" >> config.h
221 echo $TMP_CFLAGS >> config.cflags
222 echo $TMP_LDFLAGS >> config.ldflags
224 DRIVERS
="ncursesw $DRIVERS"
225 DRV_OBJS
="mpv_curses.o $DRV_OBJS"
232 if [ "$WITHOUT_CURSES" != "1" ] ; then
233 # test for transparent colors in curses
234 echo -n "Testing for transparency support in curses... "
236 echo "#include <ncursesw/ncurses.h>" > .tmp.c
237 echo "int main(void) { initscr(); use_default_colors(); endwin(); return 0; }" >> .tmp.c
239 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
241 echo "#define CONFOPT_TRANSPARENCY 1" >> config.h
247 # test now for wget_wch() existence
248 echo -n "Testing for wget_wch()... "
250 echo "#include <wchar.h>" > .tmp.c
251 echo "#include <ncursesw/ncurses.h>" >> .tmp.c
252 echo "int main(void) { wchar_t c[2]; initscr(); wget_wch(stdscr, c); endwin(); return 0; }" >> .tmp.c
254 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
256 echo "#define CONFOPT_WGET_WCH 1" >> config.h
265 echo -n "Testing for KDE4... "
266 if [ "$WITHOUT_KDE4" = "1" ] ; then
269 if which kde4-config
> /dev
/null
2>&1
271 TMP_CFLAGS
=$
(pkg-config
--cflags QtCore
)
272 TMP_CFLAGS
="$TMP_CFLAGS -I`kde4-config --install include` -I`kde4-config --install include`KDE"
274 TMP_LDFLAGS
=$
(pkg-config
--libs QtCore
)
275 TMP_LDFLAGS
="$TMP_LDFLAGS -L`kde4-config --install lib` -lkfile -lkdeui -lkdecore"
277 echo "#include <KApplication>" > .tmp.cpp
278 echo "int main(void) { new KApplication() ; return 0; } " >> .tmp.cpp
280 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
281 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
284 echo $TMP_CFLAGS >> config.cflags
285 echo $TMP_LDFLAGS >> config.ldflags
287 echo "#define CONFOPT_KDE4 1" >> config.h
290 DRIVERS
="kde4 $DRIVERS"
291 DRV_OBJS
="mpv_kde4.o $DRV_OBJS"
292 if [ "$CCLINK" = "" ] ; then
308 echo -n "Testing for Qt4... "
309 if [ "$WITHOUT_QT4" = "1" ] ; then
312 if which pkg-config
> /dev
/null
2>&1
314 TMP_CFLAGS
=$
(pkg-config
--cflags QtGui
)
315 TMP_LDFLAGS
="$(pkg-config --libs QtGui) -lX11"
317 echo "#include <QtGui>" > .tmp.cpp
318 echo "int main(int argc, char *argv[]) { new QApplication(argc, argv) ; return 0; } " >> .tmp.cpp
320 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
321 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
324 echo $TMP_CFLAGS >> config.cflags
325 echo $TMP_LDFLAGS >> config.ldflags
327 echo "#define CONFOPT_QT4 1" >> config.h
330 DRIVERS
="qt4 $DRIVERS"
331 DRV_OBJS
="mpv_qt4.o $DRV_OBJS"
332 if [ "$CCLINK" = "" ] ; then
346 echo -n "Testing for GTK... "
348 if [ "$WITHOUT_GTK" = "1" ] ; then
351 echo "#include <gtk/gtk.h>" > .tmp.c
352 echo "#include <gdk/gdkkeysyms.h>" >> .tmp.c
353 echo "int main(void) { gtk_main(); return 0; } " >> .tmp.c
356 TMP_CFLAGS
=`sh -c 'pkg-config --cflags gtk+-2.0' 2>/dev/null`
357 TMP_LDFLAGS
=`sh -c 'pkg-config --libs gtk+-2.0' 2>/dev/null`
359 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
361 echo "#define CONFOPT_GTK 2" >> config.h
362 echo "$TMP_CFLAGS " >> config.cflags
363 echo "$TMP_LDFLAGS " >> config.ldflags
365 DRIVERS
="gtk $DRIVERS"
366 DRV_OBJS
="mpv_gtk.o $DRV_OBJS"
373 echo -n "Testing for msgfmt... "
375 if which msgfmt
> /dev
/null
2>&1 ; then
377 echo "BUILDMO=build-mo" >> makefile.opts
378 echo "INSTALLMO=install-mo" >> makefile.opts
379 echo "UNINSTALLMO=uninstall-mo" >> makefile.opts
382 echo "BUILDMO=" >> makefile.opts
383 echo "INSTALLMO=" >> makefile.opts
384 echo "UNINSTALLMO=" >> makefile.opts
387 if [ "$CCLINK" = "" ] ; then
393 grep DOCS
$MPDM/makefile.opts
>> makefile.opts
394 echo "VERSION=$VERSION" >> makefile.opts
395 echo "WINDRES=$WINDRES" >> makefile.opts
396 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
397 echo "APPNAME=$APPNAME" >> makefile.opts
398 echo "DRV_OBJS=$DRV_OBJS" >> makefile.opts
399 echo "CCLINK=$CCLINK" >> makefile.opts
400 echo >> makefile.opts
402 cat makefile.opts makefile.
in makefile.depend
> Makefile
404 ##############################################
406 if [ "$DRIVERS" = "" ] ; then
409 echo "*ERROR* No usable drivers (interfaces) found"
410 echo "See the README file for the available options."
416 echo "Configured drivers:" $DRIVERS
418 echo "Type 'make' to build Minimum Profit."
420 # insert driver detection code into config.h
422 TRY_DRIVERS
="#define TRY_DRIVERS() ("
424 for drv
in $DRIVERS ; do
425 echo "int ${drv}_drv_detect(int * argc, char *** argv);" >> config.h
426 TRY_DRIVERS
="$TRY_DRIVERS ${drv}_drv_detect(&argc, &argv) || "
430 echo $TRY_DRIVERS '0)' >> config.h
433 rm -f .tmp.c .tmp.cpp .tmp.o