configure.ac 10.5 KB
Newer Older
1
2
3
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

4
AC_PREREQ([2.61])
5

6
7
8
9
dnl Name your program here
m4_define([full_package_name], [nmxptool])

dnl These three define the plug-in version number
10
m4_define([major_version], [2])
11
m4_define([minor_version], [1])
12
m4_define([micro_version], [5])
13
# Comment build_version for stable release
Matteo Quintiliani's avatar
Matteo Quintiliani committed
14
# m4_define([build_version], [dev])
15
16
17
18
19
20
21
22
23
24
25

m4_ifdef([build_version], [
	  m4_define([version],
		    [major_version.minor_version.micro_version-build_version])
	  ],
	  [
	  m4_define([version],
		    [major_version.minor_version.micro_version])
	   ]
	  )

26
27


28
m4_define([bug_report_address], [matteo.quintiliani@ingv.it])
29
30

AC_INIT([full_package_name], [version], [bug_report_address])
31
32
33

AC_CONFIG_MACRO_DIR([m4])

34
35
AC_CONFIG_SRCDIR([src/nmxptool.c])
AC_CONFIG_HEADER([config.h])
36
AC_CONFIG_SRCDIR([config.h.in])
37

38
AC_CANONICAL_HOST
39
40
AC_CANONICAL_SYSTEM

Matteo Quintiliani's avatar
Matteo Quintiliani committed
41
42
43
44
45
# Set BINARY_DIST_NAME_SUFFIX
BINARY_DIST_NAME_SUFFIX=$host
AC_MSG_NOTICE(BINARY_DIST_NAME_SUFFIX set to $BINARY_DIST_NAME_SUFFIX)
AC_SUBST(BINARY_DIST_NAME_SUFFIX)

46
47
48
49
avail_libmseed=YES
avail_seedlink=YES
avail_ew=YES

50
AM_INIT_AUTOMAKE
51
52
53
54
# Default AM_MAINTAINER_MODE is enable
# AM_MAINTAINER_MODE([enable])
# Default argument for AM_MAINTAINER_MODE is disable
AM_MAINTAINER_MODE([disable])
55
56

# Checks for programs.
57
# AC_PROG_CXX
58
AC_PROG_AWK
59
AC_PROG_CC
60
61
62
63
64
65
66
AM_PROG_CC_C_O
# AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# AC_PROG_RANLIB Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
AC_PROG_LIBTOOL
67
68

# Checks for libraries.
69
AC_CHECK_LIB(nsl, socket, LIBS="$LIBS -lsocket -lnsl", , -lsocket)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
70

71
AC_CHECK_LIB(rt, nanosleep, LIBS="$LIBS -lrt", , -lrt)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
72

73
AC_CHECK_LIB(m, fabs, LIBS="$LIBS -lm", , -lm)
74

75
AC_CHECK_LIB(ws2_32, puts, LIBS="$LIBS -lws2_32", , -lws2_32)
76

77
78
AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread", , -lpthread)

79
80
81
82
83
84
AC_ARG_ENABLE([memdebug],
	      [AS_HELP_STRING([--enable-memdebug], [compile nmxptool for debugging memory leaks])],
	    [], 
	    [enable_memdebug=no]
) 

Matteo Quintiliani's avatar
Matteo Quintiliani committed
85
86
AC_ARG_ENABLE([libmseed],
	      [AS_HELP_STRING([--disable-libmseed], [disable saving data in mini-SEED records])],
87
	    [], 
Matteo Quintiliani's avatar
Matteo Quintiliani committed
88
	    [enable_libmseed=yes]
Matteo Quintiliani's avatar
Matteo Quintiliani committed
89
90
) 

Matteo Quintiliani's avatar
Matteo Quintiliani committed
91
92
AC_ARG_ENABLE([ew],
	      [AS_HELP_STRING([--disable-ew], [do not compile nmxptool as Earthworm module])],
93
	    [], 
Matteo Quintiliani's avatar
Matteo Quintiliani committed
94
	    [enable_ew=yes]
Matteo Quintiliani's avatar
Matteo Quintiliani committed
95
96
) 

Matteo Quintiliani's avatar
Matteo Quintiliani committed
97
98
AC_ARG_ENABLE([seedlink],
	      [AS_HELP_STRING([--disable-seedlink], [do not compile nmxptool as Seedlink plug-in])],
Matteo Quintiliani's avatar
Matteo Quintiliani committed
99
	    [], 
Matteo Quintiliani's avatar
Matteo Quintiliani committed
100
	    [enable_seedlink=yes]
Matteo Quintiliani's avatar
Matteo Quintiliani committed
101
102
) 

103
104
105
AC_MSG_WARN(Cross-compiling: $cross_compiling $build $host $target)
AC_MSG_WARN(OSTYPE: $OSTYPE)

