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"
22 while [ $# -gt 0 ] ; do
25 --without-curses) WITHOUT_CURSES
=1 ;;
26 --without-gtk) WITHOUT_GTK
=1 ;;
27 --without-win32) WITHOUT_WIN32
=1 ;;
28 --without-kde4) WITHOUT_KDE4
=1 ;;
29 --without-qt4) WITHOUT_QT4
=1 ;;
30 --help) CONFIG_HELP
=1 ;;
32 --mingw32) CC
=i586-mingw32msvc-cc
33 WINDRES
=i586-mingw32msvc-windres
34 AR
=i586-mingw32msvc-ar
38 --debian) BUILD_FOR_DEBIAN
=1
43 --prefix) PREFIX
=$2 ; shift ;;
44 --prefix=*) PREFIX
=`echo $1 | sed -e 's/--prefix=//'` ;;
50 if [ "$CONFIG_HELP" = "1" ] ; then
52 echo "Available options:"
53 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
54 echo "--without-curses Disable curses (text) interface detection."
55 echo "--without-gtk Disable GTK interface detection."
56 echo "--without-win32 Disable win32 interface detection."
57 echo "--without-kde4 Disable KDE4 interface detection."
58 echo "--without-qt4 Disable Qt4 interface detection."
59 echo "--without-unix-glob Disable glob.h usage (use workaround)."
60 echo "--with-included-regex Use included regex code (gnu_regex.c)."
61 echo "--with-pcre Enable PCRE library detection."
62 echo "--without-gettext Disable gettext usage."
63 echo "--without-iconv Disable iconv usage."
64 echo "--without-wcwidth Disable system wcwidth() (use workaround)."
65 echo "--with-null-hash Tell MPDM to use a NULL hashing function."
66 echo "--mingw32 Build using the mingw32 compiler."
67 echo "--debian Build for Debian ('make deb')."
70 echo "Environment variables:"
72 echo "AR Library Archiver."
73 echo "CFLAGS Compile flags (i.e., -O3)."
74 echo "WINDRES MS Windows resource compiler."
81 echo "/* automatically created by config.sh - do not modify */" > config.h
82 echo "# automatically created by config.sh - do not modify" > makefile.opts
88 if [ "$CC" = "" ] ; then
90 # if CC is unset, try if gcc is available
91 which gcc
> /dev
/null
&& CC
=gcc
94 if [ "$CPP" = "" ] ; then
96 # if CC is unset, try if gcc is available
97 which g
++ > /dev
/null
&& CPP
=g
++
101 which moc-qt4
> /dev
/null
&& MOC
=moc-qt4
103 echo "CC=$CC" >> makefile.opts
104 echo "CPP=$CPP" >> makefile.opts
105 echo "MOC=$MOC" >> makefile.opts
108 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
112 echo "CFLAGS=$CFLAGS" >> makefile.opts
118 cat VERSION
>> config.h
120 # add installation prefix and application name
121 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
122 echo "#define CONFOPT_APPNAME \"$APPNAME\"" >> config.h
124 ################################################################
127 echo -n "Looking for MPDM... "
129 for MPDM
in .
/mpdm ..
/mpdm NOTFOUND
; do
130 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h
] ; then
135 if [ "$MPDM" != "NOTFOUND" ] ; then
136 echo "-I$MPDM" >> config.cflags
137 echo "-L$MPDM -lmpdm" >> config.ldflags
144 # If MPDM is not configured, do it
145 if [ ! -f $MPDM/Makefile
] ; then
146 ( echo ; cd $MPDM ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
149 cat $MPDM/config.ldflags
>> config.ldflags
150 echo "MPDM=$MPDM" >> makefile.opts
153 echo -n "Looking for MPSL... "
155 for MPSL
in .
/mpsl ..
/mpsl NOTFOUND
; do
156 if [ -d $MPSL ] && [ -f $MPSL/mpsl.h
] ; then
161 if [ "$MPSL" != "NOTFOUND" ] ; then
162 echo "-I$MPSL" >> config.cflags
163 echo "-L$MPSL -lmpsl" >> config.ldflags
170 # If MPSL is not configured, do it
171 if [ ! -f $MPSL/Makefile
] ; then
172 ( echo ; cd $MPSL ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
175 cat $MPSL/config.ldflags
>> config.ldflags
176 echo "MPSL=$MPSL" >> makefile.opts
180 echo -n "Testing for win32... "
181 if [ "$WITHOUT_WIN32" = "1" ] ; then
184 grep CONFOPT_WIN32
${MPDM}/config.h
>/dev
/null
187 echo "-mwindows -lcomctl32" >> config.ldflags
188 echo "#define CONFOPT_WIN32 1" >> config.h
190 DRIVERS
="win32 $DRIVERS"
191 DRV_OBJS
="mpv_win32.o $DRV_OBJS"
202 # test for curses / ncurses library
203 echo -n "Testing for ncursesw... "
205 if [ "$WITHOUT_CURSES" = "1" ] ; then
208 echo "#include <ncursesw/ncurses.h>" > .tmp.c
209 echo "int main(void) { initscr(); endwin(); return 0; }" >> .tmp.c
211 TMP_CFLAGS
="-I/usr/local/include"
212 TMP_LDFLAGS
="-L/usr/local/lib -lncursesw"
214 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
216 echo "#define CONFOPT_CURSES 1" >> config.h
217 echo $TMP_CFLAGS >> config.cflags
218 echo $TMP_LDFLAGS >> config.ldflags
220 DRIVERS
="ncursesw $DRIVERS"
221 DRV_OBJS
="mpv_curses.o $DRV_OBJS"
228 if [ "$WITHOUT_CURSES" != "1" ] ; then
229 # test for transparent colors in curses
230 echo -n "Testing for transparency support in curses... "
232 echo "#include <ncursesw/ncurses.h>" > .tmp.c
233 echo "int main(void) { initscr(); use_default_colors(); endwin(); return 0; }" >> .tmp.c
235 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
237 echo "#define CONFOPT_TRANSPARENCY 1" >> config.h
243 # test now for wget_wch() existence
244 echo -n "Testing for wget_wch()... "
246 echo "#include <wchar.h>" > .tmp.c
247 echo "#include <ncursesw/ncurses.h>" >> .tmp.c
248 echo "int main(void) { wchar_t c[2]; initscr(); wget_wch(stdscr, c); endwin(); return 0; }" >> .tmp.c
250 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
252 echo "#define CONFOPT_WGET_WCH 1" >> config.h
261 echo -n "Testing for KDE4... "
262 if [ "$WITHOUT_KDE4" = "1" ] ; then
265 if which kde4-config
> /dev
/null
267 TMP_CFLAGS
=$
(pkg-config
--cflags QtCore
)
268 TMP_CFLAGS
="$TMP_CFLAGS -I`kde4-config --install include` -I`kde4-config --install include`KDE"
270 TMP_LDFLAGS
=$
(pkg-config
--libs QtCore
)
271 TMP_LDFLAGS
="$TMP_LDFLAGS -L`kde4-config --install lib` -lkfile -lkdeui -lkdecore"
273 echo "#include <KApplication>" > .tmp.cpp
274 echo "int main(void) { new KApplication() ; return 0; } " >> .tmp.cpp
276 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
277 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
280 echo $TMP_CFLAGS >> config.cflags
281 echo $TMP_LDFLAGS >> config.ldflags
283 echo "#define CONFOPT_KDE4 1" >> config.h
286 DRIVERS
="kde4 $DRIVERS"
287 DRV_OBJS
="mpv_kde4.o $DRV_OBJS"
288 if [ "$CCLINK" = "" ] ; then
303 echo -n "Testing for Qt4... "
304 if [ "$WITHOUT_QT4" = "1" ] ; then
307 if which pkg-config
> /dev
/null
309 TMP_CFLAGS
=$
(pkg-config
--cflags QtGui
)
310 TMP_LDFLAGS
=$
(pkg-config
--libs QtGui
)
312 echo "#include <QtGui>" > .tmp.cpp
313 echo "int main(int argc, char *argv[]) { new QApplication(argc, argv) ; return 0; } " >> .tmp.cpp
315 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
316 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
319 echo $TMP_CFLAGS >> config.cflags
320 echo $TMP_LDFLAGS >> config.ldflags
322 echo "#define CONFOPT_KDE4 1" >> config.h
325 DRIVERS
="qt4 $DRIVERS"
326 DRV_OBJS
="mpv_qt4.o $DRV_OBJS"
327 if [ "$CCLINK" = "" ] ; then
341 echo -n "Testing for GTK... "
343 if [ "$WITHOUT_GTK" = "1" ] ; then
346 echo "#include <gtk/gtk.h>" > .tmp.c
347 echo "#include <gdk/gdkkeysyms.h>" >> .tmp.c
348 echo "int main(void) { gtk_main(); return 0; } " >> .tmp.c
351 TMP_CFLAGS
=`sh -c 'pkg-config --cflags gtk+-2.0' 2>/dev/null`
352 TMP_LDFLAGS
=`sh -c 'pkg-config --libs gtk+-2.0' 2>/dev/null`
354 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
356 echo "#define CONFOPT_GTK 2" >> config.h
357 echo "$TMP_CFLAGS " >> config.cflags
358 echo "$TMP_LDFLAGS " >> config.ldflags
360 DRIVERS
="gtk $DRIVERS"
361 DRV_OBJS
="mpv_gtk.o $DRV_OBJS"
367 if [ "$CCLINK" = "" ] ; then
373 grep DOCS
$MPDM/makefile.opts
>> makefile.opts
374 echo "VERSION=$VERSION" >> makefile.opts
375 echo "WINDRES=$WINDRES" >> makefile.opts
376 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
377 echo "APPNAME=$APPNAME" >> makefile.opts
378 echo "DRV_OBJS=$DRV_OBJS" >> makefile.opts
379 echo "CCLINK=$CCLINK" >> makefile.opts
380 echo >> makefile.opts
382 cat makefile.opts makefile.
in makefile.depend
> Makefile
384 ##############################################
386 if [ "$DRIVERS" = "" ] ; then
389 echo "*ERROR* No usable drivers (interfaces) found"
390 echo "See the README file for the available options."
396 echo "Configured drivers:" $DRIVERS
398 echo "Type 'make' to build Minimum Profit."
400 # insert driver detection code into config.h
402 TRY_DRIVERS
="#define TRY_DRIVERS() ("
404 for drv
in $DRIVERS ; do
405 echo "int ${drv}_drv_detect(int * argc, char *** argv);" >> config.h
406 TRY_DRIVERS
="$TRY_DRIVERS ${drv}_drv_detect(&argc, &argv) || "
410 echo $TRY_DRIVERS '0)' >> config.h
413 rm -f .tmp.c .tmp.cpp .tmp.o