lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | # -*- Autoconf -*- |
| 2 | # Process this file with autoconf to produce a configure script. |
| 3 | |
| 4 | AC_PREREQ(2.59) |
| 5 | AC_INIT(library, 1.0, support@itibia.com) |
| 6 | AC_CONFIG_AUX_DIR([build]) |
| 7 | AM_INIT_AUTOMAKE([-Wall -Werror foreign]) |
| 8 | AC_CONFIG_SRCDIR([]) |
| 9 | AC_CONFIG_HEADER([config.h]) |
| 10 | |
| 11 | #AC_PREFIX_DEFAULT([]) |
| 12 | |
| 13 | # Checks for programs. |
| 14 | AC_PROG_CXX(g++) |
| 15 | AC_PROG_CC(gcc g++) |
| 16 | AC_PROG_MAKE_SET |
| 17 | AC_PROG_CPP |
| 18 | AC_PROG_LIBTOOL |
| 19 | AC_PROG_RANLIB |
| 20 | |
| 21 | # Checks for libraries. |
| 22 | #AC_CHECK_LIB([rt], [mq_open]) |
| 23 | |
| 24 | # Checks for header files. |
| 25 | AC_HEADER_DIRENT |
| 26 | AC_HEADER_STDC |
| 27 | AC_HEADER_SYS_WAIT |
| 28 | AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h malloc.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h ]) |
| 29 | |
| 30 | |
| 31 | # Checks for typedefs, structures, and compiler characteristics. |
| 32 | AC_HEADER_STDBOOL |
| 33 | AC_C_CONST |
| 34 | AC_TYPE_UID_T |
| 35 | AC_C_INLINE |
| 36 | AC_TYPE_PID_T |
| 37 | AC_TYPE_SIZE_T |
| 38 | AC_STRUCT_TM |
| 39 | |
| 40 | # Checks for library functions. |
| 41 | AC_FUNC_ALLOCA |
| 42 | AC_FUNC_CHOWN |
| 43 | AC_FUNC_CLOSEDIR_VOID |
| 44 | AC_FUNC_FORK |
| 45 | AC_PROG_GCC_TRADITIONAL |
| 46 | #comment it to prevent autoconf #define HAVE_MALLOC to 0 and #define malloc to rpl_malloc |
| 47 | #AC_FUNC_MALLOC |
| 48 | #AC_FUNC_MKTIME |
| 49 | #AC_FUNC_REALLOC |
| 50 | AC_FUNC_SELECT_ARGTYPES |
| 51 | AC_TYPE_SIGNAL |
| 52 | AC_FUNC_STAT |
| 53 | AC_FUNC_STRFTIME |
| 54 | #check machine endian |
| 55 | AC_C_BIGENDIAN |
| 56 | |
| 57 | AC_CHECK_SIZEOF(int,[]) |
| 58 | AC_CHECK_SIZEOF(short,[]) |
| 59 | AC_CHECK_SIZEOF(long,[]) |
| 60 | AC_CHECK_SIZEOF(float,[]) |
| 61 | AC_CHECK_SIZEOF(double,[]) |
| 62 | |
| 63 | AC_TYPE_PID_T |
| 64 | AC_TYPE_SIZE_T |
| 65 | |
| 66 | AC_CHECK_FUNCS([alarm bzero endgrent endpwent getcwd gethostbyname inet_ntoa isascii localtime_r memmove memset mkdir regcomp select socket strcasecmp strchr strcspn strdup strerror strncasecmp strrchr strspn strstr]) |
| 67 | |
| 68 | AC_CONFIG_FILES([Makefile |
| 69 | libpool/src/Makefile libxmlet/src/Makefile libcwmp/src/Makefile |
| 70 | cwmpd/src/Makefile tests/src/Makefile |
| 71 | ]) |
| 72 | |
| 73 | |
| 74 | |
| 75 | #save user-provided flags |
| 76 | save_CXXFLAGS="$CXXFLAGS" |
| 77 | save_CFLAGS="-Wall -g" |
| 78 | save_LDFALGS="$LDFLAGS" |
| 79 | save_CPPFLAGS="-Wall -g" |
| 80 | |
| 81 | #restore user-provided flags |
| 82 | CXXFLAGS="$save_CXXFLAGS" |
| 83 | CFLAGS="$save_CFLAGS " |
| 84 | #Note that sysconfdir is expaned in Makefile other than here, check generated configure script, u can see |
| 85 | #sysconfdir is surrounded by single quotas to prevent expansion. |
| 86 | CPPFLAGS="-D_GNU_SOURCE $save_CPPFLAGS" |
| 87 | |
| 88 | LDFLAGS="$save_LDFALGS" |
| 89 | |
| 90 | #CPPFLAGS="$CPPFLAGS -DUSE_CWMP_OPENSSL" |
| 91 | OPENSSL_DIR=no |
| 92 | |
| 93 | AC_ARG_WITH(openssl, --with-openssl=<path> sets path to temp directory, OPENSSL_DIR=$withval, OPENSSL_DIR=no) |
| 94 | |
| 95 | if test x"$OPENSSL_DIR" != "xno"; then |
| 96 | CPPFLAGS="$CPPFLAGS -DUSE_CWMP_OPENSSL -I$OPENSSL_DIR/include" |
| 97 | LDFLAGS="$LDFLAGS -L$OPENSSL_DIR/lib -lssl" |
| 98 | fi |
| 99 | AC_SUBST(OPENSSL_DIR) |
| 100 | |
| 101 | #LIBS will be appended to gcc command, so it must be cleared to prevent unnecessary linking |
| 102 | #LIBS="" |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | #AC_CANONICAL_BUILD |
| 108 | #AC_CANONICAL_HOST |
| 109 | |
| 110 | AH_TEMPLATE([BUILD_CPU], [cpu type used in building environment]) |
| 111 | if test "x$build_cpu" != "x"; then |
| 112 | BUILD_CPU="$build_cpu" |
| 113 | AC_SUBST([BUILD_CPU]) |
| 114 | AC_DEFINE_UNQUOTED([BUILD_CPU], [$build_cpu], []) |
| 115 | fi |
| 116 | AH_TEMPLATE([BUILD_VENDOR], [cpu vendor in building environment]) |
| 117 | if test "x$build_vendor" != "x"; then |
| 118 | BUILD_VENDOR="$build_vendor" |
| 119 | AC_SUBST([BUILD_VENDOR]) |
| 120 | AC_DEFINE_UNQUOTED([BUILD_VENDOR], [$build_vendor], []) |
| 121 | fi |
| 122 | AH_TEMPLATE([BUILD_OS], [os of building environment]) |
| 123 | if test "x$build_os" != "x"; then |
| 124 | BUILD_OS="$build_os" |
| 125 | AC_SUBST([BUILD_OS]) |
| 126 | AC_DEFINE_UNQUOTED([BUILD_OS], [$build_os], []) |
| 127 | fi |
| 128 | |
| 129 | AH_TEMPLATE([HOST_CPU], [cpu type of host environment]) |
| 130 | if test "x$host_cpu" != "x"; then |
| 131 | HOST_CPU="$host_cpu" |
| 132 | AC_SUBST([HOST_CPU]) |
| 133 | AC_DEFINE_UNQUOTED([HOST_CPU], [$host_cpu], []) |
| 134 | fi |
| 135 | AH_TEMPLATE([HOST_VENDOR], [cpu vendor of host environment]) |
| 136 | if test "x$host_vendor" != "x"; then |
| 137 | HOST_VENDOR="$host_vendor" |
| 138 | AC_SUBST([HOST_VENDOR]) |
| 139 | AC_DEFINE_UNQUOTED([HOST_VENDOR], [$host_vendor], []) |
| 140 | fi |
| 141 | AH_TEMPLATE([HOST_OS], [os of host environment]) |
| 142 | if test "x$host_os" != "x"; then |
| 143 | HOST_OS="$host_os" |
| 144 | AC_SUBST([HOST_OS]) |
| 145 | AC_DEFINE_UNQUOTED([HOST_OS], [$host_os], []) |
| 146 | fi |
| 147 | |
| 148 | AM_CONDITIONAL([COMPILE_FOR_MIPS], [ test "$target" = "mips64-octeon-linux-gnu" ]) |
| 149 | AC_OUTPUT |