106
case "$OSTYPE" in
107
108
109
solaris*)
    CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
;;
110
111
112
113
114
115
win32*)
    WINSOURCES=$OSTYPE
;;
msys*)
    WINSOURCES=$OSTYPE
;;
116
117
118
cygwin*)
    WINSOURCES=$OSTYPE
;;
119
120
121
122
*)
    AC_MSG_WARN(Operating system is not Windows. $OSTYPE)
;;
esac
Matteo Quintiliani's avatar
Matteo Quintiliani committed
123
AM_CONDITIONAL(ENABLE_WINSOURCES, test x$WINSOURCES != x)
124
125
126
127
128

# mtheo
AM_PROG_LIBTOOL


129
130
131
132
133
134
135
136
137
# memdebug check.
AS_IF([test "x$enable_memdebug" != xno], 
      [
       CFLAGS="$CFLAGS -DNMXP_MEM_DEBUG"
       AC_MSG_WARN([memdebug has been enabled!])
       ]
)
AM_CONDITIONAL(ENABLE_MEMDEBUG, test x$enable_memdebug != xno)

138
139
140
141
AM_CONDITIONAL(ENABLE_DLL_PTHREAD, test x$DLL_PTHREAD != x)
AC_ARG_VAR(DIR_PTHREAD, [Directory containing PThread DDL library])
AC_ARG_VAR(DLL_PTHREAD, [Name of PThread DLL library - i.e. pthreadVC2.dll])

142

Matteo Quintiliani's avatar
Matteo Quintiliani committed
143
144
# Checks for header files.
AC_HEADER_STDC
145
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/stat.h sys/time.h unistd.h pthread.h])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
146
147
AC_CHECK_HEADERS([windows.h winsock2.h])

Matteo Quintiliani's avatar
Matteo Quintiliani committed
148
AS_IF([test "x$enable_libmseed" != xno], 
Matteo Quintiliani's avatar
Matteo Quintiliani committed
149
150
      [AC_CHECK_LIB([mseed], [msr_init],
		    [LIBS="$LIBS -lmseed"
151
		     AC_DEFINE([HAVE_LIBMSEED], [1], [Define if you have libmseed]) 
152
153
154
		     # AC_CHECK_LIB([nmxp], [nmxp_openSocket], [], [AC_MSG_ERROR([libnmxp not found!])]) 
		     # AC_CHECK_LIB([nmxp], [nmxp_data_msr_pack],
		#		  [],
Matteo Quintiliani's avatar
Matteo Quintiliani committed
155
		#		  [AC_MSG_FAILURE([libmseed found but libnmxp does not support it. (Try --disable-libmseed to disable)])])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
156
		     ], 
157
158
159
		     [
		      avail_libmseed=NO
		      AC_MSG_WARN([libmseed is not available (--disable-libmseed to disable)])
160
161
162
		     # AC_CHECK_LIB([nmxp], [nmxp_openSocket], [], [AC_MSG_ERROR([libnmxp not found or it supports libmseed
				   # but libmseed is not available anymore! Try to recompile libnmxp!
				   # ])]) 
Matteo Quintiliani's avatar
Matteo Quintiliani committed
163
164
165
				   ], 
				   )
      ],
Matteo Quintiliani's avatar
Matteo Quintiliani committed
166
      [
Matteo Quintiliani's avatar
Matteo Quintiliani committed
167
       # AC_CHECK_LIB([nmxp], [nmxp_openSocket], [], [AC_MSG_ERROR([libnmxp not found or supports libmseed (--enable-libmseed to enable)!])]) 
168
       avail_libmseed=NO
Matteo Quintiliani's avatar
Matteo Quintiliani committed
169
       AC_MSG_WARN([libmseed feature has been disabled!])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
170
      ]
Matteo Quintiliani's avatar
Matteo Quintiliani committed
171
) 
172
AM_CONDITIONAL(ENABLE_LIBMSEED, test x$enable_libmseed != xno)
173

174
175
176
177
AC_ARG_VAR(EW_HOME, [Earthworm home directory])
AC_ARG_VAR(EW_VERSION, [Earthworm version directory])
AC_ARG_VAR(EW_PARAMS, [Earthworm configuration files directory])
AC_ARG_VAR(GLOBALFLAGS, [C compiler flags for Earthworm])
178

179
EWOSOURCES=no
180

