comparison configure @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 #!/bin/sh
2 # configure - configure script for AnaGram
3 # usage: path-to-source/configure [options]
4 # for options, do configure --help, or read down.
5 #
6 # Note: this is a hand-written script, not GNU autoconf output.
7 # Its primary purpose is to set up the build tree, not to perform
8 # tests on the build platform.
9 #
10 # Also note: changing to autoconf will not make this any easier, or
11 # add any useful functionality for free, so please don't bother
12 # suggesting it.
13 #
14 # Supported compilers and targets are listed below. Note that there is
15 # vestigial support in the source tree for various other Windows
16 # compilers (Borland, Watcom, etc.) - I don't have these, but will
17 # cheerfully add support if someone tells me how to invoke them and
18 # sends patches to clean up the template instantiations. I will also
19 # take patches for supporting for other Unix compilers. And if anyone
20 # wants to update the once-upon-a-time Amiga support, I'll even take
21 # patches for that.
22 #
23 # Also, this script should not be expected to work for native builds
24 # on Windows. I don't have a Windows machine, Windows is a crippled
25 # platform, and it's too much trouble to sort out. If someone wants to
26 # make it work under Cygwin, however, I'll take the patches.
27 #
28
29 usage() {
30 cat 1>&2 <<EOF
31 Usage: PATH-TO-SOURCE/configure [options] [ostype]
32 Options:
33 --with-compiler=COMPILER Choose compiler (see below)
34 --with-ptests=DIR Use private testsuite in DIR
35 --enable-gui=GUI Enable a GUI (see below)
36 --disable-gui Build command-line version only
37 --enable-maintainer-mode Set maintainer-specific build options
38 --enable-debug Enable debugging information
39 --enable-prof Enable profiling
40 For Unix installs:
41 --destdir=DIR Set install chroot (default: none)
42 --prefix=DIR Set install prefix (default: /usr/local)
43 --bindir=DIR Install directory for binaries
44 --libdir=DIR Install directory for libraries
45 --mandir=DIR Install directory for man pages
46 --docdir=DIR Install directory for HTML docs
47 --examplesdir=DIR Install directory for examples
48 Compilers:
49 gcc The GNU compiler (gcc/g++).
50 vacpp IBM Visual Age C++ for Windows
51 GUIs:
52 vaclgui The IBM Visual Age C++ for Windows GUI
53 dummygui Equivalent to --disable-gui
54 OSes:
55 native Current Unix type (default)
56 windows Cross-compiled Windows
57 *-* or *-*-* A cross-compiled Unix type
58 Notes:
59 1. Compiling in the source directory is not supported. Run
60 configure in a subdirectory or somewhere else.
61 2. Native builds on Windows are not supported.
62 3. Read the install instructions before cross-compiling.
63 EOF
64 }
65
66 ############################################################
67 #
68 # 1. Know thyself.
69 #
70
71 SRCDIR=`dirname "$0"`
72
73 if [ ! -d "$SRCDIR" -o "$SRCDIR" = "" ]; then
74 # ...?
75 usage
76 exit 1
77 fi
78
79 if [ "$SRCDIR" = . ]; then
80 # just warn, don't error
81 echo "$0: Compiling in the source directory is not recommended" 1>&2
82 #echo "Please do this:" 1>&2
83 #echo " mkdir build" 1>&2
84 #echo " cd build" 1>&2
85 #echo " ../configure $@" 1>&2
86 #exit 1
87 fi
88
89 if [ ! -f "$SRCDIR"/anagram/agcore/pgg24.syn ]; then
90 echo "$0: please run me out of the AnaGram source directory" 1>&2
91 exit 1
92 fi
93
94 ############################################################
95 #
96 # 2. options
97 #
98
99 DESTDIR=
100 PREFIX=
101 BINDIR=
102 LIBDIR=
103 MANDIR=
104 DOCDIR=
105 EXAMPLESDIR=
106 COMPILER=
107 PTESTS=
108 GUI=
109 PLATFORM=
110 MAINTAINER=0
111 MODE=opt
112
113 while [ "x$1" != x ]; do
114 case "$1" in
115 --destdir=*) DESTDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
116 --prefix=*) PREFIX=`echo "$1" | sed 's/^[^=]*=//'`;;
117 --bindir=*) BINDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
118 --libdir=*) LIBDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
119 --mandir=*) MANDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
120 --docdir=*) DOCDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
121 --examplesdir=*) EXAMPLESDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
122 --with-compiler=*) COMPILER=`echo "$1" | sed 's/^[^=]*=//'`;;
123 --without-compiler) echo "$0: You're joking, right?" 1>&2; exit 1;;
124 --with-ptests=*) PTESTS=`echo "$1" | sed 's/^[^=]*=//'`;;
125 --without-ptests) PTESTS= ;;
126 --enable-gui=*) GUI=`echo "$1" | sed 's/^[^=]*=//'`;;
127 --disable-gui) GUI=dummygui;;
128 --enable-maintainer-mode) MAINTAINER=1;;
129 --disable-maintainer-mode) MAINTAINER=0;;
130 --enable-debug) MODE=debug;;
131 --enable-prof) MODE=prof;;
132 --disable-debug|--disable-prof) MODE=opt;;
133 --help) usage; exit 0;;
134 --*|-*) usage; exit 1;;
135 *)
136 if [ "x$PLATFORM" != x ]; then
137 usage
138 exit 1
139 fi
140 PLATFORM="$1"
141 ;;
142 esac
143 shift
144 done
145
146 # Default platform
147
148 if [ "x$PLATFORM" = x ]; then
149 PLATFORM=native
150 fi
151
152 # Check platform
153
154 case "$PLATFORM" in
155 native) OSTYPE=unix; CROSS=0;;
156 *-*-*) OSTYPE=unix; CROSS=1; CROSSNAME="$PLATFORM";;
157 *-*) OSTYPE=unix; CROSS=1; CROSSNAME="$PLATFORM";;
158 windows) OSTYPE=windows; CROSS=1; CROSSNAME=windows;;
159 *) echo "$0: Invalid platform $PLATFORM" 1>&2; exit 1;;
160 esac
161
162 # Default compiler
163
164 if [ "x$COMPILER" = x ]; then
165 if [ "$OSTYPE" = windows ]; then
166 COMPILER=vacpp
167 else
168 COMPILER=gcc
169 fi
170 fi
171
172 # Check compiler
173
174 case "$COMPILER" in
175 gcc) ;;
176 vacpp) ;;
177 *) echo "$0: Unrecognized compiler $COMPILER" 1>&2; exit 1;;
178 esac
179
180 # Default GUI
181
182 if [ "x$GUI" = x ]; then
183 if [ "$COMPILER" = vacpp ]; then
184 GUI=vaclgui
185 else
186 GUI=dummygui
187 fi
188 fi
189
190 # Check GUI
191
192 case "$GUI" in
193 vaclgui) ;;
194 dummygui) ;;
195 *) echo "$0: Unrecognized GUI $GUI" 1>&2; exit 1;;
196 esac
197
198 # Default PREFIX
199
200 if [ "x$PREFIX" = x ]; then
201 if [ $OSTYPE = unix ]; then
202 if [ $CROSS = 1 ]; then
203 PREFIX="/usr/local/$CROSSNAME"
204 else
205 PREFIX=/usr/local
206 fi
207 else
208 # Windows build doesn't use this
209 PREFIX=/error
210 fi
211 fi
212
213 # Do not need to check PREFIX
214
215 # Default DESTDIR is empty - do not need to set it
216
217 # Check DESTDIR
218
219 if [ "x$DESTDIR" != x ]; then
220 if [ ! -d "$DESTDIR" ]; then
221 echo "$0: DESTDIR $DESTDIR does not exist" 1>&2
222 exit 1
223 fi
224 fi
225
226 # Pick default install dirs
227 if [ $OSTYPE = unix ]; then
228
229 if [ "x$BINDIR" = x ]; then
230 BINDIR="$PREFIX/bin"
231 fi
232
233 if [ "x$LIBDIR" = x ]; then
234 LIBDIR="$PREFIX/lib"
235 fi
236
237 if [ "x$MANDIR" = x ]; then
238 # probe default man directory
239 if [ -d "${DESTDIR}$PREFIX/share/man" ]; then
240 MANDIR="$PREFIX/share/man"
241 else
242 MANDIR="$PREFIX/man"
243 fi
244 fi
245
246 if [ "x$DOCDIR" = x ]; then
247 if [ -d "${DESTDIR}$PREFIX/share/doc/html" ]; then
248 DOCDIR="$PREFIX/share/doc/html/AnaGram"
249 else if [ -d "${DESTDIR}$PREFIX/doc" ]; then
250 DOCDIR="$PREFIX/doc/AnaGram"
251 else
252 DOCDIR="$PREFIX/share/doc/AnaGram"
253 fi;fi
254 fi
255
256 if [ "x$EXAMPLESDIR" = x ]; then
257 if [ -d "${DESTDIR}$PREFIX/share/examples" ];then
258 EXAMPLESDIR="$PREFIX/share/examples/AnaGram"
259 else
260 EXAMPLESDIR="$DOCDIR"
261 fi
262 fi
263
264 fi
265
266
267 # Check for (in)valid combinations
268
269 case "${COMPILER}-${GUI}-${OSTYPE}" in
270 vacpp-vaclgui-windows) ;;
271 vacpp-dummygui-windows) ;;
272 gcc-dummygui-unix) ;;
273
274 vacpp-*-unix) echo "$0: compiler vacpp requires Windows" 1>&2; exit 1;;
275 gcc-*-windows) echo "$0: gcc not supported on Windows yet" 1>&2; exit 1;;
276 *-vaclgui-*) echo "$0: GUI vaclgui requires compiler vacpp" 1>&2; exit 1;;
277 *) echo "$0: invalid configuration" 1>&2; exit 1;;
278 esac
279
280 ############################################################
281 #
282 # 3. Report what we're doing
283 #
284
285 echo "Configuring for $COMPILER on $OSTYPE with GUI $GUI."
286 case $MODE in
287 opt) ;;
288 debug) echo "Enabling debugging." ;;
289 prof) echo "Enabling profiling." ;;
290 esac
291 if [ $MAINTAINER = 1 ]; then
292 echo "Enabling maintainer mode."
293 fi
294 if [ $OSTYPE = unix ]; then
295 echo "Settings:"
296 echo " DESTDIR ${DESTDIR:-[none]}"
297 echo " PREFIX ${PREFIX:-[none]}"
298 echo " BINDIR ${BINDIR:-[none]}"
299 echo " LIBDIR ${LIBDIR:-[none]}"
300 echo " MANDIR ${MANDIR:-[none]}"
301 echo " DOCDIR ${DOCDIR:-[none]}"
302 echo " EXAMPLESDIR ${EXAMPLESDIR:-[none]}"
303 echo " CROSSNAME ${CROSSNAME:-[none]}"
304 fi
305
306 ############################################################
307 #
308 # 4. Collect settings
309 #
310
311 DEFS=
312 CFLAGS=
313 LDFLAGS=
314 LIBS=
315 CLEANFILES=
316 DISTCLEANFILES=
317
318 case $OSTYPE in
319 unix)
320 DEFS="$DEFS AG_ON_UNIX"
321 CLEANFILES="$CLEANFILES *.o *.a *.so"
322 ;;
323 windows)
324 DEFS="$DEFS AG_ON_WINDOWS"
325 CLEANFILES="$CLEANFILES *.obj *.lib *.dll *.res"
326 ;;
327 amiga)
328 # No way to get to this, but there was an Amiga port once, so...
329 DEFS="$DEFS AG_ON_AMIGA"
330 CLEANFILES="$CLEANFILES *.obj *.lib *.library"
331 ;;
332 esac
333
334 case $GUI in
335 dummygui)
336 DEFS="$DEFS DUMMYGUI"
337 ;;
338 vaclgui)
339 DEFS="$DEFS VACLGUI"
340 ;;
341 esac
342
343 case $COMPILER in
344 gcc)
345 #
346 # Not used:
347 # -Wmissing-prototypes ...only valid for C, not C++.
348 # -Wshadow ...not yet
349 #
350 CFLAGS="$CFLAGS -MMD -Wall -W -Wwrite-strings -fno-strict-aliasing"
351 if [ $MAINTAINER = 1 ]; then
352 CFLAGS="$CFLAGS -Werror"
353 fi
354 LIBS="$LIBS -lstdc++ -lm"
355 DISTCLEANFILES="$DISTCLEANFILES *.d"
356
357 case $MODE in
358 opt) CFLAGS="$CFLAGS -O2"; LDFLAGS="$LDFLAGS -s";;
359 debug) CFLAGS="$CFLAGS -g";;
360 # note: some versions of Linux can't do -O2 -pg
361 prof) CFLAGS="$CFLAGS -O -pg";;
362 esac
363
364 for D in $DEFS; do
365 CFLAGS="$CFLAGS -D$D"
366 done
367 ;;
368 vacpp)
369 DEFS="$DEFS typename="
370 if [ $MAINTAINER = 1 ]; then
371 : # vacpp doesn't seem to have a -Werror equivalent...
372 fi
373 CLEANFILES="$CLEANFILES *.map *.exp .*.map .*.lib .*.exp"
374 DISTCLEANFILES="$DISTCLEANFILES *.dep *.u *.log"
375
376 case $MODE in
377 opt) CFLAGS="$CFLAGS -O";;
378 debug) CFLAGS="$CFLAGS -g";;
379 prof) ;; # XXX how?
380 esac
381
382 for D in $DEFS; do
383 CFLAGS="$CFLAGS -D$D"
384 done
385 ;;
386 esac
387
388 if [ $CROSS = 1 ]; then
389 if [ "$CROSSNAME" = windows ]; then
390 CROSSRUN="wine"
391 else
392 CROSSRUN="${CROSSNAME}-run"
393 fi
394 else
395 CROSSRUN=
396 fi
397
398 ############################################################
399 #
400 # 5. Write config.mk
401 #
402
403 (
404 echo '# Automatically generated -- do not edit'
405 echo DESTDIR="$DESTDIR"
406 echo PREFIX="$PREFIX"
407 echo BINDIR.unix="$BINDIR"
408 echo LIBDIR.unix="$LIBDIR"
409 echo MANDIR.unix="$MANDIR"
410 echo DOCDIR.unix="$DOCDIR"
411 echo EXAMPLESDIR.unix="$EXAMPLESDIR"
412 echo OS="$OSTYPE"
413 echo COMPILER="$COMPILER"
414 echo GUI="$GUI"
415 if [ $GUI = dummygui ]; then
416 echo HASGUI=nogui
417 else
418 echo HASGUI=hasgui
419 fi
420 echo CROSSRUN="$CROSSRUN"
421 echo
422
423 if [ "x$PTESTS" != x ]; then
424 echo HASPTESTS=hasptests
425 else
426 echo HASPTESTS=noptests
427 fi
428
429 if [ $MAINTAINER = 1 ]; then
430 echo MAINTAINER=maintainer
431 else
432 echo MAINTAINER=nonmaintainer
433 fi
434
435 case $OSTYPE in
436 unix)
437 echo OBJEXT=.o
438 echo LIBEXT=.o
439 echo SHLIBEXT=.so
440 echo EXEEXT=
441 ;;
442 windows)
443 echo OBJEXT=.obj
444 echo LIBEXT=.lib
445 echo SHLIBEXT=.dll
446 echo EXEEXT=.exe
447 ;;
448 amiga)
449 # No way to get this, but there was an Amiga port once, so...
450 echo OBJEXT=.obj
451 echo LIBEXT=.lib
452 echo SHLIBEXT=.library
453 echo EXEEXT=
454 ;;
455 esac
456 echo
457
458 case $COMPILER in
459 gcc)
460 if [ $CROSS = 1 ]; then
461 echo TOOLPREFIX="${CROSSNAME}-"
462 else
463 echo TOOLPREFIX=
464 fi
465 echo CC='$(TOOLPREFIX)gcc'
466 echo LDR='$(TOOLPREFIX)ld -r -o'
467 echo SHLDCC='$(TOOLPREFIX)gcc -shared'
468 echo LDCC='$(TOOLPREFIX)gcc'
469 echo CPPFILT='$(TOOLPREFIX)cppfilt'
470 echo WINDRES='$(TOOLPREFIX)windres'
471 echo
472
473 echo MKDEP='cat *.d > depend.mk'
474 echo CFLAGS.PROG=
475 echo CFLAGS.LIB=
476 echo CFLAGS.SHLIB=-fPIC
477 ;;
478 vacpp)
479 echo CC='$(TOP)/ibmscripts/cc'
480 echo LDR='$(TOP)/ibmscripts/lib'
481 echo SHLDCC='$(TOP)/ibmscripts/shldcc'
482 echo LDCC='$(TOP)/ibmscripts/ldcc'
483 echo CPPFILT='$(TOP)/ibmscripts/cppfilt'
484 echo WINDRES='$(TOP)/ibmscripts/irc'
485 echo
486
487 T='s,\\,/,g;/^[^:]*: *[A-Z]:/d'
488 echo MKDEP="cat *.u 2>/dev/null | expand | sed '$T' > depend.mk"
489 echo CFLAGS.PROG=
490 echo CFLAGS.LIB=
491 echo CFLAGS.SHLIB=-fPIC
492 ;;
493
494 esac
495 echo
496
497 case $OSTYPE in
498 windows)
499 # main ag lib is shared
500 echo 'AGLIBEXT=$(SHLIBEXT)'
501 echo 'AGLIBTYPE=SHLIB'
502 echo 'HASSHLIB=hasshlib'
503 ;;
504 unix)
505 # main ag lib is static
506 echo 'AGLIBEXT=$(LIBEXT)'
507 echo 'AGLIBTYPE=LIB'
508 echo 'HASSHLIB=noshlib'
509 ;;
510 esac
511 echo
512
513 echo CFLAGS="$CFLAGS"
514 echo LDFLAGS="$LDFLAGS"
515 echo LIBS="$LIBS"
516 echo
517
518 echo CLEANFILES="$CLEANFILES"
519 echo DISTCLEANFILES="$DISTCLEANFILES"
520 echo
521
522 # Per-host stuff.
523 # XXX this shouldn't assume gcc.
524
525 echo HOST_OBJEXT=.o
526 echo HOST_EXEEXT=
527
528 echo HOST_CC=gcc
529 echo HOST_LDCC=gcc
530 T='-MMD -Wall -W -Wwrite-strings -g'
531 if [ $MAINTAINER = 1 ]; then
532 T="$T -Werror"
533 fi
534 echo HOST_MKDEP='cat *.d > depend.mk'
535 echo HOST_CFLAGS="$T"
536 echo HOST_LDFLAGS=
537 echo HOST_LIBS=
538
539 echo HOST_CLEANFILES='*.o *.d'
540 echo
541
542 # Which AG to run.
543 if [ $CROSS = 0 ]; then
544 echo UNSAFE_AGCL='$(BUILDTOP)/anagram/run/agcl$(HOST_EXEEXT)'
545 else
546 echo UNSAFE_AGCL='false'
547 fi
548 echo 'ORDINARY_AGCL=$(TOP)/bin/agcl$(HOST_EXEEXT)'
549 echo 'SAFE_AGCL=$(TOP)/bin/safe-agcl$(HOST_EXEEXT)'
550 echo
551
552 # Choice mechanism
553 echo 'SAFE?=0'
554 echo 'UNSAFE?=0'
555 echo 'AGCL01=$(UNSAFE_AGCL)'
556 echo 'AGCL00=$(ORDINARY_AGCL)'
557 echo 'AGCL10=$(SAFE_AGCL)'
558 echo 'AGCL=$(AGCL$(SAFE)$(UNSAFE))'
559 echo 'AGCLQUAL01=UNSAFE'
560 echo 'AGCLQUAL00='
561 echo 'AGCLQUAL10=SAFE'
562 echo 'AGCLQUAL11=' # define this just in case
563 echo 'AGCLQUAL=$(AGCLQUAL$(SAFE)$(UNSAFE))'
564 echo
565
566 ) > config.mk.new
567
568 mv -f config.mk.new config.mk
569
570 ############################################################
571 #
572 # 6. Write makefiles.
573 #
574
575 makemake() {
576 local SRCDIRNAME CHOP D DS U
577
578 SRCDIRNAME="$1"; shift
579 CHOP="$1"; shift
580
581 for D in "$@"; do
582 if [ "$D" != . ]; then
583 D=`echo $D | sed 's,^\./,,'`
584 U=`echo $D | sed 's,[^/]*,..,g'`
585
586 if [ $CHOP = 1 ]; then
587 DS=`echo $D | sed 's,^[^/]*,,'`
588 else
589 DS=`echo $D | sed 's,^,/,'`
590 fi
591
592 if [ ! -d $D ]; then
593 mkdir $D
594 fi
595 (
596 echo '# Automatically generated -- do not edit'
597 case "$SRCDIR" in
598 /*) echo TOP="$SRCDIR";;
599 *) echo TOP="${U}/$SRCDIR";;
600 esac
601 if [ "x$PTESTS" != x ]; then
602 case "$PTESTS" in
603 /*) echo PTESTTOP="$PTESTS";;
604 *) echo PTESTTOP="${U}/$PTESTS";;
605 esac
606 fi
607 echo BUILDTOP="$U"
608 echo SRCDIR="${SRCDIRNAME}$DS"
609 echo 'include $(BUILDTOP)/config.mk'
610 echo 'include $(SRCDIR)/DEFS.mk'
611 ) > $D/Makefile
612 else
613 (
614 echo '# Automatically generated -- do not edit'
615 echo TOP="$SRCDIR"
616 echo BUILDTOP=.
617 echo SRCDIR="$SRCDIRNAME"
618 echo 'include $(BUILDTOP)/config.mk'
619 echo 'include $(SRCDIR)/DEFS.mk'
620 ) > $D/Makefile
621 fi
622 touch $D/depend.mk
623 touch $D/rules.mk
624 echo -n "."
625 done
626 }
627
628 echo -n "Creating makefiles..."
629
630 DIRS=`(cd "$SRCDIR" && find . -name DEFS.mk -print) | sed 's,/[^/]*$,,' | sort`
631 makemake '$(TOP)' 0 $DIRS
632
633 if [ "x$PTESTS" != x ]; then
634 if [ ! -d ptests ]; then
635 mkdir ptests
636 fi
637 DIRS=`(cd "$PTESTS" && find . -name DEFS.mk -print) |\
638 sed 's,/[^/]*$,,;s,^\.,ptests,' | sort`
639 makemake '$(PTESTTOP)' 1 $DIRS
640 fi
641
642 echo
643
644 ############################################################
645 #
646 # 7. Write config.status.
647 #
648
649 (
650 echo '#!/bin/sh'
651 echo '# Automatically generated -- do not edit'
652 echo -n "$0"
653 if [ $OSTYPE = unix ]; then
654 echo -n " --destdir=$DESTDIR"
655 echo -n " --prefix=$PREFIX"
656 echo -n " --bindir=$BINDIR"
657 echo -n " --libdir=$LIBDIR"
658 echo -n " --mandir=$MANDIR"
659 echo -n " --docdir=$DOCDIR"
660 echo -n " --examplesdir=$EXAMPLESDIR"
661 fi
662 echo -n " --with-compiler=$COMPILER"
663 echo -n " --enable-gui=$GUI"
664 if [ $MAINTAINER = 1 ]; then
665 echo -n " --enable-maintainer-mode"
666 fi
667 case $MODE in
668 opt) ;;
669 debug) echo -n ' --enable-debug';;
670 prof) echo -n ' --enable-prof';;
671 esac
672 if [ "x$PTESTS" != x ]; then
673 echo -n ' --with-ptests='"$PTESTS"
674 fi
675
676 echo -n ' "$@"'
677
678 echo " $PLATFORM"
679
680 ) > config.status.new
681 chmod a+x config.status.new
682 mv -f config.status.new config.status
683
684 ############################################################
685 #
686 # 8. done
687 #
688
689 # don't do this here - with gmake it spews tons of crap, and doing
690 # it with >/dev/null 2>&1 isn't really a good idea.
691 #echo 'make rules'
692 #make rules || exit 1
693
694 echo 'Now do:'
695 echo ' make rules'
696 echo ' make'
697 echo ' make install'
698
699 exit 0