Merge branch 'hotfix-3.07.3'
[felt.git] / configure
bloba758a69e55788235459f2485ea299c1acfbd7524
1 #!/bin/sh
2 # This file is part of the FElt finite element analysis package.
3 # Copyright (C) 1993-1995 Jason I. Gobat and Darren C. Atkinson
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # find a program in your path
22 which() {
23 IFS=:
24 for dir in $PATH; do
25 if [ -x $dir/$2 -a ! -d $dir/$2 ]; then
26 eval "$1=$dir/$2"
27 break
29 done
30 IFS=" "
34 # find a file in a list
36 findfile() {
37 for file in $2; do
38 if [ -f $file -o -d $file ]; then
39 eval $1=$file
40 break
42 done
46 # parse a command line option
48 parse() {
49 eval $1="`echo \"$2\" | sed -e 's/^[^=]*=//'`"
53 # print help information and exit
55 help() {
56 echo "usage: configure [options]"
57 echo " --contrib build contributed elements [no]"
58 echo " --prefix=dir destination directory prefix [$DEST]"
59 echo " --cc=prog C compiler [$CC]"
60 echo " --cpp=prog C preprocessor [$CPP]"
61 echo " --ccopts=options C compiler options [$CCOPTS]"
62 echo " --syslibs=libs system dependent libraries [$SYSLIBS]"
63 echo " --x-defaults=dir X11 defaults directory [$X11DEF]"
64 echo " --x-includes=dir X11 include directory [$X11INC]"
65 echo " --x-libraries=dir X11 library directory [$X11LIB]"
66 exit 0
70 # try to find the defaults
72 echo Configuring ...
74 which CC gcc
75 which RANLIB ranlib
76 which CAT cat
77 which TRUE true
79 findfile DEST "/usr/felt \
80 /usr/local \
81 /usr/contrib \
82 /usr"
84 findfile READDIR "/lib/libreadline.a \
85 /usr/lib/libreadline.a \
86 /usr/local/lib/libreadline.a \
87 /usr/gnu/lib/libreadline.a \
88 /opt/gnu/lib/libreadline.a"
90 findfile CPP "/lib/cpp \
91 /usr/lib/cpp \
92 /usr/ccs/lib/cpp \
93 /usr/lang/cpp \
94 /usr/bin/cpp \
95 /bin/cpp"
97 findfile X11DEF "/usr/X11R6/lib/X11/app-defaults \
98 /usr/X11R5/lib/X11/app-defaults \
99 /usr/X11R4/lib/X11/app-defaults \
100 /usr/X386/lib/X11/app-defaults \
101 /usr/X11/lib/X11/app-defaults \
102 /usr/X11R6/lib/app-defaults \
103 /usr/X11R5/lib/app-defaults \
104 /usr/X11R4/lib/app-defaults \
105 /usr/X386/lib/app-defaults \
106 /usr/X11/lib/app-defaults \
107 /usr/lib/X11R6/app-defaults \
108 /usr/lib/X11R5/app-defaults \
109 /usr/lib/X11R4/app-defaults \
110 /usr/lib/X386/app-defaults \
111 /usr/lib/X11/app-defaults \
112 /usr/openwin/lib/app-defaults"
114 findfile X11INC "/usr/X11R6/include \
115 /usr/X11R5/include \
116 /usr/X11R4/include \
117 /usr/X386/include \
118 /usr/X11/include \
119 /usr/include/X11R6 \
120 /usr/include/X11R5 \
121 /usr/include/X11R4 \
122 /usr/include/X11 \
123 /usr/openwin/include"
125 findfile X11LIB "/usr/X11R6/lib \
126 /usr/X11R5/lib \
127 /usr/X11R4/lib \
128 /usr/X386/lib \
129 /usr/X11/lib \
130 /usr/lib/X11R6 \
131 /usr/lib/X11R5 \
132 /usr/lib/X11R4 \
133 /usr/lib/X11 \
134 /usr/openwin/lib"
137 # provide worst-case defaults
139 : ${CC:=cc}
140 : ${RANLIB:=$TRUE}
141 : ${READDIR:=/lib}
142 : ${DEST}:=.}
143 : ${CPP:=$CAT}
144 : ${X11DEF:=.}
145 : ${X11INC:=.}
146 : ${X11LIB:=.}
148 CC=`basename $CC`
149 RANLIB=`basename $RANLIB`
150 READDIR=`dirname $READDIR`
151 CONTRIBDIR=none
153 if [ $CC = gcc ]; then CCOPTS=-O3; else CCOPTS=-O; fi
156 # defaults for known architectures that fail the above
158 case `uname -rs` in
159 HP-UX*) RANLIB=true;;
160 SunOS?5.*) CCOPTS="$CCOPTS -D_XOPEN_SOURCE";;
161 Irix*) if [ $CC = cc ]; then CCOPTS="$CCOPTS -Wf,-XNl16384"; fi;;
162 esac
165 # parse command line arguments
167 for arg in $*; do
168 case $arg in
169 -h | --help) help;;
171 --cc=*) parse CC $arg;;
172 --cpp=*) parse CPP $arg;;
173 --prefix=*) parse DEST $arg;;
174 --ccopts=*) parse CCOPTS $arg;;
175 --syslibs=*) parse SYSLIBS $arg;;
176 --x-defaults=*) parse X11DEF $arg;;
177 --x-includes=*) parse X11INC $arg;;
178 --x-libraries=*) parse X11LIB $arg;;
179 --readline=*) parse READDIR $arg;;
181 CFLAGS=*) parse CCOPTS $arg;;
183 --contrib) CONTRIBFLAGS=-DCONTRIB; CONTRIBDIR=contrib;;
184 --contrib=y) CONTRIBFLAGS=-DCONTRIB; CONTRIBDIR=contrib;;
185 --contrib=yes) CONTRIBFLAGS=-DCONTRIB; CONTRIBDIR=contrib;;
186 esac
187 done
190 # determine the readline library options
192 if [ -f $READDIR/libreadline.a ]; then
193 READLINE=-DREADLINE
194 READLIBS="-L$READDIR -lreadline -ltermcap"
195 else
196 READDIR=none
197 READLINE=
198 READLIBS=
202 # print defaults
204 echo " C compiler =" $CC
205 echo " C compiler options =" $CCOPTS
206 echo " C preprocessor =" $CPP
207 echo " ranlib program =" $RANLIB
208 echo " destination prefix =" $DEST
209 echo " readline library directory =" $READDIR
210 echo " X11 application defaults =" $X11DEF
211 echo " X11 include directory =" $X11INC
212 echo " X11 library directory =" $X11LIB
215 # create Makefile.conf
217 cat > ./etc/Makefile.conf << EOF
218 AR = ar
219 CC = $CC
220 CCOPTS = $CCOPTS
221 CONTRIBDIR = $CONTRIBDIR
222 CONTRIBFLAGS = $CONTRIBFLAGS
223 CPP = $CPP
224 DESTBIN = $DEST/bin
225 DESTLIB = $DEST/lib/felt
226 DESTMAN = $DEST/man
227 INSTALL = sh \$(TOPDIR)/etc/install.sh -c
228 LDOPTS =
229 LIBELT = \$(TOPDIR)/lib/Elements/libelt.a
230 LIBFELT = \$(TOPDIR)/lib/Felt/libfelt.a
231 LIBGEN = \$(TOPDIR)/lib/Generate/libgen.a
232 LIBGEOMPACK = \$(TOPDIR)/lib/Geompack/libgeompack.a
233 LIBMTX = \$(TOPDIR)/lib/Matrix/libmtx.a
234 LIBWIDGETS = \$(TOPDIR)/lib/Widgets/libwidgets.a
235 MKDIR = sh \$(TOPDIR)/etc/mkdirhier.sh
236 RANLIB = $RANLIB
237 READLINE = $READLINE
238 READLIBS = $READLIBS
239 RM = rm -f
240 SYSLIBS =
241 X11DEF = $X11DEF
242 X11INC = $X11INC
243 X11LIB = $X11LIB
246 exit 0