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 --help) CONFIG_HELP
=1 ;;
31 --mingw32) CC
=i586-mingw32msvc-cc
32 WINDRES
=i586-mingw32msvc-windres
33 AR
=i586-mingw32msvc-ar
37 --debian) BUILD_FOR_DEBIAN
=1
42 --prefix) PREFIX
=$2 ; shift ;;
43 --prefix=*) PREFIX
=`echo $1 | sed -e 's/--prefix=//'` ;;
49 if [ "$CONFIG_HELP" = "1" ] ; then
51 echo "Available options:"
52 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
53 echo "--without-curses Disable curses (text) interface detection."
54 echo "--without-gtk Disable GTK interface detection."
55 echo "--without-win32 Disable win32 interface detection."
56 echo "--without-kde4 Disable KDE4 interface detection."
57 echo "--without-unix-glob Disable glob.h usage (use workaround)."
58 echo "--with-included-regex Use included regex code (gnu_regex.c)."
59 echo "--with-pcre Enable PCRE library detection."
60 echo "--without-gettext Disable gettext usage."
61 echo "--without-iconv Disable iconv usage."
62 echo "--without-wcwidth Disable system wcwidth() (use workaround)."
63 echo "--with-null-hash Tell MPDM to use a NULL hashing function."
64 echo "--mingw32 Build using the mingw32 compiler."
65 echo "--debian Build for Debian ('make deb')."
68 echo "Environment variables:"
70 echo "AR Library Archiver."
71 echo "CFLAGS Compile flags (i.e., -O3)."
72 echo "WINDRES MS Windows resource compiler."
79 echo "/* automatically created by config.sh - do not modify */" > config.h
80 echo "# automatically created by config.sh - do not modify" > makefile.opts
86 if [ "$CC" = "" ] ; then
88 # if CC is unset, try if gcc is available
89 which gcc
> /dev
/null
&& CC
=gcc
92 if [ "$CPP" = "" ] ; then
94 # if CC is unset, try if gcc is available
95 which g
++ > /dev
/null
&& CPP
=g
++
99 which moc-qt4
> /dev
/null
&& MOC
=moc-qt4
101 echo "CC=$CC" >> makefile.opts
102 echo "CPP=$CPP" >> makefile.opts
103 echo "MOC=$MOC" >> makefile.opts
106 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
110 echo "CFLAGS=$CFLAGS" >> makefile.opts
116 cat VERSION
>> config.h
118 # add installation prefix and application name
119 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
120 echo "#define CONFOPT_APPNAME \"$APPNAME\"" >> config.h
122 ################################################################
125 echo -n "Looking for MPDM... "
127 for MPDM
in .
/mpdm ..
/mpdm NOTFOUND
; do
128 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h
] ; then
133 if [ "$MPDM" != "NOTFOUND" ] ; then
134 echo "-I$MPDM" >> config.cflags
135 echo "-L$MPDM -lmpdm" >> config.ldflags
142 # If MPDM is not configured, do it
143 if [ ! -f $MPDM/Makefile
] ; then
144 ( echo ; cd $MPDM ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
147 cat $MPDM/config.ldflags
>> config.ldflags
148 echo "MPDM=$MPDM" >> makefile.opts
151 echo -n "Looking for MPSL... "
153 for MPSL
in .
/mpsl ..
/mpsl NOTFOUND
; do
154 if [ -d $MPSL ] && [ -f $MPSL/mpsl.h
] ; then
159 if [ "$MPSL" != "NOTFOUND" ] ; then
160 echo "-I$MPSL" >> config.cflags
161 echo "-L$MPSL -lmpsl" >> config.ldflags
168 # If MPSL is not configured, do it
169 if [ ! -f $MPSL/Makefile
] ; then
170 ( echo ; cd $MPSL ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
173 cat $MPSL/config.ldflags
>> config.ldflags
174 echo "MPSL=$MPSL" >> makefile.opts
178 echo -n "Testing for win32... "
179 if [ "$WITHOUT_WIN32" = "1" ] ; then
182 grep CONFOPT_WIN32
${MPDM}/config.h
>/dev
/null
185 echo "-mwindows -lcomctl32" >> config.ldflags
186 echo "#define CONFOPT_WIN32 1" >> config.h
188 DRIVERS
="win32 $DRIVERS"
189 DRV_OBJS
="mpv_win32.o $DRV_OBJS"
200 # test for curses / ncurses library
201 echo -n "Testing for ncursesw... "
203 if [ "$WITHOUT_CURSES" = "1" ] ; then
206 echo "#include <ncursesw/ncurses.h>" > .tmp.c
207 echo "int main(void) { initscr(); endwin(); return 0; }" >> .tmp.c
209 TMP_CFLAGS
="-I/usr/local/include"
210 TMP_LDFLAGS
="-L/usr/local/lib -lncursesw"
212 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
214 echo "#define CONFOPT_CURSES 1" >> config.h
215 echo $TMP_CFLAGS >> config.cflags
216 echo $TMP_LDFLAGS >> config.ldflags
218 DRIVERS
="ncursesw $DRIVERS"
219 DRV_OBJS
="mpv_curses.o $DRV_OBJS"
226 if [ "$WITHOUT_CURSES" != "1" ] ; then
227 # test for transparent colors in curses
228 echo -n "Testing for transparency support in curses... "
230 echo "#include <ncursesw/ncurses.h>" > .tmp.c
231 echo "int main(void) { initscr(); use_default_colors(); endwin(); return 0; }" >> .tmp.c
233 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
235 echo "#define CONFOPT_TRANSPARENCY 1" >> config.h
241 # test now for wget_wch() existence
242 echo -n "Testing for wget_wch()... "
244 echo "#include <wchar.h>" > .tmp.c
245 echo "#include <ncursesw/ncurses.h>" >> .tmp.c
246 echo "int main(void) { wchar_t c[2]; initscr(); wget_wch(stdscr, c); endwin(); return 0; }" >> .tmp.c
248 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
250 echo "#define CONFOPT_WGET_WCH 1" >> config.h
259 echo -n "Testing for KDE4... "
260 if [ "$WITHOUT_KDE4" = "1" ] ; then
263 if which kde4-config
> /dev
/null
265 TMP_CFLAGS
=$
(pkg-config
--cflags QtCore
)
266 TMP_CFLAGS
="$TMP_CFLAGS -I`kde4-config --install include` -I`kde4-config --install include`KDE"
268 TMP_LDFLAGS
=$
(pkg-config
--libs QtCore
)
269 TMP_LDFLAGS
="$TMP_LDFLAGS -L`kde4-config --install lib` -lkfile -lkdeui -lkdecore"
271 echo "#include <KApplication>" > .tmp.cpp
272 echo "int main(void) { new KApplication() ; return 0; } " >> .tmp.cpp
274 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
275 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
278 echo $TMP_CFLAGS >> config.cflags
279 echo $TMP_LDFLAGS >> config.ldflags
281 echo "#define CONFOPT_KDE4 1" >> config.h
284 DRIVERS
="kde4 $DRIVERS"
285 DRV_OBJS
="mpv_kde4.o $DRV_OBJS"
286 if [ "$CCLINK" = "" ] ; then
300 echo -n "Testing for GTK... "
302 if [ "$WITHOUT_GTK" = "1" ] ; then
305 echo "#include <gtk/gtk.h>" > .tmp.c
306 echo "#include <gdk/gdkkeysyms.h>" >> .tmp.c
307 echo "int main(void) { gtk_main(); return 0; } " >> .tmp.c
310 TMP_CFLAGS
=`sh -c 'pkg-config --cflags gtk+-2.0' 2>/dev/null`
311 TMP_LDFLAGS
=`sh -c 'pkg-config --libs gtk+-2.0' 2>/dev/null`
313 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
315 echo "#define CONFOPT_GTK 2" >> config.h
316 echo "$TMP_CFLAGS " >> config.cflags
317 echo "$TMP_LDFLAGS " >> config.ldflags
319 DRIVERS
="gtk $DRIVERS"
320 DRV_OBJS
="mpv_gtk.o $DRV_OBJS"
326 if [ "$CCLINK" = "" ] ; then
332 grep DOCS
$MPDM/makefile.opts
>> makefile.opts
333 echo "VERSION=$VERSION" >> makefile.opts
334 echo "WINDRES=$WINDRES" >> makefile.opts
335 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
336 echo "APPNAME=$APPNAME" >> makefile.opts
337 echo "DRV_OBJS=$DRV_OBJS" >> makefile.opts
338 echo "CCLINK=$CCLINK" >> makefile.opts
339 echo >> makefile.opts
341 cat makefile.opts makefile.
in makefile.depend
> Makefile
343 ##############################################
345 if [ "$DRIVERS" = "" ] ; then
348 echo "*ERROR* No usable drivers (interfaces) found"
349 echo "See the README file for the available options."
355 echo "Configured drivers:" $DRIVERS
357 echo "Type 'make' to build Minimum Profit."
359 # insert driver detection code into config.h
361 TRY_DRIVERS
="#define TRY_DRIVERS() ("
363 for drv
in $DRIVERS ; do
364 echo "int ${drv}_drv_detect(int * argc, char *** argv);" >> config.h
365 TRY_DRIVERS
="$TRY_DRIVERS ${drv}_drv_detect(&argc, &argv) || "
369 echo $TRY_DRIVERS '0)' >> config.h
372 rm -f .tmp.c .tmp.cpp .tmp.o