File: configure.in

package info (click to toggle)
pgapack 1.1.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,548 kB
  • ctags: 1,829
  • sloc: ansic: 10,331; fortran: 2,985; sh: 486; makefile: 462; perl: 105
file content (516 lines) | stat: -rw-r--r-- 16,400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
#!/bin/sh
# This file is configure.
#
# Make all changes to configure.in, if at all possible.  After changing,
# run "autoconf".  If autoconf is not installed, then make changes to
# configure.
#
# Documentation on the autoconf program exists in GNU info file format.
# To read this, run emacs and type C-h i.  Then press the down arrow
# until you come to the line beginning "* Autoconf:".  Pressing enter on
# this line will bring up the documentaition.
#
# Type "configure" (i.e., no arguments) or read below for usage information.
#
print_error() {
    echo "$*" 2>&1 ;
}

print_usage()
{
cat <<.
Usage: configure -arch ARCH_TYPE [-cc CC] [-f77 FC] [-debug] [-help]
                 [-cflags CFLAGS] [-fflags FFLAGS]
                 [-mpiinc MPI_INC_DIR -mpilib MPI_LIB]
where
   ARCH_TYPE    = the type of machine that PGAPack is to be configured for
   CC           = the name of the ANSI C compiler
   FC           = the name of the FORTRAN 77 compiler
   CFLAGS       = C compiler flags
   FFLAGS       = FORTRAN compiler flags
   MPI_INC_DIR  = the MPI include directory
   MPI_LIB      = the full path to the MPI library


Known architectures are:

Workstations
	sun4		(SUN OS 4.x)
	hpux		(HP UX)
	irix    	(Silicon Graphics IRIX)
	alpha		(DEC Alpha)
	rs6000		(AIX for IBM RS6000)	
	next		(NeXT 680x0)
	freebsd		(PC clones running FreeBSD)
	linux		(PC clones running LINUX)
	generic		(Generic 32-bit UNIX-like machine)

MPP's
	powerchallenge	(Silicon Graphics PowerChallenge)
	challenge	(Silicon Graphics Challenge)
	t3d		(Cray-T3D)
	sp2		(IBM SP2)
	paragon		(Intel Paragon)
	exemplar	(Convex Exemplar)


In the absence of the -f77 or -cc options, configure assumes the name of 
a FORTRAN 77 or ANSI C compiler based on the architecture type.

If the -debug flag is set, then PGAPack will be built for debugging.  This
enables the extensive debugging options and datatype checks.

If both -mpiinc and -mpilib are missing, PGAPack is built using a non-parallel
"stub" library for all MPI calls.

The -help flag causes this usage guide to be printed.

Example 1:
----------
Configure and build for parallel operation on the sun4 architectue.  MPI is
in /usr/local/mpi; the MPI library is /usr/local/mpi/lib/sun4/ch_p4/libmpi.a.

  configure -arch sun4 -mpilib /usr/local/mpi/lib/sun4/ch_p4/libmpi.a \
            -mpiinc /usr/local/mpi/include
  make install

Example 2:
----------
Configure and build a debug sequential library on the rs6000 architecture.

  configure -arch rs6000 -debug
  make install
.
}

###############################################################################
# This section initializes the variables that will be used throughout
# the script.
###############################################################################
AC_INIT(source/pga.c)
ARCH=""                         # architecture type
PARALLEL=0                      # parallel libray, or use stub routines?
OPTIMIZE=1                      # optimized?
CPPFLAGS=""                     # flags to send to the C preprocessor
LDFLAGS=""                      # link flags
CFLAGS=""                       # flags to send to the C compiler
FFLAGS=""                       # flags to send to the FORTRAN compiler
PGA_DIR="`pwd`"                 # the root of the pgapack tree
PGA_DIR=`echo $PGA_DIR | sed "s=tmp_mnt/=="`    # get rid of 'tmp_mnt/'
HEADERS="$PGA_DIR/include/pgapack.h" # headers upon which pgapack depends
INCLUDES="-I$PGA_DIR/include"   # directories where to search for include files
LIB_DIRS=""                     # directories where to search for libraries
LIBS=""                         # libraries with which to link
MPI_INC_DIR=""
MPI_LIB=""
SHELL="/usr/bin/sh"
RM="/bin/rm -f"                 # command to force removal of files

