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

Matteo Quintiliani's avatar
Matteo Quintiliani committed
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], [1])
11
m4_define([minor_version], [2])
12
m4_define([micro_version], [1])
13 14 15 16 17 18 19 20 21 22 23

m4_define([version],
	            [major_version.minor_version.micro_version])

m4_define([bug_report_address], [quintiliani@ingv.it])

# AC_INIT(FULL_PACKAGE_NAME, VERSION, BUG_REPORT_ADDRESS)
AC_INIT([full_package_name], [version], [bug_report_address])
AC_CONFIG_SRCDIR([src/nmxptool.c])
AC_CONFIG_HEADER([config.h])

24 25
AC_CANONICAL_SYSTEM

26 27 28 29 30
#mtheo
# AM_INIT_AUTOMAKE(FULL_PACKAGE_NAME,VERSION)
AM_INIT_AUTOMAKE([full_package_name], [version])

# Checks for programs.
31
# AC_PROG_CXX
32
AC_PROG_CC
33 34 35 36 37 38 39
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
40 41

# Checks for libraries.
42 43 44
AC_CHECK_LIB(nsl,gethostent)
AC_SEARCH_LIBS(socket, socket, ,
	           [AC_CHECK_LIB(nsl, socket, LIBS="$LIBS -lsocket -lnsl", , -lsocket)])
45 46 47 48

AC_SEARCH_LIBS(rt, nanosleep, ,
	           [AC_CHECK_LIB(rt, nanosleep, LIBS="$LIBS -lrt", , -lrt)])

49 50 51
AC_SEARCH_LIBS(ws2_32, puts, ,
		[AC_CHECK_LIB(ws2_32, puts, LIBS="$LIBS -lws2_32", , -lws2_32)])

52 53 54 55
AC_ARG_WITH([libmseed],
	    [AS_HELP_STRING([--without-libmseed], [disable support for libmseed])],
	    [], 
	    [with_libmseed=yes]
56 57
) 

58 59 60 61
AC_ARG_WITH([ew],
	    [AS_HELP_STRING([--without-ew], [disable support for earthworm])],
	    [], 
	    [with_ew=yes]
62 63 64 65 66 67 68 69
) 

AC_ARG_WITH([seedlink],
	    [AS_HELP_STRING([--without-seedlink], [disable support for seedlink])],
	    [], 
	    [with_seedlink=yes]
) 

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
case "$OSTYPE" in
win32*)
    WINSOURCES=$OSTYPE
;;
msys*)
    WINSOURCES=$OSTYPE
;;
*)
    AC_MSG_WARN(Operating system is not Windows. $OSTYPE)
;;
esac
AM_CONDITIONAL(WITHWINSOURCES, test x$WINSOURCES != x)

# mtheo
AM_PROG_LIBTOOL


Matteo Quintiliani's avatar
Matteo Quintiliani committed
87 88
# Checks for header files.
AC_HEADER_STDC
89
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h unistd.h])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
90 91
AC_CHECK_HEADERS([windows.h winsock2.h])

92 93 94
AS_IF([test "x$with_libmseed" != xno], 
      [AC_CHECK_LIB([mseed], [msr_init],
		    [LIBS="$LIBS -lmseed"
95
		     AC_DEFINE([HAVE_LIBMSEED], [1], [Define if you have libmseed]) 
96 97 98 99
		     # AC_CHECK_LIB([nmxp], [nmxp_openSocket], [], [AC_MSG_ERROR([libnmxp not found!])]) 
		     # AC_CHECK_LIB([nmxp], [nmxp_data_msr_pack],
		#		  [],
		#		  [AC_MSG_FAILURE([libmseed found but libnmxp does not support it. (Try --without-libmseed to disable)])])
100 101 102 103
		     ], 
		     [AC_MSG_WARN([
		      libmseed is not available (--without-libmseed to disable)
		     ])
104 105 106
		     # 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!
				   # ])]) 
107 108 109
				   ], 
				   )
      ],
Matteo Quintiliani's avatar
Matteo Quintiliani committed
110
      [
111
       # AC_CHECK_LIB([nmxp], [nmxp_openSocket], [], [AC_MSG_ERROR([libnmxp not found or supports libmseed (--with-libmseed to enable)!])]) 
Matteo Quintiliani's avatar
Matteo Quintiliani committed
112 113
       AC_MSG_WARN([Mini-SEED support has been disabled!])
      ]
114
) 
115 116


