-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
378 lines (316 loc) · 12.8 KB
/
configure.ac
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
dnl Initialisation: package name and version number
AC_INIT([pgplot],[5.2.2-9],[[email protected]])
AC_PREREQ([2.69])
AC_CONFIG_MACRO_DIR([m4])
# cannot run parallel tests as all tests require keyboard input
AM_INIT_AUTOMAKE([1.14 -Wall foreign serial-tests ])
dnl Sanity-check: name a file in the source directory -- if this
dnl isn't found then configure will complain
AC_CONFIG_SRCDIR([src/pgbeg.f])
dnl Find required versions of the programs we need for configuration
AC_PROG_CC
AC_PROG_AWK
AC_PROG_F77
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AM_PROG_AR
LT_INIT
AC_CHECK_PROG([have_fold],[fold],[yes],[no])
AS_IF([test $have_fold = "no"],
[AC_MSG_ERROR([fold program is required; aborting])])
dnl if homebrew was installed, ensure that the homebrew lib
dnl directory is in the library search path. for the default
dnl /usr/local brew prefix, if using clang, the searches for brew
dnl installed libraries (e.g. the X libraries) will succeed, as
dnl clang will search /usr/local/lib for the libraries. However,
dnl the brew installed compilers won't, so e.g. gfortran will be
dnl unable to find the brew installed libraries
AC_ARG_WITH([brew],[AS_HELP_STRING([--without-brew],
[don't search homebrew's library directories if it is installed])],
[],
[with_brew=yes])
AS_IF([test "x$with_brew" != xno],
[ AC_PATH_PROG([BREW],[brew])
AS_IF([test "x$BREW" = x],[],
[LDFLAGS="$LDFLAGS -L`$BREW --prefix`/lib"])
] )
dnl Yes Virginia, there are boxes without Fortran. Drag them back to the '70s
AS_IF([test "x$F77" = x ],
[AC_MSG_ERROR([No Fortran compiler found; Cannot build without one. Aborting])
]
)
dnl If we're using GNU Fortran, use the 'legacy' standard, as this
dnl code will not compile under anything more modern.
AS_IF( [test "$ac_cv_f77_compiler_gnu" = "yes" ],
[AC_SUBST([AM_FFLAGS],[-std=legacy] ) ] );
dnl Checks for libraries
dnl On Ubuntu 13.04, need to explicitly pull in libm to resolve
dnl sincos, or cpg/cpgdemo won't link correctly
AC_CHECK_LIB(m, sincos)
dnl Checks for header files.
AC_HEADER_STDC
AC_PATH_XTRA
AC_CHECK_HEADERS([fcntl.h limits.h memory.h netdb.h netinet/in.h stddef.h sys/file.h sys/socket.h sys/systeminfo.h sys/time.h unistd.h values.h])
AC_SYS_POSIX_TERMIOS
dnl get the flags required to link other languages against fortran
dnl using their compilers, not fortran
AC_F77_LIBRARY_LDFLAGS
dnl on some older OS X systems w/ older gfortran, gfortran doesn't
dnl default to generating 64bit binaries even if the C compiler
dnl does. See if we can figure out how to force gfortran to do so.
MST_FORTRAN_64BIT([Fortran 77])
dnl Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([gethostbyname gethostname memset select socket sqrt strrchr strtol sysinfo])
dnl These are the driver files that will actually be built.
dnl In true autoconf style, we do not attempt to generate this list
dnl automatically (see the automake manual's FAQ for justification).
drivers="exdriv.lo pgdriv.lo cadriv.lo hgdriv.lo lxdriv.lo hidriv.lo psdriv.lo cwdriv.lo gldriv.lo hpdriv.lo lsdriv.lo nudriv.lo qmdriv.lo vadriv.lo cgdriv.lo rvdriv.lo xmdriv.lo tkdriv.lo pkdriv.lo xadriv.lo"
dnl Not all platforms have X
have_x11=no
have_xt=no
dnl +--------+------------------------+----------+----------+--------+-----+
dnl |Variable| AC_PATH_XTRA |-without-x|-with-x=no|-with-x | --x |
dnl +--------+------------+-----------+----------+----------+--------+-----+
dnl | | success | failure | | | | |
dnl +--------+------------+-----------+----------+----------+--------+-----+
dnl | no_x | '' | 'yes' | 'yes' | | | |
dnl +--------+------------+-----------+----------+----------+--------+-----+
dnl | with_x | | | 'no' | 'no' | 'yes' |'yes'|
dnl +--------+------------+-----------+----------+----------+--------+-----+
dnl Notes:
dnl 1) AC_PATH_XTRA runs first and modifies no_x in the presence of -without-x
dnl 2) If --with-x is not specified, AC_PATH_XTRA assumes with_x='yes'
dnl
dnl Check pkg-config if the user did not forbid X and AC_PATH_XTRA failed to find it
AS_IF([ test "x$with_x" != xno -a "x$no_x" != x ],
[
PKG_CHECK_MODULES(
[X11],
[x11],
[have_x11=yes
no_x=""
PKG_CONFIG_REQUIRES="${PKG_CONFIG_REQUIRES}[,]x11"
PKG_CHECK_MODULES(
[XT],
dnl have sm and ice listed here so that contents of $X_PRE_LIBS
dnl can be found
[sm ice xt],
[have_xt=yes
PKG_CONFIG_REQUIRES="${PKG_CONFIG_REQUIRES}[,]xt"
dnl XT_* has xt + x11 because xt depends on x11
X_LIBS="$X_LIBS $XT_LIBS"
LIBS="$LIBS $XT_LIBS"
X_CFLAGS="$X_CFLAGS $XT_CFLAGS"
CPPFLAGS="$CPPFLAGS $XT_CFLAGS"
],
[
dnl only have x11
X_LIBS="$X_LIBS $X11_LIBS"
LIBS="$LIBS $X11_LIBS"
X_CFLAGS="$X_CFLAGS $X11_CFLAGS"
CPPFLAGS="$CPPFLAGS $X11_CFLAGS"
]
)
],
[
dnl no x11 via pkg-config either
]
)
]
)
COMPILE_PGDISP=no
AS_IF([ test "x$no_x" = "x"],
[
dnl Don't take their word for it. If we can't find the
dnl headers, don't compile the X drivers
AC_CHECK_HEADERS([ X11/Intrinsic.h X11/keysym.h ])
AC_CHECK_HEADERS([ X11/StringDefs.h X11/Xatom.h ])
AC_CHECK_HEADERS([ X11/X.h X11/Xlib.h X11/Xos.h X11/Xresource.h X11/Xutil.h] )
AS_IF( [ test "x$ac_cv_header_X11_Xos_h" = xyes -a "x$ac_cv_header_X11_Xlib_h" = xyes -a "x$ac_cv_header_X11_Xutil_h" = xyes -a "x$ac_cv_header_X11_keysym_h" = xyes],
[ drivers="$drivers pgxwin.lo" ],
[ AC_MSG_WARN([X drivers requested, but missing headers prevent building of pgxwin])]
)
AS_IF( [ test "x$ac_cv_header_X11_Xatom_h" = xyes -a "x$ac_cv_header_X11_Xlib_h" = xyes ],
[ drivers="$drivers x2driv.lo figdisp_comm.lo" ],
[ AC_MSG_WARN([X drivers requested, but missing headers prevent building of x2driv and figdisp]) ]
)
AS_IF( [ test "x$ac_cv_header_X11_Xos_h" = xyes -a "x$ac_cv_header_X11_Xlib_h" = xyes -a "x$ac_cv_header_X11_Xutil_h" = xyes -a "x$ac_cv_header_X11_keysym_h" = xyes -a "x$ac_cv_header_X11_Xatom_h" = xyes],
[ drivers="$drivers xwdriv.lo" ],
[ AC_MSG_WARN([X drivers requested, but missing headers prevent building of xwdriv]) ]
)
AS_IF( [ test "x$ac_cv_header_X11_Intrinsic_h" = xyes -a "x$ac_cv_header_X11_keysym_h" = xyes -a "x$ac_cv_header_X11_StringDefs_h" = xyes -a "x$ac_cv_header_X11_Xatom_h" = xyes -a "x$ac_cv_header_X11_Xlib_h" = xyes -a "x$ac_cv_header_X11_Xresource_h" = xyes -a "x$ac_cv_header_X11_Xutil_h" = xyes ],
[ COMPILE_PGDISP=yes ],
[ AC_MSG_WARN([X drivers requested, but missing headers prevent building of pgdisp]) ]
)
dnl Make sure that X libs are included in tests.
dnl Apple puts libpng in the X11 distribution.
dnl Oddly gcc and cpp (in Snow Leopard) know how to find X11 include
dnl files without being told. This means that the standard
dnl configure test does not both adding any include directories for
dnl X. This is unfortunate because PNG is sitting there but does not
dnl have the magical <X11/...> prefix to give cpp a hint. We add
dnl the path here on the basis that it won't hurt anyone else.
X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
LIBS="$LIBS $X_LIBS"
X_CFLAGS="$X_CFLAGS -I/usr/X11/include"
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
]
);
AM_CONDITIONAL([COMPILE_PGDISP],[test "x$COMPILE_PGDISP" = xyes])
AM_CONDITIONAL([HAVE_X_WINDOW_SYSTEM],[test "x$no_x" = x])
dnl %VAL is used for some memory handling. Under 64bit pointers are
dnl 8 bytes. Files that require this are configured here
AC_CHECK_SIZEOF([void *])
AC_SUBST([SIZEOF_VOID_P],[$ac_cv_sizeof_void_p])
AC_CONFIG_FILES([drivers/ppdriv.f
drivers/gidriv.f
drivers/wddriv.f
])
dnl gfortran < 4.3 can't handle %VAL on 64 bit systems, so just
dnl don't compile drivers that use it.
MST_GNU_FORTRAN_VERSION([Fortran 77])
AS_IF([test "$mst_prog_gnu_f77_version" != '0.0.0' && test "$mst_prog_gnu_f77_version_major" -eq 4 && test "$mst_prog_gnu_f77_version_minor" -lt 3 ],
[],
[drivers="$drivers gidriv.lo ppdriv.lo wddriv.lo"]
)
# these provided required linker and compile flags for PGPLOT's pkg-config metadata files
AC_SUBST([PKG_CONFIG_LIBS])
AC_SUBST([PKG_CONFIG_CFLAGS])
dnl drivers ttdriv and vtdriv require termios; only include them if
dnl it's available.
AM_CONDITIONAL([HAVE_TERMIOS], [test "$ac_cv_sys_posix_termios" = "yes" ])
AS_IF( [test "$ac_cv_sys_posix_termios" = "yes" ],
[
drivers="$drivers ttdriv.lo vtdriv.lo"
]
)
dnl drivers nexup and nedriv require sys/socket.h
AS_IF([test "$ac_cv_header_sys_socket_h" = "yes"],
[
drivers="$drivers nexsup.lo nedriv.lo"
]
)
dnl Add the png driver if the PNG header and library are available.
dnl On some systems both png 1.2.x and png 1.5+ are installed. They
dnl are not ABI compatible, and on some systems it's possible to pull
dnl in the header for one and libs for the other. don't ask...
dnl Try to use the pkg-config files if possible, as they
dnl explicitly direct us to the version specific headers and
dnl libraries. If that doesn't work, try to find them in the
dnl standard places and pray.
have_png=no
PKG_CHECK_MODULES(
[PNG],
[libpng],
[have_png=yes
dnl add png to our own pkg-config files' requirements
PKG_CONFIG_REQUIRES="${PKG_CONFIG_REQUIRES}[,]libpng"
],
[AC_CHECK_HEADER(
[png.h],
[AC_CHECK_LIB([png],[png_create_write_struct],
[PNG_LIBS="-lpng -lz"
PKG_CONFIG_LIBS="$PKG_CONFIG_LIBS $PNG_LIBS"
have_png=yes
],
[AC_MSG_WARN(PNG libraries not found)],
[-lz]
)
]
)
]
)
dnl Add required flags and drivers if we've got libpng.
AS_IF([test $have_png = yes],
[ drivers="$drivers pndriv.lo"
LIBS="$LIBS $PNG_LIBS"
CPPFLAGS="$CPPFLAGS $PNG_CFLAGS"
]
)
dnl clean up pkg-config requires line
PKG_CONFIG_REQUIRES=`echo $PKG_CONFIG_REQUIRES | ${ac_cv_path_SED} "s/^,//"`
AC_SUBST(PKG_CONFIG_REQUIRES)
AC_SUBST(BUILT_DRIVERS,[$drivers])
dnl Stuff required for xathena
AC_ARG_WITH(
[athena],
AS_HELP_STRING([--with-athena[=path]],[use Xaw3d (default location /usr/X11R6/)]),
[
AS_IF([test "x$no_x" = x && test "$withval" != no],
[
have_athena=yes
AS_IF([test "$withval" != yes],
[
XALIBDIR=$withval/lib
XAINCDIR=$withval/include
LIBS="$LIBS -L$XALIBDIR"
CPPFLAGS="$CPPFLAGS -I$XAINCDIR"
PKG_CONFIG_LIBS="$PKG_CONFIG_LIBS -L$XALIBDIR"
PKG_CONFIG_CFLAGS="$PKG_CONFIG_CFLAGS -L$XAINCDIR"
]
)
AC_CHECK_HEADER([X11/Xaw3d/Simple.h],[],[have_athena=no] )
AC_CHECK_LIB(Xaw3d, XawInitializeWidgetSet, [],[have_athena=no] )
],
[have_athena=no]
)
]
)
AM_CONDITIONAL( HAVE_XATHENA, [test "$have_athena" = "yes"] )
dnl tcl shipes with a tcl.m4 autoconf macro library. This should be
dnl used to set up the ptk and xtk drivers. until then, disable TK
AM_CONDITIONAL( HAVE_TK, false )
dnl xmotif
AC_ARG_WITH(
[motif],
AS_HELP_STRING([--with-motif[=path]],[use XMotif (default location /usr/X11R6)]),
[
AS_IF([test "x$no_x" = x && test "$withval" != no],
[
have_motif=yes
AS_IF([test "$withval" != yes],
[
XMLIBDIR=$withval/lib
XMINCDIR=$withval/include
LIBS="$LIBS -L$XMLIBDIR"
CPPFLAGS="$CPPFLAGS -I$XMINCDIR"
PKG_CONFIG_LIBS="$PKG_CONFIG_LIBS -L$XMLIBDIR"
PKG_CONFIG_CFLAGS="$PKG_CONFIG_CFLAGS -L$XMINCDIR"
]
)
AC_CHECK_HEADER([Xm/XmP.h],[],[have_motif=no] )
AC_CHECK_LIB(Xm, XmScrolledWindowSetAreas,[],[have_motif=no] )
],
[have_motif=no]
)
]
)
AM_CONDITIONAL( HAVE_XMOTIF, [test "$have_motif" = "yes"] )
dnl If you wish to configure extra files, you can add them to this
dnl declaration.
AC_CONFIG_FILES([Makefile
cpg/Makefile
fonts/Makefile
pgdispd/Makefile
src/Makefile
sys/Makefile
examples/Makefile
drivers/Makefile
drivers/xathena/Makefile
drivers/xtk/Makefile
drivers/ptk/Makefile
drivers/xmotif/Makefile
])
dnl Add X libraries at end
PKG_CONFIG_LIBS="$PKG_CONFIG_LIBS $X_LIBS"
PKG_CONFIG_CFLAGS="$PKG_CONFIG_CFLAGS $X_CFLAGS"
dnl pkg-config files
AC_CONFIG_FILES([pgplot.pc
cpgplot.pc
])
dnl This is the bit that does the actual work
AC_OUTPUT