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 --prefix) PREFIX
=$2 ; shift ;;
28 --prefix=*) PREFIX
=`echo $1 | sed -e 's/--prefix=//'` ;;
30 --docdir) DOCDIR
=$2 ; shift ;;
31 --docdir=*) DOCDIR
=`echo $1 | sed -e 's/--docdir=//'` ;;
38 if [ "$CONFIG_HELP" = "1" ] ; then
40 echo "Available options:"
41 echo "--prefix=PREFIX Installation prefix ($PREFIX)."
42 echo "--docdir=DOCDIR Instalation directory for documentation."
43 echo "--without-win32 Disable win32 interface detection."
44 echo "--without-unix-glob Disable glob.h usage (use workaround)."
45 echo "--with-included-regex Use included regex code (gnu_regex.c)."
46 echo "--with-pcre Enable PCRE library detection."
47 echo "--without-gettext Disable gettext usage."
48 echo "--without-iconv Disable iconv usage."
49 echo "--without-wcwidth Disable system wcwidth() (use Marcus Kuhn's)."
52 echo "Environment variables:"
54 echo "AR Library Archiver."
59 if [ "$DOCDIR" = "" ] ; then
60 DOCDIR
=$PREFIX/share
/doc
/mpdm
63 echo "Configuring MPDM..."
65 echo "/* automatically created by config.sh - do not modify */" > config.h
66 echo "# automatically created by config.sh - do not modify" > makefile.opts
72 if [ "$CC" = "" ] ; then
74 # if CC is unset, try if gcc is available
82 echo "CC=$CC" >> makefile.opts
85 if [ "$CFLAGS" = "" -a "$CC" = "gcc" ] ; then
89 echo "CFLAGS=$CFLAGS" >> makefile.opts
95 if [ "$AR" = "" ] ; then
99 echo "AR=$AR" >> makefile.opts
102 cat VERSION
>> config.h
104 # add installation prefix
105 echo "#define CONFOPT_PREFIX \"$PREFIX\"" >> config.h
107 #########################################################
109 # configuration directives
112 echo -n "Testing for win32... "
113 if [ "$WITHOUT_WIN32" = "1" ] ; then
114 echo "Disabled by user"
116 echo "#include <windows.h>" > .tmp.c
117 echo "#include <commctrl.h>" >> .tmp.c
118 echo "int STDCALL WinMain(HINSTANCE h, HINSTANCE p, LPSTR c, int m)" >> .tmp.c
119 echo "{ return 0; }" >> .tmp.c
121 TMP_LDFLAGS
="-mwindows -lcomctl32"
122 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
125 echo "#define CONFOPT_WIN32 1" >> config.h
126 echo "$TMP_LDFLAGS " >> config.ldflags
135 if [ "$WITHOUT_UNIX_GLOB" != 1 ] ; then
136 echo -n "Testing for unix-like glob.h... "
137 echo "#include <stdio.h>" > .tmp.c
138 echo "#include <glob.h>" >> .tmp.c
139 echo "int main(void) { glob_t g; g.gl_offs=1; glob(\"*\",GLOB_MARK,NULL,&g); return 0; }" >> .tmp.c
141 $CC .tmp.c
-o .tmp.o
2>> .config.log
144 echo "#define CONFOPT_GLOB_H 1" >> config.h
147 echo "No; activating workaround"
152 echo -n "Testing for regular expressions... "
154 if [ "$WITH_PCRE" = 1 ] ; then
155 # try first the pcre library
156 TMP_CFLAGS
="-I/usr/local/include"
157 TMP_LDFLAGS
="-L/usr/local/lib -lpcre -lpcreposix"
158 echo "#include <pcreposix.h>" > .tmp.c
159 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
161 $CC $TMP_CFLAGS .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
164 echo "OK (using pcre library)"
165 echo "#define CONFOPT_PCRE 1" >> config.h
166 echo "$TMP_CFLAGS " >> config.cflags
167 echo "$TMP_LDFLAGS " >> config.ldflags
172 if [ "$REGEX_YET" != 1 -a "$WITH_INCLUDED_REGEX" != 1 ] ; then
173 echo "#include <sys/types.h>" > .tmp.c
174 echo "#include <regex.h>" >> .tmp.c
175 echo "int main(void) { regex_t r; regmatch_t m; regcomp(&r,\".*\",REG_EXTENDED|REG_ICASE); return 0; }" >> .tmp.c
177 $CC .tmp.c
-o .tmp.o
2>> .config.log
180 echo "OK (using system one)"
181 echo "#define CONFOPT_SYSTEM_REGEX 1" >> config.h
186 if [ "$REGEX_YET" != 1 ] ; then
187 # if system libraries lack regex, try compiling the
188 # included gnu_regex.c
190 $CC -c -DSTD_HEADERS -DREGEX gnu_regex.c
-o .tmp.o
2>> .config.log
193 echo "OK (using included gnu_regex.c)"
194 echo "#define HAVE_STRING_H 1" >> config.h
195 echo "#define REGEX 1" >> config.h
196 echo "#define CONFOPT_INCLUDED_REGEX 1" >> config.h
198 echo "#define CONFOPT_NO_REGEX 1" >> config.h
199 echo "No (No usable regex library)"
205 echo -n "Testing for unistd.h... "
206 echo "#include <unistd.h>" > .tmp.c
207 echo "int main(void) { return(0); }" >> .tmp.c
209 $CC .tmp.c
-o .tmp.o
2>> .config.log
212 echo "#define CONFOPT_UNISTD_H 1" >> config.h
218 # sys/types.h detection
219 echo -n "Testing for sys/types.h... "
220 echo "#include <sys/types.h>" > .tmp.c
221 echo "int main(void) { return(0); }" >> .tmp.c
223 $CC .tmp.c
-o .tmp.o
2>> .config.log
226 echo "#define CONFOPT_SYS_TYPES_H 1" >> config.h
232 # sys/wait.h detection
233 echo -n "Testing for sys/wait.h... "
234 echo "#include <sys/wait.h>" > .tmp.c
235 echo "int main(void) { return(0); }" >> .tmp.c
237 $CC .tmp.c
-o .tmp.o
2>> .config.log
240 echo "#define CONFOPT_SYS_WAIT_H 1" >> config.h
246 # sys/stat.h detection
247 echo -n "Testing for sys/stat.h... "
248 echo "#include <sys/stat.h>" > .tmp.c
249 echo "int main(void) { return(0); }" >> .tmp.c
251 $CC .tmp.c
-o .tmp.o
2>> .config.log
254 echo "#define CONFOPT_SYS_STAT_H 1" >> config.h
261 echo -n "Testing for pwd.h... "
262 echo "#include <pwd.h>" > .tmp.c
263 echo "int main(void) { return(0); }" >> .tmp.c
265 $CC .tmp.c
-o .tmp.o
2>> .config.log
268 echo "#define CONFOPT_PWD_H 1" >> config.h
275 echo -n "Testing for chown()... "
276 echo "#include <sys/types.h>" > .tmp.c
277 echo "#include <unistd.h>" >> .tmp.c
278 echo "int main(void) { chown(\"file\", 0, 0); }" >> .tmp.c
280 $CC .tmp.c
-o .tmp.o
2>> .config.log
283 echo "#define CONFOPT_CHOWN 1" >> config.h
290 echo -n "Testing for gettext... "
292 if [ "$WITHOUT_GETTEXT" = "1" ] ; then
293 echo "Disabled by user"
295 echo "#include <libintl.h>" > .tmp.c
296 echo "#include <locale.h>" >> .tmp.c
297 echo "int main(void) { setlocale(LC_ALL, \"\"); gettext(\"hi\"); return 0; }" >> .tmp.c
299 # try first to compile without -lintl
300 $CC .tmp.c
-o .tmp.o
2>> .config.log
304 echo "#define CONFOPT_GETTEXT 1" >> config.h
306 # try now with -lintl
309 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
312 echo "OK (libintl needed)"
313 echo "#define CONFOPT_GETTEXT 1" >> config.h
314 echo "$TMP_LDFLAGS" >> config.ldflags
323 echo -n "Testing for iconv... "
325 if [ "$WITHOUT_ICONV" = "1" ] ; then
326 echo "Disabled by user"
328 echo "#include <iconv.h>" > .tmp.c
329 echo "#include <locale.h>" >> .tmp.c
330 echo "int main(void) { setlocale(LC_ALL, \"\"); iconv_open(\"WCHAR_T\", \"ISO-8859-1\"); return 0; }" >> .tmp.c
332 # try first to compile without -liconv
333 $CC .tmp.c
-o .tmp.o
2>> .config.log
337 echo "#define CONFOPT_ICONV 1" >> config.h
339 # try now with -liconv
340 TMP_LDFLAGS
="-liconv"
342 $CC .tmp.c
$TMP_LDFLAGS -o .tmp.o
2>> .config.log
345 echo "OK (libiconv needed)"
346 echo "#define CONFOPT_ICONV 1" >> config.h
347 echo "$TMP_LDFLAGS" >> config.ldflags
354 # wcwidth() existence
355 echo -n "Testing for wcwidth()... "
357 if [ "$WITHOUT_WCWIDTH" = "1" ] ; then
358 echo "Disabled by user (using Markus Kuhn's)"
360 echo "#include <wchar.h>" > .tmp.c
361 echo "int main(void) { wcwidth(L'a'); return 0; }" >> .tmp.c
363 $CC .tmp.c
-o .tmp.o
2>> .config.log
367 echo "#define CONFOPT_WCWIDTH 1" >> config.h
369 echo "No; using Markus Kuhn's wcwidth()"
373 if [ "$WITH_NULL_HASH" = "1" ] ; then
374 echo "Selecting NULL hash function"
376 echo "#define CONFOPT_NULL_HASH 1" >> config.h
379 #########################################################
383 echo "VERSION=$VERSION" >> makefile.opts
384 echo "PREFIX=\$(DESTDIR)$PREFIX" >> makefile.opts
385 echo "DOCDIR=\$(DESTDIR)$DOCDIR" >> makefile.opts
386 echo >> makefile.opts
388 cat makefile.opts makefile.
in makefile.depend
> Makefile
390 #########################################################