configure.in 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. AC_INIT(src/main.c)
  2. NTRIPCASTER_MAJOR=0
  3. NTRIPCASTER_MINOR=1
  4. NTRIPCASTER_MICRO=5
  5. NTRIPCASTER_VERSION=$NTRIPCASTER_MAJOR.$NTRIPCASTER_MINOR.$NTRIPCASTER_MICRO
  6. PACKAGE=ntripcaster
  7. VERSION="$NTRIPCASTER_VERSION"
  8. echo "Building Ntripcaster-$VERSION..."
  9. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  10. AM_MAINTAINER_MODE
  11. if test "x$prefix" = "xNONE"; then
  12. prefix="/usr/local/ntripcaster"
  13. else
  14. prefix=$prefix
  15. fi
  16. NTRIPCASTER_BINDIR=${prefix}/bin
  17. NTRIPCASTER_ETCDIR_INST=${prefix}/conf
  18. NTRIPCASTER_LOGDIR_INST=${prefix}/logs
  19. NTRIPCASTER_ETCDIR=conf
  20. NTRIPCASTER_LOGDIR=logs
  21. NTRIPCASTER_SHAREDIR=${prefix}
  22. AM_CONFIG_HEADER(config.h)
  23. AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
  24. AC_SUBST(VERSION)
  25. AC_SUBST(NTRIPCASTER_BINDIR)
  26. AC_SUBST(NTRIPCASTER_ETCDIR_INST)
  27. AC_SUBST(NTRIPCASTER_LOGDIR_INST)
  28. AC_DEFINE_UNQUOTED(NTRIPCASTER_ETCDIR, "$NTRIPCASTER_ETCDIR")
  29. AC_SUBST(NTRIPCASTER_ETCDIR)
  30. AC_DEFINE_UNQUOTED(NTRIPCASTER_LOGDIR, "$NTRIPCASTER_LOGDIR")
  31. AC_SUBST(NTRIPCASTER_LOGDIR)
  32. AC_ARG_PROGRAM
  33. AC_PROG_RANLIB
  34. AC_PROG_CC
  35. if test "$CC" = "gcc"; then
  36. CFLAGS="$CFLAGS -Wall"
  37. fi
  38. AC_CHECK_PROG(UNAME,uname,uname)
  39. AC_PROG_INSTALL
  40. dnl weird ass systems
  41. AC_AIX
  42. AC_ISC_POSIX
  43. AC_MINIX
  44. AC_MSG_CHECKING(your OS)
  45. system=`$UNAME`
  46. IRIX=no
  47. case $system in
  48. Linux)
  49. LINUX=1
  50. AC_DEFINE(LINUX)
  51. AC_MSG_RESULT(Linux)
  52. ;;
  53. SunOS)
  54. if test x`uname -r | cut -d . -f 1` = "x5"; then
  55. SYSV=1
  56. SVR4=1
  57. SOLARIS=1
  58. AC_MSG_RESULT(Solaris)
  59. AC_DEFINE(SYSV)
  60. AC_DEFINE(SVR4)
  61. AC_DEFINE(SOLARIS)
  62. else
  63. AC_MSG_RESULT(SunOS)
  64. fi
  65. if test "$CC" = cc; then
  66. CFLAGS="$CFLAGS -mt"
  67. fi
  68. ;;
  69. HP-UX)
  70. hpux=1
  71. AC_DEFINE(hpux)
  72. AC_MSG_RESULT(HP-UX)
  73. CFLAGS="$CFLAGS -D_HPUX_SOURCE -DHPUX"
  74. if test "$CC" = cc; then
  75. CFLAGS="$CFLAGS -Aa"
  76. fi
  77. ;;
  78. IRIX)
  79. IRIX=yes
  80. AC_DEFINE(IRIX)
  81. AC_MSG_RESULT(IRIX)
  82. ;;
  83. BSD/OS)
  84. __SOMEBSD__=yes
  85. AC_DEFINE(__SOMEBSD__)
  86. AC_MSG_RESULT(BSD/OS)
  87. ;;
  88. *BSD*)
  89. __SOMEBSD__=yes
  90. AC_DEFINE(__SOMEBSD__)
  91. AC_MSG_RESULT(Some BSD variant)
  92. OLDCPPFLAGS=$CPPFLAGS
  93. THREADCPPFLAGS="-pthread"
  94. CPPFLAGS="$OLDCPPFLAGS $THREADCPPFLAGS"
  95. AC_TRY_COMPILE([#include <pthread.h>],
  96. [pthread_t thread; ],
  97. ,
  98. CPPFLAGS="$OLDCPPFLAGS")
  99. CPPFLAGS=$OLDCPPFLAGS
  100. if test "$CC" = gcc; then
  101. CFLAGS="-pthreads $CFLAGS"
  102. fi
  103. ;;
  104. *)
  105. AC_MSG_RESULT($system)
  106. ;;
  107. esac
  108. if test ${IRIX} = yes; then
  109. echo Skipping library tests because they confuse Irix.
  110. else
  111. AC_CHECK_FUNCS(socket)
  112. if test "$ac_cv_func_socket" = no; then
  113. for lib in socket inet; do
  114. if test "$HAVE_SOCKET" != 1; then
  115. AC_CHECK_LIB($lib, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
  116. fi
  117. done
  118. fi
  119. AC_CHECK_FUNCS(connect)
  120. if test "$ac_cv_func_connect" = no; then
  121. for lib in nsl; do
  122. if test "$HAVE_CONNECT" != 1; then
  123. AC_CHECK_LIB($lib, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
  124. fi
  125. done
  126. fi
  127. AC_CHECK_FUNCS(log)
  128. if test "$ac_cv_func_log" = no; then
  129. for lib in m; do
  130. AC_CHECK_LIB($lib, log)
  131. done
  132. fi
  133. AC_CHECK_FUNCS(gethostbyname)
  134. if test "$ac_cv_func_gethostbyname" = no; then
  135. for lib in dns nsl resolv; do
  136. if test "$HAVE_GETHOSTBYNAME" != 1; then
  137. AC_CHECK_LIB($lib, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
  138. fi
  139. done
  140. fi
  141. AC_CHECK_FUNCS(nanosleep)
  142. if test "$ac_cv_func_nanosleep" = no; then
  143. for lib in rt; do
  144. AC_CHECK_LIB($lib, nanosleep,LIBS="$LIBS -l$lib";HAVE_NANOSLEEP=1;AC_DEFINE(HAVE_NANOSLEEP))
  145. done
  146. fi
  147. fi
  148. opt_readline="no"
  149. dnl Do we want libreadline ?
  150. if test "$opt_readline" = "unset"; then
  151. if test -f "$withval/include/readline/readline.h"; then
  152. READLINE_INCLUDE="-I$withval/include"
  153. LDFLAGS="$LDFLAGS -L$withval/lib"
  154. AC_MSG_RESULT(yes)
  155. opt_readline="yes"
  156. elif test -f "$withval/include/readline.h"; then
  157. READLINE_INCLUDE="-I$withval/include"
  158. LDFLAGS="$LDFLAGS -L$withval/lib"
  159. AC_MSG_RESULT(yes)
  160. opt_readline="yes"
  161. elif test -f "$withval/readline.h"; then
  162. READLINE_INCLUDE="-I$withval"
  163. LDFLAGS="$LDFLAGS -L$withval"
  164. AC_MSG_RESULT(yes)
  165. opt_readline="yes"
  166. elif test -f "/usr/include/readline/readline.h"; then
  167. READLINE_INCLUDE="-I/usr/include/readline"
  168. AC_MSG_RESULT(yes)
  169. opt_readline="yes"
  170. elif test -f "/usr/include/readline.h"; then
  171. AC_MSG_RESULT(yes)
  172. opt_readline="yes"
  173. elif test -f "/usr/local/include/readline.h"; then
  174. READLINE_INCLUDE="-I/usr/local/include"
  175. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  176. AC_MSG_RESULT(yes)
  177. opt_readline="yes"
  178. elif test -f "/usr/local/include/readline/readline.h"; then
  179. READLINE_INCLUDE="-I/usr/local/include/readline"
  180. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  181. AC_MSG_RESULT(yes)
  182. opt_readline="yes"
  183. else
  184. AC_MSG_RESULT(no)
  185. opt_readline="no"
  186. fi
  187. fi
  188. if test "$opt_readline" = yes; then
  189. AC_CHECK_LIB(readline,
  190. readline,,
  191. [ AC_MSG_WARN(Testing with -ltermcap)
  192. unset ac_cv_lib_readline_readline
  193. AC_CHECK_LIB(readline,
  194. readline,
  195. LIBS="$LIBS -lreadline -ltermcap"
  196. AC_DEFINE(HAVE_LIBREADLINE),
  197. AC_MSG_WARN(Compiling without readline support),
  198. -ltermcap)]
  199. )
  200. fi
  201. CPPFLAGS="$CPPFLAGS $READLINE_INCLUDE"
  202. dnl Do we want libwrap?
  203. AC_MSG_CHECKING(whether to use libwrap)
  204. AC_ARG_WITH(libwrap,
  205. [ --with-libwrap[=PATH] compile in libwrap (tcp_wrappers) support.],
  206. [ case "$withval" in
  207. no)
  208. AC_MSG_RESULT(no)
  209. ;;
  210. yes)
  211. AC_MSG_RESULT(yes)
  212. AC_CHECK_LIB(wrap, request_init,WRAPLIBS="-lwrap";opt_libwrap="yes";)
  213. ;;
  214. *)
  215. AC_MSG_RESULT(yes)
  216. opt_libwrap="yes"
  217. if test -d "$withval"; then
  218. WRAPLIBS="-L$withval -lwrap"
  219. WRAPINCLUDES="-I$withval/include"
  220. else
  221. WRAPLIBS="$withval"
  222. fi
  223. OLDLIBS="$LIBS"
  224. LIBS="$WRAPLIBS $LIBS"
  225. AC_TRY_LINK([int allow_severity; int deny_severity; ],
  226. [hosts_access(); ],
  227. [],
  228. [AC_MSG_ERROR(Could not find the $withval library. You must first install tcp_wrappers.)])
  229. LIBS="$OLDLIBS"
  230. ;;
  231. esac ],
  232. AC_MSG_RESULT(no)
  233. )
  234. if test "$opt_libwrap" = yes; then
  235. AC_DEFINE(HAVE_LIBWRAP)
  236. AC_CHECK_FUNCS(yp_get_default_domain)
  237. if test "$ac_cv_func_yp_get_default_domain" = no; then
  238. for lib in wrap nsl nss_nis; do
  239. if test "$HAVE_YP_GET_DEFAULT_DOMAIN" != 1; then
  240. AC_CHECK_LIB($lib, yp_get_default_domain,LIBS="$LIBS -l$lib";HAVE_YP_GET_DEFAULT_DOMAIN=1;AC_DEFINE(HAVE_YP_GET_DEFAULT_DOMAIN))
  241. fi
  242. done
  243. fi
  244. fi
  245. AC_SUBST(WRAPLIBS)
  246. AC_SUBST(WRAPINCLUDES)
  247. dnl Do we want crypt?
  248. AC_MSG_CHECKING(whether to use crypted passwords)
  249. AC_ARG_WITH(crypt,
  250. [ --with-crypt use crypt() to encrypt server passwords.],
  251. [ case "$withval" in
  252. yes)
  253. AC_MSG_RESULT(yes)
  254. opt_crypt="yes"
  255. ;;
  256. *)
  257. AC_MSG_RESULT(no)
  258. ;;
  259. esac ],
  260. AC_MSG_RESULT(no)
  261. )
  262. CRYPTLIB=
  263. if test "$opt_crypt" = yes; then
  264. AC_CHECK_LIB(crypt, crypt, CRYPTLIB="-lcrypt",)
  265. AC_DEFINE(USE_CRYPT)
  266. fi
  267. AC_SUBST(CRYPTLIB)
  268. THREADLIBS="no"
  269. AC_MSG_CHECKING(for pthread functions in standard libraries)
  270. AC_TRY_LINK(, [pthread_create();],AC_MSG_RESULT(yes);THREADLIBS="",AC_MSG_RESULT(no))
  271. if test "$THREADLIBS" = ""; then
  272. AC_MSG_CHECKING(if that definition really works)
  273. AC_TRY_RUN([int main() { return !pthread_equal(pthread_self(), pthread_self());}],
  274. AC_MSG_RESULT(yes);THREADLIBS="",
  275. AC_MSG_RESULT(no);THREADLIBS="no",
  276. AC_MSG_RESULT(crosscompiling so no);THREADLIBS="no")
  277. fi
  278. if test "$THREADLIBS" = "no"; then
  279. for lib in pthread c_r dce pthreads; do
  280. AC_CHECK_LIB($lib,pthread_create,THREADLIBS="-l$lib")
  281. if test $THREADLIBS != "no"; then
  282. break
  283. fi
  284. done
  285. fi
  286. if test "$THREADLIBS" = "no"; then
  287. AC_CHECK_FUNCS(pthread_create,THREADLIBS="")
  288. fi
  289. if test "$THREADLIBS" = "no"; then
  290. AC_MSG_ERROR(Your system doesn't seem to support posix threads. Ntripcaster 0.2.0 and above won't work without threads support)
  291. exit
  292. fi
  293. AC_SUBST(THREADLIBS)
  294. LIBS="$LIBS $THREADLIBS"
  295. CFLAGS="$THREADCPPFLAGS $CPPFLAGS $CFLAGS"
  296. AC_ARG_WITH(python,
  297. [ --with-python[=ARG] enable usage of the python interpreter [ARG=yes]])
  298. AC_ARG_WITH(python-includes,
  299. [ --with-python-includes=DIR Python include files are in DIR])
  300. AC_ARG_WITH(python-libraries,
  301. [ --with-python-libraries=DIR Python library file are in DIR])
  302. if test "$with_python_includes"; then
  303. CPPFLAGS="$CPPFLAGS -I$with_python_includes"
  304. if test "$with_python" = ""; then
  305. with_python=yes
  306. fi
  307. fi
  308. if test "$with_python_libraries"; then
  309. LIBS="$LIBS -L$with_python_libraries"
  310. if test "$with_python" = ""; then
  311. with_python=yes
  312. fi
  313. fi
  314. if test "$with_python"; then
  315. dnl I can't say for sure what libs we need for python, but this is what my system needs
  316. AC_CHECK_LIB(dl, dlopen)
  317. for lib in python python2.0 python1.6 python1.5; do
  318. AC_CHECK_LIB($lib, Py_Initialize)
  319. done
  320. fi
  321. AC_TRY_COMPILE([#include <syslog.h>],
  322. [int foo = LOG_DAEMON; ],
  323. ,
  324. AC_DEFINE(NEED_SYS_SYSLOG_H))
  325. dnl Checks for header files.
  326. AC_HEADER_STDC
  327. AC_HEADER_SYS_WAIT
  328. AC_HEADER_DIRENT
  329. AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/soundcard.h machine/soundcard.h pthread.h assert.h sys/resource.h math.h signal.h sys/signal.h mcheck.h malloc.h history.h Python.h)
  330. dnl Checks for typedefs, structures, and compiler characteristics.
  331. AC_C_CONST
  332. AC_TYPE_PID_T
  333. AC_TYPE_SIZE_T
  334. AC_TYPE_SIGNAL
  335. AC_HEADER_TIME
  336. AC_STRUCT_TM
  337. AC_RETSIGTYPE
  338. AC_MSG_CHECKING([for unix98 socklen_t])
  339. AC_TRY_COMPILE([#include <sys/types.h>
  340. #include <sys/socket.h>],
  341. [typedef socklen_t int;
  342. int apan (void) {return 1;}],
  343. AC_MSG_RESULT(yeah)
  344. HAVE_SOCKLEN_T=yes,
  345. AC_MSG_RESULT(nah)
  346. HAVE_SOCKLEN_T=no)
  347. if test ${HAVE_SOCKLEN_T} = yes ;then
  348. AC_DEFINE(HAVE_SOCKLEN_T)
  349. fi
  350. dnl Checks for library functions.
  351. AC_FUNC_STRFTIME
  352. AC_FUNC_VPRINTF
  353. AC_CHECK_FUNCS(gettimeofday strstr snprintf vsnprintf rename setpgid basename setsockopt gethostbyname_r gethostbyaddr_r getrlimit setrlimit umask inet_addr inet_aton localtime_r select pthread_attr_setstacksize inet_ntoa mcheck mallinfo mtrace sigaction pthread_sigmask lseek)
  354. AC_MSG_CHECKING(if libm is bundled with some lib we're already linking)
  355. AC_TRY_LINK(, [sin(1);],AC_MSG_RESULT(yes);LDLAGS="",AC_MSG_RESULT(no);LDFLAGS="-lm")
  356. AC_OUTPUT([Makefile src/Makefile conf/Makefile conf/ntripcaster.conf.dist])
  357. echo "Ok, everything seems ok. Now do 'make'."
  358. echo "You can then run make install to install as you specified"