summaryrefslogtreecommitdiff
path: root/lib/make/configure.in
blob: 12e701bc446a4231903b0f5c1656f29236624931 (plain)
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
dnl @@
dnl    @file      configure.in
dnl    @date      Sun Jan 17 15:54:23 1999
dnl    @author    Tom Goodale
dnl    @desc 
dnl    
dnl    @enddesc 
dnl    @version $Id$
dnl  @@
dnl Process this file with autoconf to produce a configure script.

AC_REVISION($Id$)

dnl It looks like older versions of Autoconf don't quite qork properly under 
dnl cygwin.
AC_PREREQ(2.13)

dnl Starts here
AC_INIT()
AC_CONFIG_HEADER(cctk_Config.h)

dnl Check the system type
AC_CANONICAL_SYSTEM

# See if there are any preferred compilers for this system

CCTK_CONFIG_STAGE="preferred-compilers"

if test -r $srcdir/known-architectures/$host_os ; then
. $srcdir/known-architectures/$host_os
fi

dnl Checks for programs.
AC_PROG_MAKE_SET

#if test -z "$CC" ; then
AC_PROG_CC
#fi

#if test -z "$CXX" ; then
AC_PROG_CXX
#fi

if test -z "$RANLIB" ; then
AC_PROG_RANLIB
fi

dnl Look for a standalone CPP

if test -z "$CPP" ; then
AC_PATH_PROGS(CPP, cpp, echo, /lib:/usr/lib:/usr/local/lib:$PATH)
fi

if test -z "$PERL" ; then
AC_CHECK_PROGS(PERL, perl)
fi

if test -z "$F90" ; then
AC_CHECK_PROGS(F90, f90 pgf90 xlf90)
fi

if test -z "$F77" ; then
AC_CHECK_PROGS(F77, f77 pgf77 g77 f90 pgf90 xlf90)
fi

if test -z "$AR" ; then
AC_CHECK_PROGS(AR, ar)
fi

if test -z "$MKDIR" ; then
AC_CHECK_PROGS(MKDIR, mkdir)
fi

if test -z "$SHELL" ; then
AC_CHECK_PROGS(SHELL, sh bash)
fi

if test -z "$LD" ; then
AC_SUBST(LD)
LD=$CXX
fi

# Include some CCTK auxiliary functions

. $srcdir/CCTK_Functions.sh


#########################################################################
# If this is a known architecture, setup any specific flags.
# This has to be done here as flags given to the compiler may
# change the things detected later.

# Create a file to put any #defines etc needed for this architecture
# known architecture stuff should use cat >> etc to append to this file.
cat > cctk_Archdefs.h <<EOF
/* Stuff from known architectures */
#ifndef _CCTK_ARCHDEFS_H_
#define _CCTK_ARCHDEFS_H_
EOF

CCTK_CONFIG_STAGE="misc"

if test -r $srcdir/known-architectures/$host_os ; then
. $srcdir/known-architectures/$host_os
fi

# Finish the architecture stuff
cat >> cctk_Archdefs.h <<EOF
#endif /* _CCTK_ARCHDEFS_H_ */
EOF


#########################################################################
#Check for extra stuff
#########################################################################
cat > cctk_Extradefs.h <<EOF
/* Stuff from extra packages */
#ifndef _CCTK_EXTRADEFS_H_
#define _CCTK_EXTRADEFS_H_
EOF

cat > make.extra.defn <<EOF
# Stuff from extra packages 
EOF

for extra in `ls $srcdir/extras`
do
  if test -d $srcdir/extras/$extra ; then
    if test -x $srcdir/extras/$extra/setup.sh ; then
        # Put some comment lines in the files.
        CCTK_WriteLine cctk_Extradefs.h ""
        CCTK_WriteLine cctk_Extradefs.h "/*$extra definitions*/"
        CCTK_WriteLine make.extra.defn ""
        CCTK_WriteLine make.extra.defn "# $extra definitions"
        # Call the setup script
        . $srcdir/extras/$extra/setup.sh
        # Put some more comments in
        CCTK_WriteLine make.extra.defn "#End of $extra definitions"
        CCTK_WriteLine make.extra.defn ""
    fi
  fi
done

# Finish the cctk_Extradefs.h file
cat >> cctk_Extradefs.h <<EOF
#endif /*_CCTK_EXTRADEFS_H_*/
EOF



##########################################################################
#########################################################################

# Deal with the Fortran compiler issues.
# If there's a Fortran 90 compiler use that for all the Fortran.
if test "x$F90" != "x" ; then
F77=$F90 
F77FLAGS=$F90FLAGS ;
fi

# The known architecture stuff has probably set the LIBS variable
# So remember what it is and set it to blank to prevent any problems with the
# rest of the configure stuff.

KNOWN_LIBS="$LIBS"
LIBS=

