Revert bs-a and bs-b patch.
[mpsl.git] / config.sh
blob96948078b0defdce47192ed2fcbb0b4a9a474be7
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 2>&1
82 if [ $? = 0 ] ; then
83 CC=gcc
87 echo "CC=$CC" >> makefile.opts
89 # set archiver
90 if [ "$AR" = "" ] ; then
91 AR=ar
94 echo "AR=$AR" >> makefile.opts
96 # set parser
97 if [ "$YACC" = "" ] ; then
98 YACC=yacc
101 echo "YACC=$YACC" >> makefile.opts
103 # add version
104 cat VERSION >> config.h
106 # add installation prefix
107 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
109 #########################################################
111 # configuration directives
113 # CFLAGS
114 if [ -z "$CFLAGS" ] ; then
115 CFLAGS="-g -Wall"
118 echo -n "Testing if C compiler supports ${CFLAGS}... "
119 echo "int main(int argc, char *argv[]) { return 0; }" > .tmp.c
121 $CC .tmp.c -o .tmp.o 2>> .config.log
123 if [ $? = 0 ] ; then
124 echo "OK"
125 else
126 echo "No; resetting to defaults"
127 CFLAGS=""
130 echo "CFLAGS=$CFLAGS" >> makefile.opts
132 # Add CFLAGS to CC
133 CC="$CC $CFLAGS"
135 # MPDM
136 echo -n "Looking for MPDM... "
138 for MPDM in ./mpdm ../mpdm NOTFOUND ; do
139 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h ] ; then
140 break
142 done
144 if [ "$MPDM" != "NOTFOUND" ] ; then
145 echo "-I$MPDM" >> config.cflags
146 echo "-L$MPDM -lmpdm" >> config.ldflags
147 echo "OK ($MPDM)"
148 else
149 echo "No"
150 exit 1
153 # If MPDM is not configured, do it
154 if [ ! -f $MPDM/Makefile ] ; then
155 ( echo ; cd $MPDM ; ./config.sh $CONF_ARGS ; echo )
158 cat $MPDM/config.ldflags >> config.ldflags
159 echo "-lm" >> config.ldflags
161 # if win32, the interpreter is called mpsl.exe
162 grep CONFOPT_WIN32 ${MPDM}/config.h >/dev/null && TARGET=mpsl.exe
164 #########################################################
166 # final setup
168 echo "MPDM=$MPDM" >> makefile.opts
169 grep DOCS $MPDM/makefile.opts >> makefile.opts
170 echo "VERSION=$VERSION" >> makefile.opts
171 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
172 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
173 echo "TARGET=$TARGET" >> makefile.opts
174 echo >> makefile.opts
176 cat makefile.opts makefile.in makefile.depend > Makefile
178 #########################################################
180 # cleanup
182 rm -f .tmp.c .tmp.o
184 exit 0