|
1 |
| -AC_INIT(bgpq4, 0.0.7, [email protected]) |
2 |
| -AM_INIT_AUTOMAKE |
| 1 | +# |
| 2 | +# Copyright (c) 2019 Brent Cook |
| 3 | +# |
| 4 | +# Permission to use, copy, modify, and distribute this software for any |
| 5 | +# purpose with or without fee is hereby granted, provided that the above |
| 6 | +# copyright notice and this permission notice appear in all copies. |
| 7 | +# |
| 8 | +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
3 | 15 |
|
| 16 | +AC_INIT([bgpq4], m4_esyscmd([tr -d '\n' < VERSION]), [email protected]) |
| 17 | + |
| 18 | +AC_CANONICAL_HOST |
| 19 | +AM_INIT_AUTOMAKE([subdir-objects foreign]) |
4 | 20 | AC_CONFIG_MACRO_DIR([m4])
|
| 21 | +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
| 22 | +AC_PROG_CC([cc gcc]) |
5 | 23 |
|
6 |
| -AC_PACKAGE_URL(https://github.com/bgp/bgpq4) |
7 |
| -AC_CONFIG_HEADERS([config.h]) |
8 |
| -AM_SILENT_RULES([yes]) |
| 24 | +case $host_os in |
| 25 | + *darwin*) |
| 26 | + HOST_OS=darwin |
| 27 | + AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV]) |
| 28 | + ;; |
| 29 | + *freebsd*) |
| 30 | + HOST_OS=freebsd |
| 31 | + ;; |
| 32 | + *linux*) |
| 33 | + HOST_OS=linux |
| 34 | + CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE" |
| 35 | + AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV]) |
| 36 | + ;; |
| 37 | + *netbsd*) |
| 38 | + HOST_OS=netbsd |
| 39 | + ;; |
| 40 | + *openbsd*) |
| 41 | + HOST_OS=openbsd |
| 42 | + AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD has __bounded__]) |
| 43 | + AC_DEFINE([HAVE_ATTRIBUTE__DEAD], [1], [OpenBSD has __dead]) |
| 44 | + ;; |
| 45 | + *solaris*) |
| 46 | + HOST_OS=solaris |
| 47 | + CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP" |
| 48 | + ;; |
| 49 | + *) ;; |
| 50 | +esac |
9 | 51 |
|
10 |
| -AC_PROG_CC |
11 |
| -CC=cc |
12 |
| -CFLAGS="${CFLAGS} -std=gnu11" |
| 52 | +AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) |
| 53 | +AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) |
| 54 | +AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) |
| 55 | +AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd]) |
| 56 | +AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) |
13 | 57 |
|
| 58 | +AC_PROG_CC |
| 59 | +AC_PROG_CC_STDC |
| 60 | +AM_PROG_CC_C_O |
14 | 61 | AC_PROG_LIBTOOL
|
15 |
| - |
16 | 62 | AC_PROG_INSTALL
|
17 | 63 |
|
18 |
| -AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) |
| 64 | +AC_ARG_ENABLE(warnings, |
| 65 | + AS_HELP_STRING([--disable-warnings], |
| 66 | + [ enable compiler warnings [default=enabled]]), |
| 67 | + [case $enableval in |
| 68 | + yes) enable_warnings=yes;; |
| 69 | + no) enable_warnings=no;; |
| 70 | + *) enable_warnings=yes;; esac], |
| 71 | + enable_warnings=yes) |
19 | 72 |
|
20 |
| -AC_CHECK_HEADERS([sys/cdefs.h sys/queue.h sys/tree.h sys/select.h]) |
| 73 | +if test "$enable_warnings" = yes; then |
| 74 | + AM_CFLAGS="$AM_CFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wsign-compare -Werror-implicit-function-declaration" |
| 75 | + save_cflags="$CFLAGS" |
| 76 | + CFLAGS=-Wno-pointer-sign |
| 77 | + AC_MSG_CHECKING([whether CC supports -Wno-pointer-sign]) |
| 78 | + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
| 79 | + [AC_MSG_RESULT([yes])] |
| 80 | + [WARN_CFLAGS=-Wno-pointer-sign], |
| 81 | + [AC_MSG_RESULT([no])] |
| 82 | + ) |
| 83 | + AM_CFLAGS="$AM_CFLAGS $WARN_CFLAGS" |
| 84 | + CFLAGS="$save_cflags" |
| 85 | +fi |
| 86 | + |
| 87 | +AC_MSG_CHECKING([if compiling with clang]) |
| 88 | +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ |
| 89 | +#ifndef __clang__ |
| 90 | + not clang |
| 91 | +#endif |
| 92 | + ]])], |
| 93 | + [AC_MSG_RESULT([yes])] |
| 94 | + [CLANG_FLAGS=-Qunused-arguments], |
| 95 | + [AC_MSG_RESULT([no])] |
| 96 | +) |
| 97 | +AM_CFLAGS="$AM_CFLAGS $CLANG_FLAGS" |
| 98 | +AM_LDFLAGS="$LDFLAGS $CLANG_FLAGS" |
| 99 | +AC_SUBST(AM_CFLAGS) |
| 100 | +AC_SUBST(AM_LDFLAGS) |
21 | 101 |
|
22 | 102 | AC_CHECK_FUNCS(strlcpy)
|
23 | 103 | AC_CHECK_FUNCS(pledge)
|
24 | 104 |
|
25 | 105 | AC_CHECK_LIB(socket,socket)
|
26 | 106 | AC_CHECK_LIB(nsl,getaddrinfo)
|
27 | 107 |
|
| 108 | +AC_CHECK_HEADERS([sys/cdefs.h sys/queue.h sys/tree.h sys/select.h]) |
| 109 | + |
| 110 | +AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) |
| 111 | + |
28 | 112 | AC_CONFIG_FILES([
|
29 | 113 | Makefile
|
30 | 114 | include/Makefile
|
|
0 commit comments