OBJS='$(PGA_LIB_DIR)/binary.o        \\\
      $(PGA_LIB_DIR)/char.o          \\\
      $(PGA_LIB_DIR)/cmdline.o       \\\
      $(PGA_LIB_DIR)/create.o        \\\
      $(PGA_LIB_DIR)/cross.o         \\\
      $(PGA_LIB_DIR)/debug.o         \\\
      $(PGA_LIB_DIR)/duplcate.o      \\\
      $(PGA_LIB_DIR)/evaluate.o      \\\
      $(PGA_LIB_DIR)/fitness.o       \\\
      $(PGA_LIB_DIR)/hamming.o       \\\
      $(PGA_LIB_DIR)/heap.o          \\\
      $(PGA_LIB_DIR)/integer.o       \\\
      $(PGA_LIB_DIR)/mutation.o      \\\
      $(PGA_LIB_DIR)/parallel.o      \\\
      $(PGA_LIB_DIR)/pga.o           \\\
      $(PGA_LIB_DIR)/pop.o           \\\
      $(PGA_LIB_DIR)/random.o        \\\
      $(PGA_LIB_DIR)/real.o          \\\
      $(PGA_LIB_DIR)/report.o        \\\
      $(PGA_LIB_DIR)/restart.o       \\\
      $(PGA_LIB_DIR)/select.o        \\\
      $(PGA_LIB_DIR)/stop.o          \\\
      $(PGA_LIB_DIR)/system.o        \\\
      $(PGA_LIB_DIR)/user.o          \\\
      $(PGA_LIB_DIR)/utility.o'      # these are pgapack's object files

###############################################################################
# This section parse the command line options. There a two types of options:
# those that take arguments and those that don't.  Parsing the case where an
# option takes an argument is a little tricky.  This is how it works.  Suppose
# that the program comes upon "-cc".  Then we know that the next argument
# will be the name of the C compiler.  Hence, we set the flag next_cc to be
# equal to "yes".  The next time through the loop, it will be the case that
# x$next_cc equal "xyes" because $next_cc expands to "yes".  Thus, we know that
# this argument is the name of the compiler and we assign it to USR_CC.  Then
# we set next_cc back to a null string.  This way on the next time through
# the loop x$next_cc will equal just "x".  Since the shell initializes
# variables to null strings, we do not have to initialize the "next_" family
# of variables by hand.
###############################################################################
for arg
do
    if test x$next_arch = xyes
        then
            ARCH=$arg
            next_arch=
        elif test x$next_mpiinc = xyes
            then
                MPI_INC_DIR=$arg
                next_mpiinc=
        elif test x$next_mpilib = xyes
            then
                MPI_LIB=$arg
                next_mpilib=
        elif test x$next_f77 = xyes
            then
                USR_FC=$arg
                next_f77=
        elif test x$next_cc = xyes
            then
                USR_CC=$arg
                next_cc=
        elif test x$next_cflags = xyes
            then
                CFLAGS="$arg $CFLAGS"
                next_cflags=
        elif test x$next_fflags = xyes
            then
                FFLAGS="$arg $FFLAGS"
                next_fflags=
        else
            case $arg in
                -arch)
                    next_arch=yes
                    ;;
                -f77)
                    next_f77=yes
                    ;;
                -cc)
                    next_cc=yes
                    ;;
                -mpiinc)
                    next_mpiinc=yes
                    PARALLEL=1
                    ;;
                -mpilib)
                    next_mpilib=yes
                    PARALLEL=1
                    ;;
                -debug)
                    OPTIMIZE=0
                    ;;
                -cflags)
                    next_cflags=yes
                    ;;
                -fflags)
                    next_fflags=yes
                    ;;
                -help)
                    print_usage >& 2
                    exit 1
                    ;;
                *) 
                    ;;
            esac
    fi
done

if test "$MPI_LIB" -a "$MPI_INC_DIR" ; then
    if test ! -d "$MPI_INC_DIR" ; then
        print_error "MPI_INC_DIR == $MPI_INC_DIR is not a valid directory!"
        exit 1
    fi
    if test ! -f "$MPI_INC_DIR/mpi.h" ; then
        print_error "Couldn't find $MPI_INC_DIR/mpi.h!"
        exit 1
    fi

    if test ! -f "$MPI_LIB" ; then
        print_error "MPI_LIB == $MPI_LIB is not a file!"
        exit 1
    fi

    PARALLEL=1
else
    PARALLEL=0
    CPPFLAGS="-DFAKE_MPI $CPPFLAGS"
fi

if test $OPTIMIZE -eq 1 ; then
	CPPFLAGS="-DOPTIMIZE $CPPFLAGS"
	CFLAGS="-O $CFLAGS"
	FFLAGS="-O $FFLAGS"
	PGA_LIB="pgaO"