KNOWN_LDFLAGS="$LDFLAGS"
LDFLAGS=

dnl Checks for libraries.

dnl Checks for header files.

AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.

AC_C_BIGENDIAN
AC_C_CONST
AC_C_INLINE
AC_C_LONG_DOUBLE

# Check for sizes of integer types
AC_CHECK_SIZEOF(long int)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short int)

# Check for sizes of floating point types
AC_CHECK_SIZEOF(long double)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(float)

# Check for sizes of pointers.  
AC_CHECK_SIZEOF(char *)

# See if there's a null device, and what it's called

CCTK_FIND_NULLDEVICE

# Various flags

AC_SUBST(ARFLAGS)
: ${ARFLAGS=rucs}


AC_SUBST(F90FLAGS)
AC_SUBST(F77FLAGS)

: ${F90FLAGS="$CFLAGS"}
: ${F77FLAGS="$CFLAGS"}

dnl Checks for library functions.

AC_CHECK_FUNCS(mkdir) 

dnl Check some timing stuff

CCTK_TIME_GETTIMEOFDAY
CCTK_TIME_GETRUSAGE
CCTK_TIME__FTIME

dnl Include file stuff

CCTK_CHECK_HEADERS(sys/time.h)
CCTK_CHECK_HEADERS(unistd.h)
AC_HEADER_TIME

dnl Misc stuff

AC_SUBST(LIBDIRS)

AC_SUBST(PACKAGE_DIR)
AC_SUBST(BUILD_DIR)
AC_SUBST(CCTK_LIBDIR)
AC_SUBST(EXEDIR)
AC_SUBST(EXE)

: ${PACKAGE_DIR=arrangements}
: ${BUILD_DIR=build}
: ${CCTK_LIBDIR=lib}
: ${EXEDIR='$(CCTK_HOME)/exe'}
: ${EXE=cactus-unknown}

# Integer types

case "x$ac_cv_sizeof_long_int" in
    "x8")
      CCTK_INT8="long int" ;;
    "x4")
      CCTK_INT4="long int" ;;
    "x2")
      CCTK_INT2="long int" ;;
esac

case "x$ac_cv_sizeof_int" in
    "x8")
      CCTK_INT8="int" ;;
    "x4")
      CCTK_INT4="int" ;;
    "x2")
      CCTK_INT2="int" ;;
esac

case "x$ac_cv_sizeof_short_int" in
    "x8")
      CCTK_INT8="short int" ;;
    "x4")
      CCTK_INT4="short int" ;;
    "x2")
      CCTK_INT2="short int" ;;
esac

if test -n  "$CCTK_INT8" ; then
AC_DEFINE_UNQUOTED(CCTK_INT8, $CCTK_INT8)
fi

if test -n  "$CCTK_INT4" ; then
AC_DEFINE_UNQUOTED(CCTK_INT4, $CCTK_INT4)
fi

if test -n  "$CCTK_INT2" ; then
AC_DEFINE_UNQUOTED(CCTK_INT2, $CCTK_INT2)
fi

# Float types

case "x$ac_cv_sizeof_long_double" in
    "x16")
      CCTK_REAL16="long double" ;;
    "x8")
      CCTK_REAL8="long double" ;;
    "x4")
      CCTK_REAL4="long double" ;;
esac

case "x$ac_cv_sizeof_double" in
    "x16")
      CCTK_REAL16="double" ;;
    "x8")
      CCTK_REAL8="double" ;;
    "x4")
      CCTK_REAL4="double" ;;
esac

case "x$ac_cv_sizeof_float" in
    "x16")
      CCTK_REAL16="float" ;;
    "x8")
      CCTK_REAL8="float" ;;
    "x4")
      CCTK_REAL4="float" ;;
esac

if test -n  "$CCTK_REAL16" ; then
AC_DEFINE_UNQUOTED(CCTK_REAL16, $CCTK_REAL16)
fi

if test -n  "$CCTK_REAL8" ; then
AC_DEFINE_UNQUOTED(CCTK_REAL8, $CCTK_REAL8)
fi

if test -n  "$CCTK_REAL4" ; then
AC_DEFINE_UNQUOTED(CCTK_REAL4, $CCTK_REAL4)
fi


# Define the default floating point and integer precisions
case "x$REAL_PRECISION" in
    "x16")
	AC_DEFINE(CCTK_REAL_PRECISION_16) ;;
    "x8")
	AC_DEFINE(CCTK_REAL_PRECISION_8) ;;
    "x4")
	AC_DEFINE(CCTK_REAL_PRECISION_4) ;;
    *)
	AC_DEFINE(CCTK_REAL_PRECISION_8) ;;
esac

