3 # Minimum Profit autoconfiguration script
10 VERSION
=`cut -f2 -d\" VERSION`
12 # default installation prefix
15 # store command line args for configuring the libraries
19 while [ $# -gt 0 ] ; do
22 --without-curses) WITHOUT_CURSES
=1 ;;
23 --without-gtk) WITHOUT_GTK
=1 ;;
24 --without-win32) WITHOUT_WIN32
=1 ;;
25 --without-kde4) WITHOUT_KDE4
=1 ;;
26 --help) CONFIG_HELP
=1 ;;
28 --mingw32) CC
=i586-mingw32msvc-cc
29 WINDRES
=i586-mingw32msvc-windres
30 AR
=i586-mingw32msvc-ar
34 --debian) BUILD_FOR_DEBIAN
=1
39 --prefix) PREFIX
=$2 ; shift ;;
40 --prefix=*) PREFIX
=`echo $1 | sed -e 's/--prefix=//'` ;;
46 if [ "$CONFIG_HELP" = "1" ] ; then
48 echo "Available options:"
49 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
50 echo "--without-curses Disable curses (text) interface detection."
51 echo "--without-gtk Disable GTK interface detection."
52 echo "--without-win32 Disable win32 interface detection."
53 echo "--without-kde4 Disable KDE4 interface detection."
54 echo "--without-unix-glob Disable glob.h usage (use workaround)."
55 echo "--with-included-regex Use included regex code (gnu_regex.c)."
56 echo "--with-pcre Enable PCRE library detection."
57 echo "--without-gettext Disable gettext usage."
58 echo "--without-iconv Disable iconv usage."
59 echo "--without-wcwidth Disable system wcwidth() (use workaround)."
60 echo "--with-null-hash Tell MPDM to use a NULL hashing function."
61 echo "--mingw32 Build using the mingw32 compiler."
62 echo "--debian Build for Debian ('make deb')."
65 echo "Environment variables:"
67 echo "AR Library Archiver."
68 echo "CFLAGS Compile flags (i.e., -O3)."
69 echo "WINDRES MS Windows resource compiler."
76 echo "/* automatically created by config.sh - do not modify */" > config.h
77 echo "# automatically created by config.sh - do not modify" > makefile.opts
83 if [ "$CC" = "" ] ; then
85 # if CC is unset, try if gcc is available
86 which gcc
> /dev
/null
&& CC
=gcc
89 if [ "$CPP" = "" ] ; then
91 # if CC is unset, try if gcc is available
92 which g
++ > /dev
/null
&& CPP
=g
++
96 which moc-qt4
> /dev
/null
&& MOC
=moc-qt4
98 echo "CC=$CC" >> makefile.opts
99 echo "CPP=$CPP" >> makefile.opts
100 echo "MOC=$MOC" >> makefile.opts
103 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
107 echo "CFLAGS=$CFLAGS" >> makefile.opts
113 cat VERSION
>> config.h
115 # add installation prefix and application name
116 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
117 echo "#define CONFOPT_APPNAME \"$APPNAME\"" >> config.h
119 ################################################################
122 echo -n "Looking for MPDM... "
124 for MPDM
in .
/mpdm ..
/mpdm NOTFOUND
; do
125 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h
] ; then
130 if [ "$MPDM" != "NOTFOUND" ] ; then
131 echo "-I$MPDM" >> config.cflags
132 echo "-L$MPDM -lmpdm" >> config.ldflags
139 # If MPDM is not configured, do it
140 if [ ! -f $MPDM/Makefile
] ; then
141 ( echo ; cd $MPDM ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
144 cat $MPDM/config.ldflags
>> config.ldflags
145 echo "MPDM=$MPDM" >> makefile.opts
148 echo -n "Looking for MPSL... "
150 for MPSL
in .
/mpsl ..
/mpsl NOTFOUND
; do
151 if [ -d $MPSL ] && [ -f $MPSL/mpsl.h
] ; then
156 if [ "$MPSL" != "NOTFOUND" ] ; then
157 echo "-I$MPSL" >> config.cflags
158 echo "-L$MPSL -lmpsl" >> config.ldflags
165 # If MPSL is not configured, do it
166 if [ ! -f $MPSL/Makefile
] ; then
167 ( echo ; cd $MPSL ; .
/config.sh
--prefix=$PREFIX --docdir=$PREFIX/share
/doc
/$APPNAME $CONF_ARGS ; echo )
170 cat $MPSL/config.ldflags
>> config.ldflags
171 echo "MPSL=$MPSL" >> makefile.opts
175 echo -n "Testing for win32... "
176 if [ "$WITHOUT_WIN32" = "1" ] ; then
179 grep CONFOPT_WIN32
${MPDM}/config.h
>/dev
/null
182 echo "-mwindows -lcomctl32" >> config.ldflags
183 echo "#define CONFOPT_WIN32 1" >> config.h
185 DRIVERS
="win32 $DRIVERS"
186 DRV_OBJS
="mpv_win32.o $DRV_OBJS"
197 # test for curses / ncurses library
198 echo -n "Testing for ncursesw... "
200 if [ "$WITHOUT_CURSES" = "1" ] ; then
203 echo "#include <curses.h>" > .tmp.c
204 echo "int main(void) { initscr(); endwin(); return 0; }" >> .tmp.c
206 TMP_CFLAGS
="-I/usr/local/include"
207 TMP_LDFLAGS
="-L/usr/local/lib -lncursesw"
209 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
211 echo "#define CONFOPT_CURSES 1" >> config.h
212 echo $TMP_CFLAGS >> config.cflags
213 echo $TMP_LDFLAGS >> config.ldflags
215 DRIVERS
="ncursesw $DRIVERS"
216 DRV_OBJS
="mpv_curses.o $DRV_OBJS"
223 if [ "$WITHOUT_CURSES" != "1" ] ; then
224 # test for transparent colors in curses
225 echo -n "Testing for transparency support in curses... "
227 echo "#include <curses.h>" > .tmp.c
228 echo "int main(void) { initscr(); use_default_colors(); endwin(); return 0; }" >> .tmp.c
230 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
232 echo "#define CONFOPT_TRANSPARENCY 1" >> config.h
238 # test now for wget_wch() existence
239 echo -n "Testing for wget_wch()... "
241 echo "#include <wchar.h>" > .tmp.c
242 echo "#include <curses.h>" >> .tmp.c
243 echo "int main(void) { wchar_t c[2]; initscr(); wget_wch(stdscr, c); endwin(); return 0; }" >> .tmp.c
245 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
247 echo "#define CONFOPT_WGET_WCH 1" >> config.h
256 echo -n "Testing for KDE4... "
257 if [ "$WITHOUT_KDE4" = "1" ] ; then
260 if which kde4-config
> /dev
/null
262 TMP_CFLAGS
=$
(pkg-config
--cflags QtCore
)
263 TMP_CFLAGS
="$TMP_CFLAGS -I`kde4-config --install include`KDE"
265 TMP_LDFLAGS
=$
(pkg-config
--libs QtCore
)
266 TMP_LDFLAGS
="$TMP_LDFLAGS -L`kde4-config --install lib` -lkfile -lkdeui -lkdecore"
268 echo "#include <KApplication>" > .tmp.cpp
269 echo "int main(void) { new KApplication() ; return 0; } " >> .tmp.cpp
271 echo "$CPP $TMP_CFLAGS .tmp.cpp $TMP_LDFLAGS -o .tmp.o" >> .config.log
272 $CPP $TMP_CFLAGS .tmp.cpp
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
275 echo $TMP_CFLAGS >> config.cflags
276 echo $TMP_LDFLAGS >> config.ldflags
278 echo "#define CONFOPT_KDE4 1" >> config.h
281 DRIVERS
="kde4 $DRIVERS"
282 DRV_OBJS
="mpv_kde4.o $DRV_OBJS"
283 if [ "$CCLINK" = "" ] ; then
297 echo -n "Testing for GTK... "
299 if [ "$WITHOUT_GTK" = "1" ] ; then
302 echo "#include <gtk/gtk.h>" > .tmp.c
303 echo "#include <gdk/gdkkeysyms.h>" >> .tmp.c
304 echo "int main(void) { gtk_main(); return 0; } " >> .tmp.c
307 TMP_CFLAGS
=`sh -c 'pkg-config --cflags gtk+-2.0' 2>/dev/null`
308 TMP_LDFLAGS
=`sh -c 'pkg-config --libs gtk+-2.0' 2>/dev/null`
310 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
312 echo "#define CONFOPT_GTK 2" >> config.h
313 echo "$TMP_CFLAGS " >> config.cflags
314 echo "$TMP_LDFLAGS " >> config.ldflags
316 DRIVERS
="gtk $DRIVERS"
317 DRV_OBJS
="mpv_gtk.o $DRV_OBJS"
323 if [ "$CCLINK" = "" ] ; then
329 grep DOCS
$MPDM/makefile.opts
>> makefile.opts
330 echo "VERSION=$VERSION" >> makefile.opts
331 echo "WINDRES=$WINDRES" >> makefile.opts
332 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
333 echo "APPNAME=$APPNAME" >> makefile.opts
334 echo "DRV_OBJS=$DRV_OBJS" >> makefile.opts
335 echo "CCLINK=$CCLINK" >> makefile.opts
336 echo >> makefile.opts
338 cat makefile.opts makefile.
in makefile.depend
> Makefile
340 ##############################################
342 if [ "$DRIVERS" = "" ] ; then
345 echo "*ERROR* No usable drivers (interfaces) found"
346 echo "See the README file for the available options."
352 echo "Configured drivers:" $DRIVERS
354 echo "Type 'make' to build Minimum Profit."
356 # insert driver detection code into config.h
358 TRY_DRIVERS
="#define TRY_DRIVERS() ("
360 for drv
in $DRIVERS ; do
361 echo "int ${drv}_drv_detect(int * argc, char *** argv);" >> config.h
362 TRY_DRIVERS
="$TRY_DRIVERS ${drv}_drv_detect(&argc, &argv) || "
366 echo $TRY_DRIVERS '0)' >> config.h
369 rm -f .tmp.c .tmp.cpp .tmp.o