else
	CFLAGS="-g $CFLAGS"
	FFLAGS="-g $FFLAGS"
	PGA_LIB="pgag"
fi


###############################################################################
# This section sets the default values of certain variables based upon the
# architecture type specified.  If no architecture was specified, the script
# issues an error and aborts.
###############################################################################
if test -z "$ARCH"
    then
        print_error "You must specify the architecture with -arch <value>"
        print_error "Valid architectures are the following:"	
	print_error " Workstations      MPP's"
	print_error "    sun4        powerchallenge"
	print_error "    next        challenge"
	print_error "    rs6000      t3d"
	print_error "    freebsd     sp2"
	print_error "    irix        paragon"
	print_error "    linux       exemplar"
	print_error "    hpux"
	print_error "    alpha"
	print_error "    generic"
	print_error ""
	print_error "For more information type configure -help."
        exit 1
fi

case $ARCH in
    sun4)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    next)
        CC=cc
        FC=
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    rs6000)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 $CPPFLAGS"
        ;;
    freebsd)
        CC=cc
        FC=f77
	FFLAGS="-w"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    irix)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    alpha)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=64 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    hpux)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 $CPPFLAGS"
	SHELL=/bin/sh
        ;;
    linux)
	SHELL="/bin/sh"
        CC=cc
        FC=f77
	FFLAGS="-w"
	LDFLAGS="-s $LDFLAGS"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    t3d)
        CC=/mpp/bin/cc
        FC=/mpp/bin/cf77
        CFLAGS="-T cray-t3d"
        FFLAGS="-C cray-t3d -dp"
        CPPFLAGS="-DWL=64 -DFORTRANCAP $CPPFLAGS"
	SHELL=/bin/sh
        ;;
    powerchallenge)
        CC=cc
        FC=f77
	CFLAGS="-mips4 -fullwarn -64"
        CPPFLAGS="-DWL=64 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    challenge)
        CC=cc
        FC=f77
	CFLAGS="-mips2 -fullwarn -32"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    paragon)
        CC=cc
        FC=f77
        CFLAGS="-nx $CFLAGS"
        FFLAGS="-nx $FFLAGS"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    sp2)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 $CPPFLAGS"
        ;;
    exemplar)
        CC=cc
        FC=fort77
	FFLAGS="-L/usr/lib -lU77 $FFLAGS"
        CPPFLAGS="-DWL=32 $CPPFLAGS"
	SHELL=/bin/sh
        ;;
    *)
	CC=cc
	FC=f77
	CPPFLAGS="-DWL=32 $CPPFLAGS"
	print_error "WARNING:  Configuring for untested architecture.  Using"
        print_error "          word size of 32 bits, cc and f77 as compilers."
	print_error "          You might have trouble with Fortran programs"
        print_error "          not linking correctly.  Check the manual on"
        print_error "          the FORTRANUNDERSCORE #define."
	;;
esac

###############################################################################
# This section sets the variables that do not relate to parallel code.
###############################################################################
CPPFLAGS="-D$ARCH $CPPFLAGS"
PGA_LIB_DIR="../lib/$ARCH"
LIB_DIRS="-L$PGA_DIR/lib/$ARCH $LIB_DIRS"
LIBS="-l$PGA_LIB $LIBS"

#     Set output variable `RANLIB' to `ranlib' if `ranlib' is found,
#     otherwise to `:' (do nothing).
AC_PROG_RANLIB()

#    "Determine a C compiler to use.  If `CC' is not already set in the
#     environment, check for `gcc', and use `cc' if it's not found.  Set
#     output variable `CC' to the name of the compiler found.
#
#    "If using the GNU C compiler, set shell variable `GCC' to `yes',
#     empty otherwise.  If output variable `CFLAGS' was not already set,
#     set it to `-g -O' for the GNU C compiler (`-O' on systems where
#     GCC does not accept `-g'), or `-g' for other compilers."
if test -n "$USR_CC"
     then
          CC=$USR_CC
     else
          AC_PROG_CC()
fi

#     Check for each program in the whitespace-separated list
#     PROGS-TO-CHECK-FOR exists in `PATH'.  If it is found, set VARIABLE
#     to the name of that program.  Otherwise, continue checking the
#     next program in the list.  If none of the programs in the list are
#     found, set VARIABLE to VALUE-IF-NOT-FOUND; if VALUE-IF-NOT-FOUND
#     is not specified, the value of VARIABLE is not changed.
if test -n "$USR_FC"
     then
          FC=$USR_FC
     else
          AC_PROGRAMS_CHECK(FC, f77 fortran xlf gf77 mpxlf if77)
fi

