Accept files starting with #! in mpsl_compile_file().
[mpsl.git] / config.sh
blobd3254125e3bb63a51d5c564dabe3623896d43a4d
1 #!/bin/sh
3 # Configuration shell script
5 TARGET=mpsl
7 # gets program version
8 VERSION=`cut -f2 -d\" VERSION`
10 # default installation prefix
11 PREFIX=/usr/local
13 # installation directory for documents
14 DOCDIR=""
16 # store command line args for configuring the libraries
17 CONF_ARGS="$*"
19 # parse arguments
20 while [ $# -gt 0 ] ; do
22 case $1 in
23 --help) CONFIG_HELP=1 ;;
25 --mingw32) CC=i586-mingw32msvc-cc
26 WINDRES=i586-mingw32msvc-windres
27 AR=i586-mingw32msvc-ar
30 --prefix) PREFIX=$2 ; shift ;;
31 --prefix=*) PREFIX=`echo $1 | sed -e 's/--prefix=//'` ;;
33 --docdir) DOCDIR=$2 ; shift ;;
34 --docdir=*) DOCDIR=`echo $1 | sed -e 's/--docdir=//'` ;;
36 esac
38 shift
39 done
41 if [ "$CONFIG_HELP" = "1" ] ; then
43 echo "Available options:"
44 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
45 echo "--docdir=DOCDIR Instalation directory for documentation."
46 echo "--without-win32 Disable win32 interface detection."
47 echo "--without-unix-glob Disable glob.h usage (use workaround)."
48 echo "--with-included-regex Use included regex code (gnu_regex.c)."
49 echo "--with-pcre Enable PCRE library detection."
50 echo "--without-gettext Disable gettext usage."
51 echo "--without-iconv Disable iconv usage."
52 echo "--without-wcwidth Disable system wcwidth() (use workaround)."
53 echo "--mingw32 Build using the mingw32 compiler."
55 echo
56 echo "Environment variables:"
57 echo "CC C Compiler."
58 echo "AR Library Archiver."
59 echo "YACC Parser."
61 exit 1
64 if [ "$DOCDIR" = "" ] ; then
65 DOCDIR=$PREFIX/share/doc/mpsl
68 echo "Configuring MPSL..."
70 echo "/* automatically created by config.sh - do not modify */" > config.h
71 echo "# automatically created by config.sh - do not modify" > makefile.opts
72 > config.ldflags
73 > config.cflags
74 > .config.log
76 # set compiler
77 if [ "$CC" = "" ] ; then
78 CC=cc
79 # if CC is unset, try if gcc is available
80 which gcc > /dev/null
82 if [ $? = 0 ] ; then
83 CC=gcc
87 echo "CC=$CC" >> makefile.opts
89 # set cflags
90 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
91 CFLAGS="-g -Wall"
94 echo "CFLAGS=$CFLAGS" >> makefile.opts
96 # Add CFLAGS to CC
97 CC="$CC $CFLAGS"
99 # set archiver
100 if [ "$AR" = "" ] ; then
101 AR=ar
104 echo "AR=$AR" >> makefile.opts
106 # set parser
107 if [ "$YACC" = "" ] ; then
108 YACC=yacc
111 echo "YACC=$YACC" >> makefile.opts
113 # add version
114 cat VERSION >> config.h
116 # add installation prefix
117 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
119 #########################################################
121 # configuration directives
123 # MPDM
124 echo -n "Looking for MPDM... "
126 for MPDM in ./mpdm ../mpdm NOTFOUND ; do
127 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h ] ; then
128 break
130 done
132 if [ "$MPDM" != "NOTFOUND" ] ; then
133 echo "-I$MPDM" >> config.cflags
134 echo "-L$MPDM -lmpdm" >> config.ldflags
135 echo "OK ($MPDM)"
136 else
137 echo "No"
138 exit 1
141 # If MPDM is not configured, do it
142 if [ ! -f $MPDM/Makefile ] ; then
143 ( echo ; cd $MPDM ; ./config.sh $CONF_ARGS ; echo )
146 cat $MPDM/config.ldflags >> config.ldflags
148 # if win32, the interpreter is called mpsl.exe
149 grep CONFOPT_WIN32 ${MPDM}/config.h >/dev/null && TARGET=mpsl.exe
151 #########################################################
153 # final setup
155 echo "MPDM=$MPDM" >> makefile.opts
156 grep DOCS $MPDM/makefile.opts >> makefile.opts
157 echo "VERSION=$VERSION" >> makefile.opts
158 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
159 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
160 echo "TARGET=$TARGET" >> makefile.opts
161 echo >> makefile.opts
163 cat makefile.opts makefile.in makefile.depend > Makefile
165 #########################################################
167 # cleanup
169 rm -f .tmp.c .tmp.o
171 exit 0