case "x$INTEGER_PRECISION" in
    "x8")
	AC_DEFINE(CCTK_INTEGER_PRECISION_8) ;;
    "x4")
	AC_DEFINE(CCTK_INTEGER_PRECISION_4) ;;
    "x2")
	AC_DEFINE(CCTK_INTEGER_PRECISION_2) ;;
    *)
	AC_DEFINE(CCTK_INTEGER_PRECISION_4) ;;
esac

# Define any code needed before the definition of a Fortran subroutine
# This is empty on most architectures.

: ${FMODIFIER=""}

AC_DEFINE_UNQUOTED(FMODIFIER, $FMODIFIER) 

# Define how to make a directory in the config.h file

AC_DEFINE_UNQUOTED(MKDIR, "$MKDIR") 

AC_SUBST(MKDIRFLAGS)

: ${MKDIRFLAGS="-p"}

AC_DEFINE_UNQUOTED(MKDIRFLAGS, " $MKDIRFLAGS ") 


# The perl scripts run by the make system need to have their names
# changed if under cygwin - e.g. //d/foo needs to be d:/foo

PERL_CONFIGURE_SCRIPT=`echo $srcdir/configure.pl | sed 's,^//\(.\)/,\1:/,'`

AC_SUBST(BUILD_ACTIVETHORNS)
BUILD_ACTIVETHORNS='$(CCTK_HOME)/lib/sbin/BuildActiveThorns.pl'

AC_SUBST(CST)
CST='$(CCTK_HOME)/lib//sbin/CST'

AC_SUBST(F_FILE_PROCESSOR)
F_FILE_PROCESSOR='$(CCTK_HOME)/lib/sbin/f_file_processor.pl'
AC_SUBST(C_FILE_PROCESSOR)
C_FILE_PROCESSOR='$(CCTK_HOME)/lib/sbin/c_file_processor.pl'



AC_SUBST(CCOMPILEONLY)
AC_SUBST(FCOMPILEONLY)

# Put the libraries from the known-architectures onto the LIB variable.
LIBS="$KNOWN_LIBS $LIBS"
LDFLAGS="$KNOWN_LDFLAGS $LDFLAGS"

#Set the compileonly flags if they've not been set by now

: ${CCOMPILEONLY="-c -o"}
: ${FCOMPILEONLY="-c -o"}

#Set the createexe flag if it's not been set by now

AC_SUBST(CREATEEXE)

: ${CREATEEXE="-o"}

AC_SUBST(DIRSEP)

: ${DIRSEP="/"}

AC_SUBST(OPTIONSEP)

: ${OPTIONSEP='$(EMPTY_VAR) # a single space'}

AC_SUBST(CACTUSLIBLINKLINE)

: ${CACTUSLIBLINKLINE='-L$(CCTK_LIBDIR) $(addprefix -l, $(ALLCACTUSLIBS))'}

AC_SUBST(C_DEPEND)

: ${C_DEPEND='$(CC) -E -M $(CPPFLAGS)'}

AC_SUBST(C_DEPEND_OUT)

: ${C_DEPEND_OUT=' > $@'}

AC_SUBST(CXX_DEPEND)

: ${CXX_DEPEND='$(CXX) -E -M $(CPPFLAGS)'}

AC_SUBST(CXX_DEPEND_OUT)

: ${CXX_DEPEND_OUT=' > $@'}

AC_SUBST(F77_DEPEND)

: ${F77_DEPEND='$(CPP) -M $(CPPFLAGS)'}

AC_SUBST(F77_DEPEND_OUT)

: ${F77_DEPEND_OUT=' > $@'}

AC_SUBST(F_DEPEND)

: ${F_DEPEND='$(CPP) -M $(CPPFLAGS)'}

AC_SUBST(F_DEPEND_OUT)

: ${F_DEPEND_OUT=' > $@'}

AC_SUBST(GET_WD)
: ${GET_WD="pwd"}

AC_SUBST(SYS_INC_DIRS)
: ${SYS_INC_DIRS=" "}

AC_SUBST(GENERAL_LIBRARIES)
: ${GENERAL_LIBRARIES='$(LIBDIRS:%=-L%) $(LIBS:%=-l%)'}

AC_SUBST(PERL_BACKUP_NECESSARY)

: ${PERL_BACKUP_NECESSARY=""}

# Cache stuff - this will probably change 

: ${L2_CACHELINE_BYTES="0"}
: ${L2_CACHE_SIZE="0"}

AC_DEFINE_UNQUOTED(CCTK_L2_CACHELINE_BYTES, $L2_CACHELINE_BYTES) 
AC_DEFINE_UNQUOTED(CCTK_L2_CACHE_SIZE, $L2_CACHE_SIZE) 


dnl Run any other scripts necessary

AC_OUTPUT_COMMANDS(,$PERL -s $PERL_CONFIGURE_SCRIPT -compiler="$F77" -opts="$F77FLAGS" .) 

dnl Output everything
AC_OUTPUT(make.config.defn make.config.deps make.config.rules)