# Originally had
#                     OBJS="$OBJS $(PGA_LIB_DIR)/f2c.o"
# However, freebsd bourne shell equates $(var) and `var`.  Hence, I had
# to break the assignment up into two parts.  $FORTWRAP is a Makefile
# dependency line defining how to compile f2c.c
if test -n "$FC"
    then
	TEMP='$(PGA_LIB_DIR)/f2c.o'
        OBJS="$OBJS $TEMP"
        FORTWRAP='$(PGA_LIB_DIR)/f2c.o: f2c.c $(HEADERS)\
	$(COMPILE.c) f2c.c'
fi

if test ! -d lib
    then
        mkdir lib
fi

if test ! -d lib/$ARCH
    then
        mkdir lib/$ARCH
fi

#  Set up symlinks for pgapackf.h to any directories with Fortran source
rm -f ./examples/fortran/pgapackf.h ./examples/mgh/pgapackf.h ./test/pgapackf.h
ln -s ../../include/pgapackf.h ./examples/fortran/pgapackf.h
ln -s ../../include/pgapackf.h ./examples/mgh/pgapackf.h
ln -s ../include/pgapackf.h    ./test/pgapackf.h

#  Use the stub library.
if test $PARALLEL -eq 0
  then
    rm -f ./include/mpi.h ./include/mpif.h ./examples/fortran/mpif.h ./examples/mgh/mpif.h ./test/mpif.h
    ln -s fakempi_h include/mpi.h
    ln -s fakempif_h include/mpif.h
    ln -s ../../include/mpif.h ./examples/fortran/mpif.h
    ln -s ../../include/mpif.h ./examples/mgh/mpif.h
    ln -s ../include/mpif.h ./test/mpif.h
    TEMP='$(PGA_LIB_DIR)/mpi_stub.o'
    OBJS="$OBJS $TEMP"
    MPICOMP='$(PGA_LIB_DIR)/mpi_stub.o: mpi_stub.c $(HEADERS)\
	$(COMPILE.c) mpi_stub.c'
#  The tab above is IMPORTANT!  Needed for make!
else
    rm -f ./include/mpi.h ./include/mpif.h ./examples/fortran/mpif.h ./examples/mgh/mpif.h ./test/mpif.h
    ln -s $MPI_INC_DIR/mpif.h ./examples/fortran/mpif.h
    ln -s $MPI_INC_DIR/mpif.h ./examples/mgh/mpif.h
    ln -s $MPI_INC_DIR/mpif.h ./test/mpif.h
    LIBS="$LIBS $MPI_LIB"
    INCLUDES="$INCLUDES -I$MPI_INC_DIR"
fi

LIBS="$LIBS -lm"
CPPFLAGS="$INCLUDES $CPPFLAGS"
LDFLAGS="$LDFLAGS $LIB_DIRS $LIBS"
###############################################################################
# This section exports the variables that have previously been set.
# Configure creates the Makefiles listed on the last line from the
# Makefile.in in each directory.  It does this by substituting the value
# of $VAR for every occurent of @VAR@ in the Makefile.in.  For
# example, if the characters @CC@ occur any place in a Makefile.in, they
# will be replaced with the value that $CC has when ac_subst(CC) is
# called.
###############################################################################
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(FFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(FC)
AC_SUBST(FORTWRAP)
AC_SUBST(HEADERS)
AC_SUBST(LDFLAGS)
AC_SUBST(PARALLEL)
AC_SUBST(PGA_LIB_DIR)
AC_SUBST(PGA_LIB)
AC_SUBST(OBJS)
AC_SUBST(MPICOMP)
AC_SUBST(RM)
AC_SUBST(RANLIB)
AC_SUBST(SHELL)
AC_OUTPUT(Makefile source/Makefile test/Makefile test/Makefile \
	  examples/Makefile examples/c/Makefile examples/fortran/Makefile \
	  examples/mgh/Makefile)

if test ! -f ".pgapack" ; then
  if test $PARALLEL -eq 1 ; then
      OPERATION="parallel"
      ECHO_LIBS="$MPI_LIB"
  else
      OPERATION="sequential"
      ECHO_LIBS="stub routines in mpi_stub.c"
  fi
  if test $OPTIMIZE -eq 1 ; then
      OPERATION="optimized $OPERATION"
  else
      OPERATION="debug $OPERATION"
  fi
  echo " "
  echo "PGAPack has been configured for $OPERATION operation on"
  echo "the $ARCH architecture, using $ECHO_LIBS."
  echo " "
  echo "Type \"make install\" to install PGAPack."
  echo " "
fi