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 cat VERSION
>> config.h
113 # add installation prefix and application name
114 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
115 echo "#define CONFOPT_APPNAME \"$APPNAME\"" >> config.h
117 ################################################################
120 if [ -z "$CFLAGS" ] ; then
124 echo -n "Testing if C compiler supports ${CFLAGS}... "
125 echo "int main(int argc, char *argv[]) { return 0; }" > .tmp.c
127 $CC .tmp.c
-o .tmp.o
2>> .config.log
132 echo "No; resetting to defaults"
136 echo "CFLAGS=$CFLAGS" >> makefile.opts
142 echo -n "Looking for MPDM... "
144 for MPDM
in .
/mpdm ..
/mpdm NOTFOUND
; do
145 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h
] ; then
150 if [ "$MPDM" != "NOTFOUND" ] ; then
151 echo "-I$MPDM" >> config.cflags
152 echo "-L$MPDM -lmpdm" >> config.ldflags
159 # If MPDM is not configured, do it
160 if [ ! -f $MPDM/Makefile
] ; then
161 ( echo ; cd $MPDM ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
164 cat $MPDM/config.ldflags
>> config.ldflags
165 echo "MPDM=$MPDM" >> makefile.opts
168 echo -n "Looking for MPSL... "
170 for MPSL
in .
/mpsl ..
/mpsl NOTFOUND
; do
171 if [ -d $MPSL ] && [ -f $MPSL/mpsl.h
] ; then
176 if [ "$MPSL" != "NOTFOUND" ] ; then
177 echo "-I$MPSL" >> config.cflags
178 echo "-L$MPSL -lmpsl" >> config.ldflags
185 # If MPSL is not configured, do it
186 if [ ! -f $MPSL/Makefile
] ; then
187 ( echo ; cd $MPSL ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
190 cat $MPSL/config.ldflags
>> config.ldflags
191 echo "MPSL=$MPSL" >> makefile.opts
195 echo -n "Testing for win32... "
196 if [ "$WITHOUT_WIN32" = "1" ] ; then
199 grep CONFOPT_WIN32
${MPDM}/config.h
>/dev
/null
202 echo "-mwindows -lcomctl32" >> config.ldflags
203 echo "#define CONFOPT_WIN32 1" >> config.h
205 DRIVERS
="win32 $DRIVERS"
206 DRV_OBJS
="mpv_win32.o $DRV_OBJS"
218 # test for curses / ncurses library
219 echo -n "Testing for ncursesw... "
221 if [ "$WITHOUT_CURSES" = "1" ] ; then
224 echo "#include <ncursesw/ncurses.h>" > .tmp.c
225 echo "int main(void) { initscr(); endwin(); return 0; }" >> .tmp.c
227 TMP_CFLAGS
="-I/usr/local/include"
228 TMP_LDFLAGS
="-L/usr/local/lib -lncursesw"
230 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
232 echo "#define CONFOPT_CURSES 1" >> config.h
233 echo $TMP_CFLAGS >> config.cflags
234 echo $TMP_LDFLAGS >> config.ldflags
236 DRIVERS
="ncursesw $DRIVERS"
237 DRV_OBJS
="mpv_curses.o $DRV_OBJS"
244 if [ "$WITHOUT_CURSES" != "1" ] ; then
245 # test for transparent colors in curses
246 echo -n "Testing for transparency support in curses... "
248 echo "#include <ncursesw/ncurses.h>" > .tmp.c
249 echo "int main(void) { initscr(); use_default_colors(); endwin(); return 0; }" >> .tmp.c
251 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
253 echo "#define CONFOPT_TRANSPARENCY 1" >> config.h
259 # test now for wget_wch() existence
260 echo -n "Testing for wget_wch()... "
262 echo "#include <wchar.h>" > .tmp.c
263 echo "#include <ncursesw/ncurses.h>" >> .tmp.c
264 echo "int main(void) { wchar_t c[2]; initscr(); wget_wch(stdscr, c); endwin(); return 0; }" >> .tmp.c
266 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
268 echo "#define CONFOPT_WGET_WCH 1" >> config.h
277 echo -n "Testing for KDE4... "
278 if [ "$WITHOUT_KDE4" = "1" ] ; then
281 if which kde4-config
> /dev
/null
2>&1
283 TMP_CFLAGS
=$
(pkg-config
--cflags QtCore
)
284 TMP_CFLAGS
="$TMP_CFLAGS -I`kde4-config --install include` -I`kde4-config --install include`KDE"
286 TMP_LDFLAGS
=$
(pkg-config
--libs QtCore
)
287 TMP_LDFLAGS
="$TMP_LDFLAGS -L`kde4-config --install lib` -lkfile -lkdeui -lkdecore"
289 echo "#include <KApplication>" > .tmp.cpp
290 echo "int main(void) { new KApplication() ; return 0; } " >> .tmp.cpp
292 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
293 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
296 echo $TMP_CFLAGS >> config.cflags
297 echo $TMP_LDFLAGS >> config.ldflags
299 echo "#define CONFOPT_KDE4 1" >> config.h
302 DRIVERS
="kde4 $DRIVERS"
303 DRV_OBJS
="mpv_kde4.o $DRV_OBJS"
304 if [ "$CCLINK" = "" ] ; then
320 echo -n "Testing for Qt4... "
321 if [ "$WITHOUT_QT4" = "1" ] ; then
324 if which pkg-config
> /dev
/null
2>&1
326 TMP_CFLAGS
=$
(pkg-config
--cflags QtGui
)
327 TMP_LDFLAGS
="$(pkg-config --libs QtGui) -lX11"
329 echo "#include <QtGui>" > .tmp.cpp
330 echo "int main(int argc, char *argv[]) { new QApplication(argc, argv) ; return 0; } " >> .tmp.cpp
332 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
333 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
336 echo $TMP_CFLAGS >> config.cflags
337 echo $TMP_LDFLAGS >> config.ldflags
339 echo "#define CONFOPT_QT4 1" >> config.h
342 DRIVERS
="qt4 $DRIVERS"
343 DRV_OBJS
="mpv_qt4.o $DRV_OBJS"
344 if [ "$CCLINK" = "" ] ; then
358 echo -n "Testing for GTK... "
360 if [ "$WITHOUT_GTK" = "1" ] ; then
363 echo "#include <gtk/gtk.h>" > .tmp.c
364 echo "#include <gdk/gdkkeysyms.h>" >> .tmp.c
365 echo "int main(void) { gtk_main(); return 0; } " >> .tmp.c
368 TMP_CFLAGS
=`sh -c 'pkg-config --cflags gtk+-3.0' 2>/dev/null`
369 TMP_LDFLAGS
=`sh -c 'pkg-config --libs gtk+-3.0' 2>/dev/null`
371 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
373 echo "#define CONFOPT_GTK 3" >> config.h
374 echo "$TMP_CFLAGS " >> config.cflags
375 echo "$TMP_LDFLAGS " >> config.ldflags
377 DRIVERS
="gtk $DRIVERS"
378 DRV_OBJS
="mpv_gtk.o $DRV_OBJS"
381 TMP_CFLAGS
=`sh -c 'pkg-config --cflags gtk+-2.0' 2>/dev/null`
382 TMP_LDFLAGS
=`sh -c 'pkg-config --libs gtk+-2.0' 2>/dev/null`
384 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
386 echo "#define CONFOPT_GTK 2" >> config.h
387 echo "$TMP_CFLAGS " >> config.cflags
388 echo "$TMP_LDFLAGS " >> config.ldflags
390 DRIVERS
="gtk $DRIVERS"
391 DRV_OBJS
="mpv_gtk.o $DRV_OBJS"
399 echo -n "Testing for msgfmt... "
401 if which msgfmt
> /dev
/null
2>&1 ; then
403 echo "BUILDMO=build-mo" >> makefile.opts
404 echo "INSTALLMO=install-mo" >> makefile.opts
405 echo "UNINSTALLMO=uninstall-mo" >> makefile.opts
408 echo "BUILDMO=" >> makefile.opts
409 echo "INSTALLMO=" >> makefile.opts
410 echo "UNINSTALLMO=" >> makefile.opts
413 if [ "$CCLINK" = "" ] ; then
419 grep DOCS
$MPDM/makefile.opts
>> makefile.opts
420 echo "VERSION=$VERSION" >> makefile.opts
421 echo "WINDRES=$WINDRES" >> makefile.opts
422 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
423 echo "APPNAME=$APPNAME" >> makefile.opts
424 echo "DRV_OBJS=$DRV_OBJS" >> makefile.opts
425 echo "CCLINK=$CCLINK" >> makefile.opts
426 echo >> makefile.opts
428 cat makefile.opts makefile.
in makefile.depend
> Makefile
430 ##############################################
432 if [ "$DRIVERS" = "" ] ; then
435 echo "*ERROR* No usable drivers (interfaces) found"
436 echo "See the README file for the available options."
442 echo "Configured drivers:" $DRIVERS
444 echo "Type 'make' to build Minimum Profit."
446 # insert driver detection code into config.h
448 TRY_DRIVERS
="#define TRY_DRIVERS() ("
450 for drv
in $DRIVERS ; do
451 echo "int ${drv}_drv_detect(int * argc, char *** argv);" >> config.h
452 TRY_DRIVERS
="$TRY_DRIVERS ${drv}_drv_detect(&argc, &argv) || "
456 echo $TRY_DRIVERS '0)' >> config.h
459 rm -f .tmp.c .tmp.cpp .tmp.o