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 [ "$AR" = "" ] ; then
95 echo "AR=$AR" >> makefile.opts
98 cat VERSION
>> config.h
100 # add installation prefix
101 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
103 #########################################################
105 # configuration directives
108 if [ -z "$CFLAGS" ] ; then
112 echo -n "Testing if C compiler supports ${CFLAGS}... "
113 echo "int main(int argc, char *argv[]) { return 0; }" > .tmp.c
115 $CC .tmp.c
-o .tmp.o
2>> .config.log
120 echo "No; resetting to defaults"
124 echo "CFLAGS=$CFLAGS" >> makefile.opts
130 echo -n "Testing for win32... "
131 if [ "$WITHOUT_WIN32" = "1" ] ; then
132 echo "Disabled by user"
134 echo "#include <windows.h>" > .tmp.c
135 echo "#include <commctrl.h>" >> .tmp.c
136 echo "int STDCALL WinMain(HINSTANCE h, HINSTANCE p, LPSTR c, int m)" >> .tmp.c
137 echo "{ return 0; }" >> .tmp.c
140 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
143 echo "#define CONFOPT_WIN32 1" >> config.h
153 if [ "$WITHOUT_UNIX_GLOB" != 1 ] ; then
154 echo -n "Testing for unix-like glob.h... "
155 echo "#include <stdio.h>" > .tmp.c
156 echo "#include <glob.h>" >> .tmp.c
157 echo "int main(void) { glob_t g; g.gl_offs=1; glob(\"*\",GLOB_MARK,NULL,&g); return 0; }" >> .tmp.c
159 $CC .tmp.c
-o .tmp.o
2>> .config.log
162 echo "#define CONFOPT_GLOB_H 1" >> config.h
165 echo "No; activating workaround"
170 echo -n "Testing for regular expressions... "
172 if [ "$WITH_PCRE" = 1 ] ; then
173 # try first the pcre library
174 TMP_CFLAGS
="-I/usr/local/include"
175 TMP_LDFLAGS
="-L/usr/local/lib -lpcre -lpcreposix"
176 echo "#include <pcreposix.h>" > .tmp.c
177 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
179 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
182 echo "OK (using pcre library)"
183 echo "#define CONFOPT_PCRE 1" >> config.h
184 echo "$TMP_CFLAGS " >> config.cflags
185 echo "$TMP_LDFLAGS " >> config.ldflags
190 if [ "$REGEX_YET" != 1 -a "$WITH_INCLUDED_REGEX" != 1 ] ; then
191 echo "#include <sys/types.h>" > .tmp.c
192 echo "#include <regex.h>" >> .tmp.c
193 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
195 $CC .tmp.c
-o .tmp.o
2>> .config.log
198 echo "OK (using system one)"
199 echo "#define CONFOPT_SYSTEM_REGEX 1" >> config.h
204 if [ "$REGEX_YET" != 1 ] ; then
205 # if system libraries lack regex, try compiling the
206 # included gnu_regex.c
208 $CC -c -DSTD_HEADERS -DREGEX gnu_regex.c
-o .tmp.o
2>> .config.log
211 echo "OK (using included gnu_regex.c)"
212 echo "#define HAVE_STRING_H 1" >> config.h
213 echo "#define REGEX 1" >> config.h
214 echo "#define CONFOPT_INCLUDED_REGEX 1" >> config.h
216 echo "#define CONFOPT_NO_REGEX 1" >> config.h
217 echo "No (No usable regex library)"
223 echo -n "Testing for unistd.h... "
224 echo "#include <unistd.h>" > .tmp.c
225 echo "int main(void) { return(0); }" >> .tmp.c
227 $CC .tmp.c
-o .tmp.o
2>> .config.log
230 echo "#define CONFOPT_UNISTD_H 1" >> config.h
236 # sys/types.h detection
237 echo -n "Testing for sys/types.h... "
238 echo "#include <sys/types.h>" > .tmp.c
239 echo "int main(void) { return(0); }" >> .tmp.c
241 $CC .tmp.c
-o .tmp.o
2>> .config.log
244 echo "#define CONFOPT_SYS_TYPES_H 1" >> config.h
250 # sys/wait.h detection
251 echo -n "Testing for sys/wait.h... "
252 echo "#include <sys/wait.h>" > .tmp.c
253 echo "int main(void) { return(0); }" >> .tmp.c
255 $CC .tmp.c
-o .tmp.o
2>> .config.log
258 echo "#define CONFOPT_SYS_WAIT_H 1" >> config.h
264 # sys/stat.h detection
265 echo -n "Testing for sys/stat.h... "
266 echo "#include <sys/stat.h>" > .tmp.c
267 echo "int main(void) { return(0); }" >> .tmp.c
269 $CC .tmp.c
-o .tmp.o
2>> .config.log
272 echo "#define CONFOPT_SYS_STAT_H 1" >> config.h
279 echo -n "Testing for pwd.h... "
280 echo "#include <pwd.h>" > .tmp.c
281 echo "int main(void) { return(0); }" >> .tmp.c
283 $CC .tmp.c
-o .tmp.o
2>> .config.log
286 echo "#define CONFOPT_PWD_H 1" >> config.h
293 echo -n "Testing for chown()... "
294 echo "#include <sys/types.h>" > .tmp.c
295 echo "#include <unistd.h>" >> .tmp.c
296 echo "int main(void) { chown(\"file\", 0, 0); }" >> .tmp.c
298 $CC .tmp.c
-o .tmp.o
2>> .config.log
301 echo "#define CONFOPT_CHOWN 1" >> config.h
308 echo -n "Testing for gettext... "
310 if [ "$WITHOUT_GETTEXT" = "1" ] ; then
311 echo "Disabled by user"
313 echo "#include <libintl.h>" > .tmp.c
314 echo "#include <locale.h>" >> .tmp.c
315 echo "int main(void) { setlocale(LC_ALL, \"\"); gettext(\"hi\"); return 0; }" >> .tmp.c
317 # try first to compile without -lintl
318 $CC .tmp.c
-o .tmp.o
2>> .config.log
322 echo "#define CONFOPT_GETTEXT 1" >> config.h
324 # try now with -lintl
327 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
330 echo "OK (libintl needed)"
331 echo "#define CONFOPT_GETTEXT 1" >> config.h
332 echo "$TMP_LDFLAGS" >> config.ldflags
341 echo -n "Testing for iconv... "
343 if [ "$WITHOUT_ICONV" = "1" ] ; then
344 echo "Disabled by user"
346 echo "#include <iconv.h>" > .tmp.c
347 echo "#include <locale.h>" >> .tmp.c
348 echo "int main(void) { setlocale(LC_ALL, \"\"); iconv_open(\"WCHAR_T\", \"ISO-8859-1\"); return 0; }" >> .tmp.c
350 # try first to compile without -liconv
351 $CC .tmp.c
-o .tmp.o
2>> .config.log
355 echo "#define CONFOPT_ICONV 1" >> config.h
357 # try now with -liconv
358 TMP_LDFLAGS
="-liconv"
360 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
363 echo "OK (libiconv needed)"
364 echo "#define CONFOPT_ICONV 1" >> config.h
365 echo "$TMP_LDFLAGS" >> config.ldflags
372 # wcwidth() existence
373 echo -n "Testing for wcwidth()... "
375 if [ "$WITHOUT_WCWIDTH" = "1" ] ; then
376 echo "Disabled by user (using Markus Kuhn's)"
378 echo "#include <wchar.h>" > .tmp.c
379 echo "int main(void) { wcwidth(L'a'); return 0; }" >> .tmp.c
381 $CC .tmp.c
-o .tmp.o
2>> .config.log
385 echo "#define CONFOPT_WCWIDTH 1" >> config.h
387 echo "No; using Markus Kuhn's wcwidth()"
391 # canonicalize_file_name() detection
392 echo -n "Testing for file canonicalization... "
393 echo "#include <stdlib.h>" > .tmp.c
394 echo "int main(void) { canonicalize_file_name(\"file\"); return 0; }" >> .tmp.c
396 $CC .tmp.c
-o .tmp.o
2>> .config.log
399 echo "#define CONFOPT_CANONICALIZE_FILE_NAME 1" >> config.h
400 echo "canonicalize_file_name()"
403 echo "#include <stdlib.h>" > .tmp.c
404 echo "int main(void) { char tmp[2048]; realpath(\"file\", tmp); return 0; }" >> .tmp.c
406 $CC .tmp.c
-o .tmp.o
2>> .config.log
409 echo "#define CONFOPT_REALPATH 1" >> config.h
413 echo "#include <stdlib.h>" > .tmp.c
414 echo "int main(void) { char tmp[2048]; _fullpath(tmp, \"file\", _MAX_PATH); return 0; }" >> .tmp.c
416 $CC .tmp.c
-o .tmp.o
2>> .config.log
419 echo "#define CONFOPT_FULLPATH 1" >> config.h
427 if [ "$WITH_WIN32" != 1 ] ; then
428 echo -n "Testing for nanosleep()... "
429 echo "#include <time.h>" > .tmp.c
430 echo "int main(void) { struct timespec ts; ts.tv_sec = 1; ts.tv_nsec = 0; nanosleep(&ts, NULL); return 0; }" >> .tmp.c
432 $CC .tmp.c
-o .tmp.o
2>> .config.log
435 echo "#define CONFOPT_NANOSLEEP 1" >> config.h
442 if [ "$WITH_WIN32" != 1 ] ; then
443 echo -n "Testing for POSIX threads... "
444 echo "#include <pthread.h>" > .tmp.c
445 echo "void *f(void *p) { return p; } int main(void) { pthread_t t; pthread_create(&t, NULL, f, NULL); return 0; }" >> .tmp.c
447 TMP_LDFLAGS
="-pthread"
448 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
451 echo "#define CONFOPT_PTHREADS 1" >> config.h
452 echo $TMP_LDFLAGS >> config.ldflags
460 if [ "$WITH_WIN32" != 1 -a "$WITH_PTHREADS" = 1 ] ; then
461 echo -n "Testing for POSIX semaphores... "
462 echo "#include <semaphore.h>" > .tmp.c
463 echo "int main(void) { sem_t s; sem_init(&s, 0, 0); return 0; }" >> .tmp.c
465 TMP_LDFLAGS
="-pthread"
466 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
469 echo "#define CONFOPT_POSIXSEMS 1" >> config.h
477 echo -n "Testing if Grutatxt is installed... "
481 if which grutatxt
> /dev
/null
2>&1 ; then
483 echo "GRUTATXT=yes" >> makefile.opts
484 DOCS
="$DOCS \$(GRUTATXT_DOCS)"
487 echo "GRUTATXT=no" >> makefile.opts
491 echo -n "Testing if mp_doccer is installed... "
492 MP_DOCCER
=$
(which mp_doccer||
which mp-doccer
)
496 if ${MP_DOCCER} --help |
grep grutatxt
> /dev
/null
; then
500 echo "MP_DOCCER=yes" >> makefile.opts
501 DOCS
="$DOCS \$(MP_DOCCER_DOCS)"
503 grep GRUTATXT
=yes makefile.opts
> /dev
/null
&& DOCS
="$DOCS \$(G_AND_MP_DOCS)"
506 echo "MP_DOCCER=no" >> makefile.opts
510 echo "MP_DOCCER=no" >> makefile.opts
513 if [ "$WITH_NULL_HASH" = "1" ] ; then
514 echo "Selecting NULL hash function"
516 echo "#define CONFOPT_NULL_HASH 1" >> config.h
519 #########################################################
523 echo "DOCS=$DOCS" >> makefile.opts
524 echo "VERSION=$VERSION" >> makefile.opts
525 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
526 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
527 echo >> makefile.opts
529 cat makefile.opts makefile.
in makefile.depend
> Makefile
531 #########################################################