source: trunk/optimizer/src/pgapack/pgapack/configure.in @ 986

Last change on this file since 986 was 816, checked in by liveletlive, 17 years ago

Committing the newer version of PGAPack.

File size: 16.5 KB
Line 
1#!/bin/sh
2# This file is configure.
3#
4# Make all changes to configure.in, if at all possible.  After changing,
5# run "autoconf".  If autoconf is not installed, then make changes to
6# configure.
7#
8# Documentation on the autoconf program exists in GNU info file format.
9# To read this, run emacs and type C-h i.  Then press the down arrow
10# until you come to the line beginning "* Autoconf:".  Pressing enter on
11# this line will bring up the documentaition.
12#
13# Type "configure" (i.e., no arguments) or read below for usage information.
14#
15print_error() {
16    echo "$*" 2>&1 ;
17}
18
19print_usage()
20{
21cat <<.
22Usage: configure -arch ARCH_TYPE [-cc CC] [-f77 FC] [-debug] [-help]
23                 [-cflags CFLAGS] [-fflags FFLAGS]
24                 [-mpiinc MPI_INC_DIR -mpilib MPI_LIB]
25where
26   ARCH_TYPE    = the type of machine that PGAPack is to be configured for
27   CC           = the name of the ANSI C compiler
28   FC           = the name of the FORTRAN 77 compiler
29   CFLAGS       = C compiler flags
30   FFLAGS       = FORTRAN compiler flags
31   MPI_INC_DIR  = the MPI include directory
32   MPI_LIB      = the full path to the MPI library
33
34
35Known architectures are:
36
37Workstations
38        sun4            (SUN OS 4.x)
39        hpux            (HP UX)
40        irix            (Silicon Graphics IRIX)
41        alpha           (DEC Alpha)
42        rs6000          (AIX for IBM RS6000)   
43        next            (NeXT 680x0)
44        freebsd         (PC clones running FreeBSD)
45        linux           (PC clones running LINUX)
46        generic         (Generic 32-bit UNIX-like machine)
47
48MPP's
49        powerchallenge  (Silicon Graphics PowerChallenge)
50        challenge       (Silicon Graphics Challenge)
51        t3d             (Cray-T3D)
52        sp2             (IBM SP2)
53        paragon         (Intel Paragon)
54        exemplar        (Convex Exemplar)
55
56
57In the absence of the -f77 or -cc options, configure assumes the name of
58a FORTRAN 77 or ANSI C compiler based on the architecture type.
59
60If the -debug flag is set, then PGAPack will be built for debugging.  This
61enables the extensive debugging options and datatype checks.
62
63If both -mpiinc and -mpilib are missing, PGAPack is built using a non-parallel
64"stub" library for all MPI calls.
65
66The -help flag causes this usage guide to be printed.
67
68Example 1:
69----------
70Configure and build for parallel operation on the sun4 architectue.  MPI is
71in /usr/local/mpi; the MPI library is /usr/local/mpi/lib/sun4/ch_p4/libmpi.a.
72
73  configure -arch sun4 -mpilib /usr/local/mpi/lib/sun4/ch_p4/libmpi.a \
74            -mpiinc /usr/local/mpi/include
75  make install
76
77Example 2:
78----------
79Configure and build a debug sequential library on the rs6000 architecture.
80
81  configure -arch rs6000 -debug
82  make install
83.
84}
85
86###############################################################################
87# This section initializes the variables that will be used throughout
88# the script.
89###############################################################################
90AC_INIT(source/pga.c)
91ARCH=""                         # architecture type
92PARALLEL=0                      # parallel libray, or use stub routines?
93OPTIMIZE=1                      # optimized?
94CPPFLAGS=""                     # flags to send to the C preprocessor
95LDFLAGS=""                      # link flags
96CFLAGS=""                       # flags to send to the C compiler
97FFLAGS=""                       # flags to send to the FORTRAN compiler
98PGA_DIR="`pwd`"                 # the root of the pgapack tree
99PGA_DIR=`echo $PGA_DIR | sed "s=tmp_mnt/=="`    # get rid of 'tmp_mnt/'
100HEADERS="$PGA_DIR/include/pgapack.h" # headers upon which pgapack depends
101INCLUDES="-I$PGA_DIR/include"   # directories where to search for include files
102LIB_DIRS=""                     # directories where to search for libraries
103LIBS=""                         # libraries with which to link
104MPI_INC_DIR=""
105MPI_LIB=""
106SHELL="/usr/bin/sh"
107RM="/bin/rm -f"                 # command to force removal of files
108
109OBJS='$(PGA_LIB_DIR)/binary.o        \\\
110      $(PGA_LIB_DIR)/char.o          \\\
111      $(PGA_LIB_DIR)/cmdline.o       \\\
112      $(PGA_LIB_DIR)/create.o        \\\
113      $(PGA_LIB_DIR)/cross.o         \\\
114      $(PGA_LIB_DIR)/debug.o         \\\
115      $(PGA_LIB_DIR)/duplcate.o      \\\
116      $(PGA_LIB_DIR)/evaluate.o      \\\
117      $(PGA_LIB_DIR)/fitness.o       \\\
118      $(PGA_LIB_DIR)/hamming.o       \\\
119      $(PGA_LIB_DIR)/heap.o          \\\
120      $(PGA_LIB_DIR)/integer.o       \\\
121      $(PGA_LIB_DIR)/mutation.o      \\\
122      $(PGA_LIB_DIR)/parallel.o      \\\
123      $(PGA_LIB_DIR)/pga.o           \\\
124      $(PGA_LIB_DIR)/pop.o           \\\
125      $(PGA_LIB_DIR)/random.o        \\\
126      $(PGA_LIB_DIR)/real.o          \\\
127      $(PGA_LIB_DIR)/report.o        \\\
128      $(PGA_LIB_DIR)/restart.o       \\\
129      $(PGA_LIB_DIR)/select.o        \\\
130      $(PGA_LIB_DIR)/stop.o          \\\
131      $(PGA_LIB_DIR)/system.o        \\\
132      $(PGA_LIB_DIR)/user.o          \\\
133      $(PGA_LIB_DIR)/utility.o'      # these are pgapack's object files
134
135###############################################################################
136# This section parse the command line options. There a two types of options:
137# those that take arguments and those that don't.  Parsing the case where an
138# option takes an argument is a little tricky.  This is how it works.  Suppose
139# that the program comes upon "-cc".  Then we know that the next argument
140# will be the name of the C compiler.  Hence, we set the flag next_cc to be
141# equal to "yes".  The next time through the loop, it will be the case that
142# x$next_cc equal "xyes" because $next_cc expands to "yes".  Thus, we know that
143# this argument is the name of the compiler and we assign it to USR_CC.  Then
144# we set next_cc back to a null string.  This way on the next time through
145# the loop x$next_cc will equal just "x".  Since the shell initializes
146# variables to null strings, we do not have to initialize the "next_" family
147# of variables by hand.
148###############################################################################
149for arg
150do
151    if test x$next_arch = xyes
152        then
153            ARCH=$arg
154            next_arch=
155        elif test x$next_mpiinc = xyes
156            then
157                MPI_INC_DIR=$arg
158                next_mpiinc=
159        elif test x$next_mpilib = xyes
160            then
161                MPI_LIB=$arg
162                next_mpilib=
163        elif test x$next_f77 = xyes
164            then
165                USR_FC=$arg
166                next_f77=
167        elif test x$next_cc = xyes
168            then
169                USR_CC=$arg
170                next_cc=
171        elif test x$next_cflags = xyes
172            then
173                CFLAGS="$arg $CFLAGS"
174                next_cflags=
175        elif test x$next_fflags = xyes
176            then
177                FFLAGS="$arg $FFLAGS"
178                next_fflags=
179        else
180            case $arg in
181                -arch)
182                    next_arch=yes
183                    ;;
184                -f77)
185                    next_f77=yes
186                    ;;
187                -cc)
188                    next_cc=yes
189                    ;;
190                -mpiinc)
191                    next_mpiinc=yes
192                    PARALLEL=1
193                    ;;
194                -mpilib)
195                    next_mpilib=yes
196                    PARALLEL=1
197                    ;;
198                -debug)
199                    OPTIMIZE=0
200                    ;;
201                -cflags)
202                    next_cflags=yes
203                    ;;
204                -fflags)
205                    next_fflags=yes
206                    ;;
207                -help)
208                    print_usage >& 2
209                    exit 1
210                    ;;
211                *)
212                    ;;
213            esac
214    fi
215done
216
217if test "$MPI_LIB" -a "$MPI_INC_DIR" ; then
218    if test ! -d "$MPI_INC_DIR" ; then
219        print_error "MPI_INC_DIR == $MPI_INC_DIR is not a valid directory!"
220        exit 1
221    fi
222    if test ! -f "$MPI_INC_DIR/mpi.h" ; then
223        print_error "Couldn't find $MPI_INC_DIR/mpi.h!"
224        exit 1
225    fi
226
227    if test ! -f "$MPI_LIB" ; then
228        print_error "MPI_LIB == $MPI_LIB is not a file!"
229        exit 1
230    fi
231
232    PARALLEL=1
233else
234    PARALLEL=0
235    CPPFLAGS="-DFAKE_MPI $CPPFLAGS"
236fi
237
238if test $OPTIMIZE -eq 1 ; then
239        CPPFLAGS="-DOPTIMIZE $CPPFLAGS"
240        CFLAGS="-O $CFLAGS"
241        FFLAGS="-O $FFLAGS"
242        PGA_LIB="pgaO"
243else
244        CFLAGS="-g $CFLAGS"
245        FFLAGS="-g $FFLAGS"
246        PGA_LIB="pgag"
247fi
248
249
250###############################################################################
251# This section sets the default values of certain variables based upon the
252# architecture type specified.  If no architecture was specified, the script
253# issues an error and aborts.
254###############################################################################
255if test -z "$ARCH"
256    then
257        print_error "You must specify the architecture with -arch <value>"
258        print_error "Valid architectures are the following:"   
259        print_error " Workstations      MPP's"
260        print_error "    sun4        powerchallenge"
261        print_error "    next        challenge"
262        print_error "    rs6000      t3d"
263        print_error "    freebsd     sp2"
264        print_error "    irix        paragon"
265        print_error "    linux       exemplar"
266        print_error "    hpux"
267        print_error "    alpha"
268        print_error "    generic"
269        print_error ""
270        print_error "For more information type configure -help."
271        exit 1
272fi
273
274case $ARCH in
275    sun4)
276        CC=cc
277        FC=f77
278        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
279        ;;
280    next)
281        CC=cc
282        FC=
283        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
284        ;;
285    rs6000)
286        CC=cc
287        FC=f77
288        CPPFLAGS="-DWL=32 $CPPFLAGS"
289        ;;
290    freebsd)
291        CC=cc
292        FC=f77
293        FFLAGS="-w"
294        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
295        ;;
296    irix)
297        CC=cc
298        FC=f77
299        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
300        ;;
301    alpha)
302        CC=cc
303        FC=f77
304        CPPFLAGS="-DWL=64 -DFORTRANUNDERSCORE $CPPFLAGS"
305        ;;
306    hpux)
307        CC=cc
308        FC=f77
309        CPPFLAGS="-DWL=32 $CPPFLAGS"
310        SHELL=/bin/sh
311        ;;
312    linux)
313        SHELL="/bin/sh"
314        CC=cc
315        FC=f77
316        FFLAGS="-w"
317        LDFLAGS="-s $LDFLAGS"
318        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
319        ;;
320    t3d)
321        CC=/mpp/bin/cc
322        FC=/mpp/bin/cf77
323        CFLAGS="-T cray-t3d"
324        FFLAGS="-C cray-t3d -dp"
325        CPPFLAGS="-DWL=64 -DFORTRANCAP $CPPFLAGS"
326        SHELL=/bin/sh
327        ;;
328    powerchallenge)
329        CC=cc
330        FC=f77
331        CFLAGS="-mips4 -fullwarn -64"
332        CPPFLAGS="-DWL=64 -DFORTRANUNDERSCORE $CPPFLAGS"
333        ;;
334    challenge)
335        CC=cc
336        FC=f77
337        CFLAGS="-mips2 -fullwarn -32"
338        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
339        ;;
340    paragon)
341        CC=cc
342        FC=f77
343        CFLAGS="-nx $CFLAGS"
344        FFLAGS="-nx $FFLAGS"
345        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
346        ;;
347    sp2)
348        CC=cc
349        FC=f77
350        CPPFLAGS="-DWL=32 $CPPFLAGS"
351        ;;
352    exemplar)
353        CC=cc
354        FC=fort77
355        FFLAGS="-L/usr/lib -lU77 $FFLAGS"
356        CPPFLAGS="-DWL=32 $CPPFLAGS"
357        SHELL=/bin/sh
358        ;;
359    *)
360        CC=cc
361        FC=f77
362        CPPFLAGS="-DWL=32 $CPPFLAGS"
363        print_error "WARNING:  Configuring for untested architecture.  Using"
364        print_error "          word size of 32 bits, cc and f77 as compilers."
365        print_error "          You might have trouble with Fortran programs"
366        print_error "          not linking correctly.  Check the manual on"
367        print_error "          the FORTRANUNDERSCORE #define."
368        ;;
369esac
370
371###############################################################################
372# This section sets the variables that do not relate to parallel code.
373###############################################################################
374CPPFLAGS="-D$ARCH $CPPFLAGS"
375PGA_LIB_DIR="../lib/$ARCH"
376LIB_DIRS="-L$PGA_DIR/lib/$ARCH $LIB_DIRS"
377LIBS="-l$PGA_LIB $LIBS"
378
379#     Set output variable `RANLIB' to `ranlib' if `ranlib' is found,
380#     otherwise to `:' (do nothing).
381AC_PROG_RANLIB()
382
383#    "Determine a C compiler to use.  If `CC' is not already set in the
384#     environment, check for `gcc', and use `cc' if it's not found.  Set
385#     output variable `CC' to the name of the compiler found.
386#
387#    "If using the GNU C compiler, set shell variable `GCC' to `yes',
388#     empty otherwise.  If output variable `CFLAGS' was not already set,
389#     set it to `-g -O' for the GNU C compiler (`-O' on systems where
390#     GCC does not accept `-g'), or `-g' for other compilers."
391if test -n "$USR_CC"
392     then
393          CC=$USR_CC
394     else
395          AC_PROG_CC()
396fi
397
398#     Check for each program in the whitespace-separated list
399#     PROGS-TO-CHECK-FOR exists in `PATH'.  If it is found, set VARIABLE
400#     to the name of that program.  Otherwise, continue checking the
401#     next program in the list.  If none of the programs in the list are
402#     found, set VARIABLE to VALUE-IF-NOT-FOUND; if VALUE-IF-NOT-FOUND
403#     is not specified, the value of VARIABLE is not changed.
404if test -n "$USR_FC"
405     then
406          FC=$USR_FC
407     else
408          AC_PROGRAMS_CHECK(FC, f77 fortran xlf gf77 mpxlf if77)
409fi
410
411# Originally had
412#                     OBJS="$OBJS $(PGA_LIB_DIR)/f2c.o"
413# However, freebsd bourne shell equates $(var) and `var`.  Hence, I had
414# to break the assignment up into two parts.  $FORTWRAP is a Makefile
415# dependency line defining how to compile f2c.c
416if test -n "$FC"
417    then
418        TEMP='$(PGA_LIB_DIR)/f2c.o'
419        OBJS="$OBJS $TEMP"
420        FORTWRAP='$(PGA_LIB_DIR)/f2c.o: f2c.c $(HEADERS)\
421        $(COMPILE.c) f2c.c'
422fi
423
424if test ! -d lib
425    then
426        mkdir lib
427fi
428
429if test ! -d lib/$ARCH
430    then
431        mkdir lib/$ARCH
432fi
433
434#  Set up symlinks for pgapackf.h to any directories with Fortran source
435rm -f ./examples/fortran/pgapackf.h ./examples/mgh/pgapackf.h ./test/pgapackf.h
436ln -s ../../include/pgapackf.h ./examples/fortran/pgapackf.h
437ln -s ../../include/pgapackf.h ./examples/mgh/pgapackf.h
438ln -s ../include/pgapackf.h    ./test/pgapackf.h
439
440#  Use the stub library.
441if test $PARALLEL -eq 0
442  then
443    rm -f ./include/mpi.h ./include/mpif.h ./examples/fortran/mpif.h ./examples/mgh/mpif.h ./test/mpif.h
444    ln -s fakempi_h include/mpi.h
445    ln -s fakempif_h include/mpif.h
446    ln -s ../../include/mpif.h ./examples/fortran/mpif.h
447    ln -s ../../include/mpif.h ./examples/mgh/mpif.h
448    ln -s ../include/mpif.h ./test/mpif.h
449    TEMP='$(PGA_LIB_DIR)/mpi_stub.o'
450    OBJS="$OBJS $TEMP"
451    MPICOMP='$(PGA_LIB_DIR)/mpi_stub.o: mpi_stub.c $(HEADERS)\
452        $(COMPILE.c) mpi_stub.c'
453#  The tab above is IMPORTANT!  Needed for make!
454else
455    rm -f ./include/mpi.h ./include/mpif.h ./examples/fortran/mpif.h ./examples/mgh/mpif.h ./test/mpif.h
456    ln -s $MPI_INC_DIR/mpif.h ./examples/fortran/mpif.h
457    ln -s $MPI_INC_DIR/mpif.h ./examples/mgh/mpif.h
458    ln -s $MPI_INC_DIR/mpif.h ./test/mpif.h
459    LIBS="$LIBS $MPI_LIB"
460    INCLUDES="$INCLUDES -I$MPI_INC_DIR"
461fi
462
463LIBS="$LIBS -lm"
464CPPFLAGS="$INCLUDES $CPPFLAGS"
465LDFLAGS="$LDFLAGS $LIB_DIRS $LIBS"
466###############################################################################
467# This section exports the variables that have previously been set.
468# Configure creates the Makefiles listed on the last line from the
469# Makefile.in in each directory.  It does this by substituting the value
470# of $VAR for every occurent of @VAR@ in the Makefile.in.  For
471# example, if the characters @CC@ occur any place in a Makefile.in, they
472# will be replaced with the value that $CC has when ac_subst(CC) is
473# called.
474###############################################################################
475AC_SUBST(CC)
476AC_SUBST(CFLAGS)
477AC_SUBST(FFLAGS)
478AC_SUBST(CPPFLAGS)
479AC_SUBST(FC)
480AC_SUBST(FORTWRAP)
481AC_SUBST(HEADERS)
482AC_SUBST(LDFLAGS)
483AC_SUBST(PARALLEL)
484AC_SUBST(PGA_LIB_DIR)
485AC_SUBST(PGA_LIB)
486AC_SUBST(OBJS)
487AC_SUBST(MPICOMP)
488AC_SUBST(RM)
489AC_SUBST(RANLIB)
490AC_SUBST(SHELL)
491AC_OUTPUT(Makefile source/Makefile test/Makefile test/Makefile \
492          examples/Makefile examples/c/Makefile examples/fortran/Makefile \
493          examples/mgh/Makefile)
494
495if test ! -f ".pgapack" ; then
496  if test $PARALLEL -eq 1 ; then
497      OPERATION="parallel"
498      ECHO_LIBS="$MPI_LIB"
499  else
500      OPERATION="sequential"
501      ECHO_LIBS="stub routines in mpi_stub.c"
502  fi
503  if test $OPTIMIZE -eq 1 ; then
504      OPERATION="optimized $OPERATION"
505  else
506      OPERATION="debug $OPERATION"
507  fi
508  echo " "
509  echo "PGAPack has been configured for $OPERATION operation on"
510  echo "the $ARCH architecture, using $ECHO_LIBS."
511  echo " "
512  echo "**********************************************************************"
513  echo "*  Please register your copy of PGAPack by sending a mail message    *"
514  echo "*  to pgapack@mcs.anl.gov.  This will allow us to notify you of bug  *"
515  echo "*  fixes, enhancements, and new releases. The PGAPack homepage is at *"
516  echo "*  http://www.mcs.anl.gov/pgapack.html.                              *"
517  echo "**********************************************************************"
518  echo " "
519  echo "Type \"make install\" to install PGAPack."
520  echo " "
521fi
522
523
Note: See TracBrowser for help on using the repository browser.