117
EWOSOURCES=no
118

119
# Earthworm check.
120 121
AS_IF([test "x$with_ew" != xno], 
      [
Matteo Quintiliani's avatar
Matteo Quintiliani committed
122 123
    AS_IF([test "x$EW_HOME" != x], 
	  [
124
	   CFLAGS="$CFLAGS $GLOBALFLAGS"
125 126
	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])],
127
			 AC_MSG_ERROR([Earthworm header files not found!])
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
	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_CHECK_FILES([$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_MSG_WARN(Earthworm object file is missing! Attempt to compile from source!)
			EWOSOURCES=yes
			]
		       )
	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
		;;
		*)
		    EWOS=unix
		    AC_MSG_WARN(Unrecognised OS $OSTYPE)
		;;
		esac
		AC_MSG_WARN(EWOS set to $EWOS)
		AC_SUBST(EWOS)
164 165 166
		AC_SUBST(EW_HOME)
		AC_SUBST(EW_VERSION)
		AC_SUBST(EW_PARAMS)
167 168 169 170 171 172
		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)
173 174 175 176
	       ],
	      [
	       LIBS="$LIBS $EWOBJS"
	       ])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
177 178 179 180 181
	],
	[AC_MSG_WARN([Earthworm files are not available (--without-ew to disable)])]
    )
    ],
    [AC_MSG_WARN([Earthworm support has been disabled!])]
182
)
183
AM_CONDITIONAL(WITHEWSOURCES, test x$EWOS != x)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
184
AM_CONDITIONAL(WITHEW, test x$with_ew != xno)
185

186

187
# Set BINARY_DIST_NAME_SUFFIX
188
BINARY_DIST_NAME_SUFFIX=$host
189 190 191 192
AC_MSG_NOTICE(BINARY_DIST_NAME_SUFFIX set to $BINARY_DIST_NAME_SUFFIX)
AC_SUBST(BINARY_DIST_NAME_SUFFIX)


193
# Checks for files.
194 195 196

# Seedlink check.
AS_IF([test "x$with_seedlink" != xno], 
197 198 199 200 201 202 203 204 205 206 207 208
      [
       AC_CHECK_FILES([./src/seedlink_plugin.c ./src/seedlink_plugin.h], [], AC_MSG_ERROR([seedlink plug-in sources not found!]))

       AS_IF([test "x$SEISCOMPDIR" == x],
	      [
	       SEISCOMPDIR=/home/sysop/seiscomp
	       ]
	      )
       AC_MSG_WARN([SEISCOMPDIR is set to ${SEISCOMPDIR}])
       AC_SUBST(SEISCOMPDIR)

       ],
209
    [AC_MSG_WARN([SeedLink support has been disabled!])]
210
)
211 212
AM_CONDITIONAL(WITHSEEDLINK, test x$with_seedlink != xno)

213 214 215

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
216
AC_TYPE_INT16_T
217
AC_TYPE_INT32_T
218 219
AC_TYPE_UINT32_T
AC_TYPE_INT8_T
220
AC_TYPE_PID_T
221 222 223 224 225
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_STRUCT_TM

# Checks for library functions.
Matteo Quintiliani's avatar
Matteo Quintiliani committed
226
AC_FUNC_MALLOC
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
AC_FUNC_MKTIME
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([gethostbyname inet_ntoa memset select socket strcasecmp strchr strdup strerror strtol])
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])

# 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
285 286

AC_CONFIG_FILES([Makefile
287
                 lib/Makefile
288
                 src/Makefile])
Matteo Quintiliani's avatar
Matteo Quintiliani committed
289 290 291

# AC_CONFIG_SUBDIRS([libnmxp])

292
AC_OUTPUT
Matteo Quintiliani's avatar
Matteo Quintiliani committed
293 294

AC_MSG_NOTICE([
295 296
      Compile nmxptool using 'make'.])

Matteo Quintiliani's avatar
Matteo Quintiliani committed
297
AS_IF([test "x$with_ew" != xno], 
298 299 300 301 302 303 304 305 306 307 308 309 310
      [AC_MSG_NOTICE([
      After compilation you can install nmxptool for Earthworm:
            make install-ew-bin
            make install-ew-conf])
      ]
)
AS_IF([test "x$with_seedlink" != xno], 
      [AC_MSG_NOTICE([
      After compilation you can install nmxptool for SeedLink:
            make install-seiscomp-bin
            make install-seiscomp-templates])
      ]
)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
311