Matteo Quintiliani's avatar
Matteo Quintiliani committed
181
# Earthworm check.
Matteo Quintiliani's avatar
Matteo Quintiliani committed
182
AS_IF([test "x$enable_ew" != xno], 
183
      [
Matteo Quintiliani's avatar
Matteo Quintiliani committed
184
185
    AS_IF([test "x$EW_HOME" != x], 
	  [
186
	   # CFLAGS="$CFLAGS -m32"
187
	   CFLAGS="$CFLAGS -I$EW_HOME/$EW_VERSION/include $GLOBALFLAGS"
188
189
	AC_CHECK_HEADERS([earthworm.h kom.h transport.h trace_buf.h],
			 [AC_DEFINE([HAVE_EARTHWORMFILES_H], [1], [Define if you have earthworm header file])],
190
			 AC_MSG_ERROR([Earthworm header files not found!])
191
			 )
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
	EWLIB=$EW_HOME/$EW_VERSION/lib
	EWOBJS="$EWLIB/kom.o $EWLIB/getutil.o $EWLIB/logit_mt.o $EWLIB/socket_ew_common.o $EWLIB/transport.o $EWLIB/sleep_ew.o $EWLIB/socket_ew.o $EWLIB/time_ew.o $EWLIB/threads_ew.o $EWLIB/sema_ew.o $EWLIB/swap.o $EWLIB/mem_circ_queue.o"
	AC_DEFINE([HAVE_EARTHWORMOBJS], [1], [Define if you have all earthworm object files])
	AS_IF([test "x$EWOSOURCES" != xno],
	      [ 
		case "$OSTYPE" in
		solaris*)
		    EWOS=solaris
		;;
		darwin*)
		    EWOS=unix
		;;
		linux*)
		    EWOS=unix
		;;
		win32*)
		    EWOS=winnt
		;;
		msys*)
		    EWOS=winnt
		;;
213
214
215
		cygwin*)
		    EWOS=winnt
		;;
216
217
218
219
220
221
222
		*)
		    EWOS=unix
		    AC_MSG_WARN(Unrecognised OS $OSTYPE)
		;;
		esac
		AC_MSG_WARN(EWOS set to $EWOS)
		AC_SUBST(EWOS)
223
224
225
226
227
228
		EW_LIBSRC=$EW_HOME/$EW_VERSION/src/libsrc
		EW_LIBSRC_UTIL=$EW_LIBSRC/util
		EW_LIBSRC_OS=$EW_LIBSRC/$EWOS
		AC_SUBST(EW_LIBSRC)
		AC_SUBST(EW_LIBSRC_UTIL)
		AC_SUBST(EW_LIBSRC_OS)
229
230
231
232
	       ],
	      [
	       LIBS="$LIBS $EWOBJS"
	       ])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
233
	],
234
235
236
	[
	 avail_ew=NO
	 AC_MSG_WARN([Earthworm files are not available (--disable-ew to disable)])]
Matteo Quintiliani's avatar
Matteo Quintiliani committed
237
238
    )
    ],
239
240
241
    [
     avail_ew=NO
     AC_MSG_WARN([ew feature has been disabled!])]
242
)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
243
244
AM_CONDITIONAL(ENABLE_EWSOURCES, test x$EWOS != x)
AM_CONDITIONAL(ENABLE_EW, test x$enable_ew != xno)
245

246
# Checks for files.
Matteo Quintiliani's avatar
Matteo Quintiliani committed
247

248
249
AC_ARG_VAR(SEISCOMPDIR, [SeisComP root directory - default is /home/sysop/seiscomp3])

Matteo Quintiliani's avatar
Matteo Quintiliani committed
250
# Seedlink check.
Matteo Quintiliani's avatar
Matteo Quintiliani committed
251
AS_IF([test "x$enable_seedlink" != xno], 
252
253
254
255
      [

       AS_IF([test "x$SEISCOMPDIR" == x],
	      [
256
	       SEISCOMPDIR=/home/sysop/seiscomp3
257
258
259
260
	       ]
	      )
       AC_MSG_WARN([SEISCOMPDIR is set to ${SEISCOMPDIR}])
       AC_SUBST(SEISCOMPDIR)
261
       AC_DEFINE([HAVE_SEEDLINK], [1], [Define if you have libmseed]) 
262
263

       ],
264
265
266
    [
     avail_seedlink=NO
     AC_MSG_WARN([seedlink feature has been disabled!])]
Matteo Quintiliani's avatar
Matteo Quintiliani committed
267
)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
268
AM_CONDITIONAL(ENABLE_SEEDLINK, test x$enable_seedlink != xno)
269

270
271
272

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
273
AC_C_INLINE
274
AC_TYPE_INT16_T
275
AC_TYPE_INT32_T
276
AC_TYPE_INT64_T
277
278
AC_TYPE_UINT32_T
AC_TYPE_INT8_T
279
AC_TYPE_MODE_T
Matteo Quintiliani's avatar
Matteo Quintiliani committed
280
AC_TYPE_PID_T
281
282
283
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_STRUCT_TM
Matteo Quintiliani's avatar
Matteo Quintiliani committed
284
# AC_CHECK_SIZEOF([long int])
285
286

