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
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
140 if [ "$WITHOUT_UNIX_GLOB" != 1 ] ; then
141 echo -n "Testing for unix-like glob.h... "
142 echo "#include <stdio.h>" > .tmp.c
143 echo "#include <glob.h>" >> .tmp.c
144 echo "int main(void) { glob_t g; g.gl_offs=1; glob(\"*\",GLOB_MARK,NULL,&g); return 0; }" >> .tmp.c
146 $CC .tmp.c
-o .tmp.o
2>> .config.log
149 echo "#define CONFOPT_GLOB_H 1" >> config.h
152 echo "No; activating workaround"
157 echo -n "Testing for regular expressions... "
159 if [ "$WITH_PCRE" = 1 ] ; then
160 # try first the pcre library
161 TMP_CFLAGS
="-I/usr/local/include"
162 TMP_LDFLAGS
="-L/usr/local/lib -lpcre -lpcreposix"
163 echo "#include <pcreposix.h>" > .tmp.c
164 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
166 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
169 echo "OK (using pcre library)"
170 echo "#define CONFOPT_PCRE 1" >> config.h
171 echo "$TMP_CFLAGS " >> config.cflags
172 echo "$TMP_LDFLAGS " >> config.ldflags
177 if [ "$REGEX_YET" != 1 -a "$WITH_INCLUDED_REGEX" != 1 ] ; then
178 echo "#include <sys/types.h>" > .tmp.c
179 echo "#include <regex.h>" >> .tmp.c
180 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
182 $CC .tmp.c
-o .tmp.o
2>> .config.log
185 echo "OK (using system one)"
186 echo "#define CONFOPT_SYSTEM_REGEX 1" >> config.h
191 if [ "$REGEX_YET" != 1 ] ; then
192 # if system libraries lack regex, try compiling the
193 # included gnu_regex.c
195 $CC -c -DSTD_HEADERS -DREGEX gnu_regex.c
-o .tmp.o
2>> .config.log
198 echo "OK (using included gnu_regex.c)"
199 echo "#define HAVE_STRING_H 1" >> config.h
200 echo "#define REGEX 1" >> config.h
201 echo "#define CONFOPT_INCLUDED_REGEX 1" >> config.h
203 echo "#define CONFOPT_NO_REGEX 1" >> config.h
204 echo "No (No usable regex library)"
210 echo -n "Testing for unistd.h... "
211 echo "#include <unistd.h>" > .tmp.c
212 echo "int main(void) { return(0); }" >> .tmp.c
214 $CC .tmp.c
-o .tmp.o
2>> .config.log
217 echo "#define CONFOPT_UNISTD_H 1" >> config.h
223 # sys/types.h detection
224 echo -n "Testing for sys/types.h... "
225 echo "#include <sys/types.h>" > .tmp.c
226 echo "int main(void) { return(0); }" >> .tmp.c
228 $CC .tmp.c
-o .tmp.o
2>> .config.log
231 echo "#define CONFOPT_SYS_TYPES_H 1" >> config.h
237 # sys/wait.h detection
238 echo -n "Testing for sys/wait.h... "
239 echo "#include <sys/wait.h>" > .tmp.c
240 echo "int main(void) { return(0); }" >> .tmp.c
242 $CC .tmp.c
-o .tmp.o
2>> .config.log
245 echo "#define CONFOPT_SYS_WAIT_H 1" >> config.h
251 # sys/stat.h detection
252 echo -n "Testing for sys/stat.h... "
253 echo "#include <sys/stat.h>" > .tmp.c
254 echo "int main(void) { return(0); }" >> .tmp.c
256 $CC .tmp.c
-o .tmp.o
2>> .config.log
259 echo "#define CONFOPT_SYS_STAT_H 1" >> config.h
266 echo -n "Testing for pwd.h... "
267 echo "#include <pwd.h>" > .tmp.c
268 echo "int main(void) { return(0); }" >> .tmp.c
270 $CC .tmp.c
-o .tmp.o
2>> .config.log
273 echo "#define CONFOPT_PWD_H 1" >> config.h
280 echo -n "Testing for chown()... "
281 echo "#include <sys/types.h>" > .tmp.c
282 echo "#include <unistd.h>" >> .tmp.c
283 echo "int main(void) { chown(\"file\", 0, 0); }" >> .tmp.c
285 $CC .tmp.c
-o .tmp.o
2>> .config.log
288 echo "#define CONFOPT_CHOWN 1" >> config.h
295 echo -n "Testing for gettext... "
297 if [ "$WITHOUT_GETTEXT" = "1" ] ; then
298 echo "Disabled by user"
300 echo "#include <libintl.h>" > .tmp.c
301 echo "#include <locale.h>" >> .tmp.c
302 echo "int main(void) { setlocale(LC_ALL, \"\"); gettext(\"hi\"); return 0; }" >> .tmp.c
304 # try first to compile without -lintl
305 $CC .tmp.c
-o .tmp.o
2>> .config.log
309 echo "#define CONFOPT_GETTEXT 1" >> config.h
311 # try now with -lintl
314 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
317 echo "OK (libintl needed)"
318 echo "#define CONFOPT_GETTEXT 1" >> config.h
319 echo "$TMP_LDFLAGS" >> config.ldflags
328 echo -n "Testing for iconv... "
330 if [ "$WITHOUT_ICONV" = "1" ] ; then
331 echo "Disabled by user"
333 echo "#include <iconv.h>" > .tmp.c
334 echo "#include <locale.h>" >> .tmp.c
335 echo "int main(void) { setlocale(LC_ALL, \"\"); iconv_open(\"WCHAR_T\", \"ISO-8859-1\"); return 0; }" >> .tmp.c
337 # try first to compile without -liconv
338 $CC .tmp.c
-o .tmp.o
2>> .config.log
342 echo "#define CONFOPT_ICONV 1" >> config.h
344 # try now with -liconv
345 TMP_LDFLAGS
="-liconv"
347 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
350 echo "OK (libiconv needed)"
351 echo "#define CONFOPT_ICONV 1" >> config.h
352 echo "$TMP_LDFLAGS" >> config.ldflags
359 # wcwidth() existence
360 echo -n "Testing for wcwidth()... "
362 if [ "$WITHOUT_WCWIDTH" = "1" ] ; then
363 echo "Disabled by user (using Markus Kuhn's)"
365 echo "#include <wchar.h>" > .tmp.c
366 echo "int main(void) { wcwidth(L'a'); return 0; }" >> .tmp.c
368 $CC .tmp.c
-o .tmp.o
2>> .config.log
372 echo "#define CONFOPT_WCWIDTH 1" >> config.h
374 echo "No; using Markus Kuhn's wcwidth()"
378 # canonicalize_file_name() detection
379 echo -n "Testing for file canonicalization... "
380 echo "#include <stdlib.h>" > .tmp.c
381 echo "int main(void) { canonicalize_file_name(\"file\"); return 0; }" >> .tmp.c
383 $CC .tmp.c
-o .tmp.o
2>> .config.log
386 echo "#define CONFOPT_CANONICALIZE_FILE_NAME 1" >> config.h
387 echo "canonicalize_file_name()"
390 echo "#include <stdlib.h>" > .tmp.c
391 echo "int main(void) { char tmp[2048]; realpath(\"file\", tmp); return 0; }" >> .tmp.c
393 $CC .tmp.c
-o .tmp.o
2>> .config.log
396 echo "#define CONFOPT_REALPATH 1" >> config.h
404 echo -n "Testing if Grutatxt is installed... "
408 if which grutatxt
> /dev
/null
; then
410 echo "GRUTATXT=yes" >> makefile.opts
411 DOCS
="$DOCS \$(GRUTATXT_DOCS)"
414 echo "GRUTATXT=no" >> makefile.opts
418 echo -n "Testing if mp_doccer is installed... "
419 MP_DOCCER
=$
(which mp_doccer ||
which mp-doccer
)
423 if ${MP_DOCCER} --help |
grep grutatxt
> /dev
/null
; then
427 echo "MP_DOCCER=yes" >> makefile.opts
428 DOCS
="$DOCS \$(MP_DOCCER_DOCS)"
430 grep GRUTATXT
=yes makefile.opts
> /dev
/null
&& DOCS
="$DOCS \$(G_AND_MP_DOCS)"
433 echo "MP_DOCCER=no" >> makefile.opts
437 echo "MP_DOCCER=no" >> makefile.opts
440 if [ "$WITH_NULL_HASH" = "1" ] ; then
441 echo "Selecting NULL hash function"
443 echo "#define CONFOPT_NULL_HASH 1" >> config.h
446 #########################################################
450 echo "DOCS=$DOCS" >> makefile.opts
451 echo "VERSION=$VERSION" >> makefile.opts
452 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
453 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
454 echo >> makefile.opts
456 cat makefile.opts makefile.
in makefile.depend
> Makefile
458 #########################################################