New stress test for future foreach() local iterator.
[mpsl.git] / config.sh
blob4214efdd4350ac5d51dce2e63ff3db489bb46a0b
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 # parse arguments
17 while [ $# -gt 0 ] ; do
19 case $1 in
20 --without-win32) WITHOUT_WIN32=1 ;;
21 --without-unix-glob) WITHOUT_UNIX_GLOB=1 ;;
22 --with-included-regex) WITH_INCLUDED_REGEX=1 ;;
23 --with-pcre) WITH_PCRE=1 ;;
24 --without-gettext) WITHOUT_GETTEXT=1 ;;
25 --without-iconv) WITHOUT_ICONV=1 ;;
26 --without-wcwidth) WITHOUT_WCWIDTH=1 ;;
27 --help) CONFIG_HELP=1 ;;
29 --prefix) PREFIX=$2 ; shift ;;
30 --prefix=*) PREFIX=`echo $1 | sed -e 's/--prefix=//'` ;;
32 --docdir) DOCDIR=$2 ; shift ;;
33 --docdir=*) DOCDIR=`echo $1 | sed -e 's/--docdir=//'` ;;
35 esac
37 shift
38 done
40 if [ "$CONFIG_HELP" = "1" ] ; then
42 echo "Available options:"
43 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
44 echo "--docdir=DOCDIR Instalation directory for documentation."
45 echo "--without-win32 Disable win32 interface detection."
46 echo "--without-unix-glob Disable glob.h usage (use workaround)."
47 echo "--with-included-regex Use included regex code (gnu_regex.c)."
48 echo "--with-pcre Enable PCRE library detection."
49 echo "--without-gettext Disable gettext usage."
50 echo "--without-iconv Disable iconv usage."
51 echo "--without-wcwidth Disable system wcwidth() (use workaround)."
53 echo
54 echo "Environment variables:"
55 echo "CC C Compiler."
56 echo "AR Library Archiver."
57 echo "YACC Parser."
59 exit 1
62 if [ "$DOCDIR" = "" ] ; then
63 DOCDIR=$PREFIX/share/doc/mpsl
66 echo "Configuring MPSL..."
68 echo "/* automatically created by config.sh - do not modify */" > config.h
69 echo "# automatically created by config.sh - do not modify" > makefile.opts
70 > config.ldflags
71 > config.cflags
72 > .config.log
74 # set compiler
75 if [ "$CC" = "" ] ; then
76 CC=cc
77 # if CC is unset, try if gcc is available
78 which gcc > /dev/null
80 if [ $? = 0 ] ; then
81 CC=gcc
85 echo "CC=$CC" >> makefile.opts
87 # set cflags
88 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
89 CFLAGS="-g -Wall"
92 echo "CFLAGS=$CFLAGS" >> makefile.opts
94 # Add CFLAGS to CC
95 CC="$CC $CFLAGS"
97 # set archiver
98 if [ "$AR" = "" ] ; then
99 AR=ar
102 echo "AR=$AR" >> makefile.opts
104 # set parser
105 if [ "$YACC" = "" ] ; then
106 YACC=yacc
109 echo "YACC=$YACC" >> makefile.opts
111 # add version
112 cat VERSION >> config.h
114 # add installation prefix
115 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
117 #########################################################
119 # configuration directives
121 # MPDM
122 echo -n "Looking for MPDM... "
124 for MPDM in ./mpdm ../mpdm NOTFOUND ; do
125 if [ -d $MPDM ] && [ -f $MPDM/mpdm.h ] ; then
126 break
128 done
130 if [ "$MPDM" != "NOTFOUND" ] ; then
131 echo "-I$MPDM" >> config.cflags
132 echo "-L$MPDM -lmpdm" >> config.ldflags
133 echo "OK ($MPDM)"
134 else
135 echo "No"
136 exit 1
139 # If MPDM is not configured, do it
140 if [ ! -f $MPDM/Makefile ] ; then
141 CONF_ARGS="--prefix=$PREFIX"
142 [ "$WITHOUT_WIN32" = 1 ] && CONF_ARGS="$CONF_ARGS --without-win32"
143 [ "$WITHOUT_UNIX_GLOB" = 1 ] && CONF_ARGS="$CONF_ARGS --without-unix-glob"
144 [ "$WITH_INCLUDED_REGEX" = 1 ] && CONF_ARGS="$CONF_ARGS --with-included-regex"
145 [ "$WITH_PCRE" = 1 ] && CONF_ARGS="$CONF_ARGS --with-pcre"
146 [ "$WITHOUT_GETTEXT" = 1 ] && CONF_ARGS="$CONF_ARGS --without-gettext"
147 [ "$WITHOUT_ICONV" = 1 ] && CONF_ARGS="$CONF_ARGS --without-iconv"
148 [ "$WITHOUT_WCWIDTH" = 1 ] && CONF_ARGS="$CONF_ARGS --without-wcwidth"
149 ( echo ; cd $MPDM ; ./config.sh $CONF_ARGS ; echo )
152 cat $MPDM/config.ldflags >> config.ldflags
154 # if win32, the interpreter is called mpsl.exe
155 grep CONFOPT_WIN32 ${MPDM}/config.h >/dev/null && TARGET=mpsl.exe
157 #########################################################
159 # final setup
161 echo "MPDM=$MPDM" >> makefile.opts
162 echo "VERSION=$VERSION" >> makefile.opts
163 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
164 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
165 echo "TARGET=$TARGET" >> makefile.opts
166 echo >> makefile.opts
168 cat makefile.opts makefile.in makefile.depend > Makefile
170 #########################################################
172 # cleanup
174 rm -f .tmp.c .tmp.o
176 exit 0