# Checks for library functions.
287
# AC_FUNC_MALLOC
288
289
290
AC_FUNC_MKTIME
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRERROR_R
Matteo Quintiliani's avatar
Matteo Quintiliani committed
291
AC_TYPE_SIGNAL
292
293
294
295
AC_CHECK_FUNCS([getcwd gethostbyname inet_ntoa memmove memset mkdir select setenv socket strcasecmp strchr strerror strstr strtol tzset])
AC_CHECK_FUNCS([gettimeofday], [], [
			       AC_MSG_ERROR([function gettimeofday() not found!])
])
296
297
298
299
300
301
302
303
304
305
306
AC_CHECK_FUNCS([timegm], [], [
		AC_CHECK_FUNCS([getenv setenv unsetenv tzset],
			       [],
			       [AC_MSG_WARN([
				Computation of packet latencies could be wrong
				if local time is not equal to UTC.
				])]
			       )
])
AC_CHECK_MEMBERS([struct tm.tm_gmtoff])

307
# Test whether _timezone is available. (On Windows only)
308
309
310
311
312
313
314
315
AC_MSG_CHECKING([for global _timezone variable])
dnl FIXME: As above, don't want link check
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]],
		  [[long z2 = _timezone;]])],
		  [AC_DEFINE(HAVE_UNDERSCORE_TIMEZONE, 1,
		   [Define if your platform has the global _timezone variable.])
		  AC_MSG_RESULT(yes)],
		  [AC_MSG_RESULT(no)])
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
# Test whether SO_RCVTIMEO is broken. (On Solaris SO_RCVTIMEO is defined but not implemented)
AC_CACHE_CHECK([whether setsockopt(SO_RCVTIMEO) is broken],
ac_cv_so_rcvtimeo_broken, [dnl
			   AC_RUN_IFELSE([AC_LANG_SOURCE([[
					  #if defined(HAVE_SYS_TYPES_H)
					  #include <sys/types.h>
					  #endif

					  #if defined(HAVE_SYS_SOCKET_H)
					  #include <sys/socket.h>
					  #endif

					  #if defined(HAVE_SYS_TIME_H)
					  #include <sys/time.h>
					  #endif

					  int main(void) {

					  #ifdef HAVE_WINDOWS_H
					  return 0;
					  #else
					  
					  int fd;
					  int ret;
					  struct timeval new_tv;

					  /* Open the socket (INET/TCP).*/
					  fd = socket(AF_INET, SOCK_STREAM, 0);

					  /* set the timeout for the incoming queue */
					  /* 1 second for example */
					  new_tv.tv_sec = 1;
					  new_tv.tv_usec = 0;

					  ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &new_tv, sizeof(new_tv)); 
					  return ret;

					  #endif
				      }
				      ]])],[ac_cv_so_rcvtimeo_broken=no],[ac_cv_so_rcvtimeo_broken=yes],[ac_cv_so_rcvtimeo_broken=cross])])
if test x"$ac_cv_so_rcvtimeo_broken" = x"yes"; then
    AC_DEFINE(HAVE_BROKEN_SO_RCVTIMEO, 1, [Define if setsockopt(SO_RCVTIMEO) is broken])
    fi
362
363

AC_CONFIG_FILES([Makefile
364
                 lib/Makefile
365
                 src/Makefile])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
366
367
368

# AC_CONFIG_SUBDIRS([libnmxp])

369
AC_OUTPUT
Matteo Quintiliani's avatar
Matteo Quintiliani committed
370

371
372
373
# AC_MSG_NOTICE([
#      Enabled features: libmseed ($enable_ew), SeedLink ($enable_seedlink), Earthworm ($enable_ew).])
AC_MSG_NOTICE([Enabled features
374
375
          libmseed : $avail_libmseed
	  SeedLink : $avail_seedlink
376
377
	  Earthworm: $avail_ew
	  Cross-compiling: $cross_compiling $build $host $target])
378

Matteo Quintiliani's avatar
Matteo Quintiliani committed
379
AC_MSG_NOTICE([
380
381
      Compile nmxptool using 'make'.])

Matteo Quintiliani's avatar
Matteo Quintiliani committed
382
AS_IF([test "x$enable_ew" != xno], 
383
384
385
386
387
388
      [AC_MSG_NOTICE([
      After compilation you can install nmxptool for Earthworm:
            make install-ew-bin
            make install-ew-conf])
      ]
)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
389
AS_IF([test "x$enable_seedlink" != xno], 
390
      [AC_MSG_NOTICE([
Matteo Quintiliani's avatar
Matteo Quintiliani committed
391
      After compilation you can install nmxptool for Seedlink:
392
393
394
395
            make install-seiscomp-bin
            make install-seiscomp-templates])
      ]
)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
396