3 # Configuration shell script
6 VERSION
=`cut -f2 -d\" VERSION`
8 # default installation prefix
11 # installation directory for documents
15 while [ $# -gt 0 ] ; do
18 --without-win32) WITHOUT_WIN32
=1 ;;
19 --without-unix-glob) WITHOUT_UNIX_GLOB
=1 ;;
20 --with-included-regex) WITH_INCLUDED_REGEX
=1 ;;
21 --with-pcre) WITH_PCRE
=1 ;;
22 --without-gettext) WITHOUT_GETTEXT
=1 ;;
23 --without-iconv) WITHOUT_ICONV
=1 ;;
24 --without-wcwidth) WITHOUT_WCWIDTH
=1 ;;
25 --help) CONFIG_HELP
=1 ;;
27 --mingw32) CC
=i586-mingw32msvc-cc
28 WINDRES
=i586-mingw32msvc-windres
29 AR
=i586-mingw32msvc-ar
32 --prefix) PREFIX
=$2 ; shift ;;
33 --prefix=*) PREFIX
=`echo $1 | sed -e 's/--prefix=//'` ;;
35 --docdir) DOCDIR
=$2 ; shift ;;
36 --docdir=*) DOCDIR
=`echo $1 | sed -e 's/--docdir=//'` ;;
43 if [ "$CONFIG_HELP" = "1" ] ; then
45 echo "Available options:"
46 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
47 echo "--docdir=DOCDIR Instalation directory for documentation."
48 echo "--without-win32 Disable win32 interface detection."
49 echo "--without-unix-glob Disable glob.h usage (use workaround)."
50 echo "--with-included-regex Use included regex code (gnu_regex.c)."
51 echo "--with-pcre Enable PCRE library detection."
52 echo "--without-gettext Disable gettext usage."
53 echo "--without-iconv Disable iconv usage."
54 echo "--without-wcwidth Disable system wcwidth() (use Marcus Kuhn's)."
55 echo "--mingw32 Build using the mingw32 compiler."
58 echo "Environment variables:"
60 echo "AR Library Archiver."
65 if [ "$DOCDIR" = "" ] ; then
66 DOCDIR
=$PREFIX/share
/doc
/mpdm
69 echo "Configuring MPDM..."
71 echo "/* automatically created by config.sh - do not modify */" > config.h
72 echo "# automatically created by config.sh - do not modify" > makefile.opts
78 if [ "$CC" = "" ] ; then
80 # if CC is unset, try if gcc is available
81 which gcc
> /dev
/null
2>&1
88 echo "CC=$CC" >> makefile.opts
91 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
95 echo "CFLAGS=$CFLAGS" >> makefile.opts
101 if [ "$AR" = "" ] ; then
105 echo "AR=$AR" >> makefile.opts
108 cat VERSION
>> config.h
110 # add installation prefix
111 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
113 #########################################################
115 # configuration directives
118 echo -n "Testing for win32... "
119 if [ "$WITHOUT_WIN32" = "1" ] ; then
120 echo "Disabled by user"
122 echo "#include <windows.h>" > .tmp.c
123 echo "#include <commctrl.h>" >> .tmp.c
124 echo "int STDCALL WinMain(HINSTANCE h, HINSTANCE p, LPSTR c, int m)" >> .tmp.c
125 echo "{ return 0; }" >> .tmp.c
128 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
131 echo "#define CONFOPT_WIN32 1" >> config.h
141 if [ "$WITHOUT_UNIX_GLOB" != 1 ] ; then
142 echo -n "Testing for unix-like glob.h... "
143 echo "#include <stdio.h>" > .tmp.c
144 echo "#include <glob.h>" >> .tmp.c
145 echo "int main(void) { glob_t g; g.gl_offs=1; glob(\"*\",GLOB_MARK,NULL,&g); return 0; }" >> .tmp.c
147 $CC .tmp.c
-o .tmp.o
2>> .config.log
150 echo "#define CONFOPT_GLOB_H 1" >> config.h
153 echo "No; activating workaround"
158 echo -n "Testing for regular expressions... "
160 if [ "$WITH_PCRE" = 1 ] ; then
161 # try first the pcre library
162 TMP_CFLAGS
="-I/usr/local/include"
163 TMP_LDFLAGS
="-L/usr/local/lib -lpcre -lpcreposix"
164 echo "#include <pcreposix.h>" > .tmp.c
165 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
167 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
170 echo "OK (using pcre library)"
171 echo "#define CONFOPT_PCRE 1" >> config.h
172 echo "$TMP_CFLAGS " >> config.cflags
173 echo "$TMP_LDFLAGS " >> config.ldflags
178 if [ "$REGEX_YET" != 1 -a "$WITH_INCLUDED_REGEX" != 1 ] ; then
179 echo "#include <sys/types.h>" > .tmp.c
180 echo "#include <regex.h>" >> .tmp.c
181 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
183 $CC .tmp.c
-o .tmp.o
2>> .config.log
186 echo "OK (using system one)"
187 echo "#define CONFOPT_SYSTEM_REGEX 1" >> config.h
192 if [ "$REGEX_YET" != 1 ] ; then
193 # if system libraries lack regex, try compiling the
194 # included gnu_regex.c
196 $CC -c -DSTD_HEADERS -DREGEX gnu_regex.c
-o .tmp.o
2>> .config.log
199 echo "OK (using included gnu_regex.c)"
200 echo "#define HAVE_STRING_H 1" >> config.h
201 echo "#define REGEX 1" >> config.h
202 echo "#define CONFOPT_INCLUDED_REGEX 1" >> config.h
204 echo "#define CONFOPT_NO_REGEX 1" >> config.h
205 echo "No (No usable regex library)"
211 echo -n "Testing for unistd.h... "
212 echo "#include <unistd.h>" > .tmp.c
213 echo "int main(void) { return(0); }" >> .tmp.c
215 $CC .tmp.c
-o .tmp.o
2>> .config.log
218 echo "#define CONFOPT_UNISTD_H 1" >> config.h
224 # sys/types.h detection
225 echo -n "Testing for sys/types.h... "
226 echo "#include <sys/types.h>" > .tmp.c
227 echo "int main(void) { return(0); }" >> .tmp.c
229 $CC .tmp.c
-o .tmp.o
2>> .config.log
232 echo "#define CONFOPT_SYS_TYPES_H 1" >> config.h
238 # sys/wait.h detection
239 echo -n "Testing for sys/wait.h... "
240 echo "#include <sys/wait.h>" > .tmp.c
241 echo "int main(void) { return(0); }" >> .tmp.c
243 $CC .tmp.c
-o .tmp.o
2>> .config.log
246 echo "#define CONFOPT_SYS_WAIT_H 1" >> config.h
252 # sys/stat.h detection
253 echo -n "Testing for sys/stat.h... "
254 echo "#include <sys/stat.h>" > .tmp.c
255 echo "int main(void) { return(0); }" >> .tmp.c
257 $CC .tmp.c
-o .tmp.o
2>> .config.log
260 echo "#define CONFOPT_SYS_STAT_H 1" >> config.h
267 echo -n "Testing for pwd.h... "
268 echo "#include <pwd.h>" > .tmp.c
269 echo "int main(void) { return(0); }" >> .tmp.c
271 $CC .tmp.c
-o .tmp.o
2>> .config.log
274 echo "#define CONFOPT_PWD_H 1" >> config.h
281 echo -n "Testing for chown()... "
282 echo "#include <sys/types.h>" > .tmp.c
283 echo "#include <unistd.h>" >> .tmp.c
284 echo "int main(void) { chown(\"file\", 0, 0); }" >> .tmp.c
286 $CC .tmp.c
-o .tmp.o
2>> .config.log
289 echo "#define CONFOPT_CHOWN 1" >> config.h
296 echo -n "Testing for gettext... "
298 if [ "$WITHOUT_GETTEXT" = "1" ] ; then
299 echo "Disabled by user"
301 echo "#include <libintl.h>" > .tmp.c
302 echo "#include <locale.h>" >> .tmp.c
303 echo "int main(void) { setlocale(LC_ALL, \"\"); gettext(\"hi\"); return 0; }" >> .tmp.c
305 # try first to compile without -lintl
306 $CC .tmp.c
-o .tmp.o
2>> .config.log
310 echo "#define CONFOPT_GETTEXT 1" >> config.h
312 # try now with -lintl
315 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
318 echo "OK (libintl needed)"
319 echo "#define CONFOPT_GETTEXT 1" >> config.h
320 echo "$TMP_LDFLAGS" >> config.ldflags
329 echo -n "Testing for iconv... "
331 if [ "$WITHOUT_ICONV" = "1" ] ; then
332 echo "Disabled by user"
334 echo "#include <iconv.h>" > .tmp.c
335 echo "#include <locale.h>" >> .tmp.c
336 echo "int main(void) { setlocale(LC_ALL, \"\"); iconv_open(\"WCHAR_T\", \"ISO-8859-1\"); return 0; }" >> .tmp.c
338 # try first to compile without -liconv
339 $CC .tmp.c
-o .tmp.o
2>> .config.log
343 echo "#define CONFOPT_ICONV 1" >> config.h
345 # try now with -liconv
346 TMP_LDFLAGS
="-liconv"
348 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
351 echo "OK (libiconv needed)"
352 echo "#define CONFOPT_ICONV 1" >> config.h
353 echo "$TMP_LDFLAGS" >> config.ldflags
360 # wcwidth() existence
361 echo -n "Testing for wcwidth()... "
363 if [ "$WITHOUT_WCWIDTH" = "1" ] ; then
364 echo "Disabled by user (using Markus Kuhn's)"
366 echo "#include <wchar.h>" > .tmp.c
367 echo "int main(void) { wcwidth(L'a'); return 0; }" >> .tmp.c
369 $CC .tmp.c
-o .tmp.o
2>> .config.log
373 echo "#define CONFOPT_WCWIDTH 1" >> config.h
375 echo "No; using Markus Kuhn's wcwidth()"
379 # canonicalize_file_name() detection
380 echo -n "Testing for file canonicalization... "
381 echo "#include <stdlib.h>" > .tmp.c
382 echo "int main(void) { canonicalize_file_name(\"file\"); return 0; }" >> .tmp.c
384 $CC .tmp.c
-o .tmp.o
2>> .config.log
387 echo "#define CONFOPT_CANONICALIZE_FILE_NAME 1" >> config.h
388 echo "canonicalize_file_name()"
391 echo "#include <stdlib.h>" > .tmp.c
392 echo "int main(void) { char tmp[2048]; realpath(\"file\", tmp); return 0; }" >> .tmp.c
394 $CC .tmp.c
-o .tmp.o
2>> .config.log
397 echo "#define CONFOPT_REALPATH 1" >> config.h
401 echo "#include <stdlib.h>" > .tmp.c
402 echo "int main(void) { char tmp[2048]; _fullpath(tmp, \"file\", _MAX_PATH); return 0; }" >> .tmp.c
404 $CC .tmp.c
-o .tmp.o
2>> .config.log
407 echo "#define CONFOPT_FULLPATH 1" >> config.h
415 if [ "$WITH_WIN32" != 1 ] ; then
416 echo -n "Testing for nanosleep()... "
417 echo "#include <time.h>" > .tmp.c
418 echo "int main(void) { struct timespec ts; ts.tv_sec = 1; ts.tv_nsec = 0; nanosleep(&ts, NULL); return 0; }" >> .tmp.c
420 $CC .tmp.c
-o .tmp.o
2>> .config.log
423 echo "#define CONFOPT_NANOSLEEP 1" >> config.h
430 if [ "$WITH_WIN32" != 1 ] ; then
431 echo -n "Testing for POSIX threads... "
432 echo "#include <pthread.h>" > .tmp.c
433 echo "int main(void) { pthread_t t; pthread_create(&t, NULL, NULL, NULL); return 0; }" >> .tmp.c
435 TMP_LDFLAGS
="-pthread"
436 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
439 echo "#define CONFOPT_PTHREADS 1" >> config.h
440 echo $TMP_LDFLAGS >> config.ldflags
448 if [ "$WITH_WIN32" != 1 -a "$WITH_PTHREADS" = 1 ] ; then
449 echo -n "Testing for POSIX semaphores... "
450 echo "#include <semaphore.h>" > .tmp.c
451 echo "int main(void) { sem_t s; sem_init(&s, 0, 0); return 0; }" >> .tmp.c
453 TMP_LDFLAGS
="-pthread"
454 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
457 echo "#define CONFOPT_POSIXSEMS 1" >> config.h
465 echo -n "Testing if Grutatxt is installed... "
469 if which grutatxt
> /dev
/null
2>&1 ; then
471 echo "GRUTATXT=yes" >> makefile.opts
472 DOCS
="$DOCS \$(GRUTATXT_DOCS)"
475 echo "GRUTATXT=no" >> makefile.opts
479 echo -n "Testing if mp_doccer is installed... "
480 MP_DOCCER
=$
(which mp_doccer||
which mp-doccer
)
484 if ${MP_DOCCER} --help |
grep grutatxt
> /dev
/null
; then
488 echo "MP_DOCCER=yes" >> makefile.opts
489 DOCS
="$DOCS \$(MP_DOCCER_DOCS)"
491 grep GRUTATXT
=yes makefile.opts
> /dev
/null
&& DOCS
="$DOCS \$(G_AND_MP_DOCS)"
494 echo "MP_DOCCER=no" >> makefile.opts
498 echo "MP_DOCCER=no" >> makefile.opts
501 if [ "$WITH_NULL_HASH" = "1" ] ; then
502 echo "Selecting NULL hash function"
504 echo "#define CONFOPT_NULL_HASH 1" >> config.h
507 #########################################################
511 echo "DOCS=$DOCS" >> makefile.opts
512 echo "VERSION=$VERSION" >> makefile.opts
513 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
514 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
515 echo >> makefile.opts
517 cat makefile.opts makefile.
in makefile.depend
> Makefile
519 #########################################################