src/sn_{network,stage}.[ch]: Implement sn_network_unify().
[sort-networks.git] / configure.ac
1 AC_PREREQ([2.61])
2 AC_INIT([libsortnetwork], [1.0.0], [ff@octo.it])
3 AC_CONFIG_SRCDIR([src/sn_network.c])
4 AC_CONFIG_HEADERS([src/config.h])
5 AM_INIT_AUTOMAKE(dist-bzip2)
6 AC_LANG(C)
7
8 AC_PREFIX_DEFAULT("/opt/libsortnetwork")
9
10 # Checks for programs.
11 AC_PROG_CC
12 AC_PROG_CPP
13 AC_PROG_INSTALL
14 AM_PROG_CC_C_O
15 AC_DISABLE_STATIC
16 AC_PROG_LIBTOOL
17
18 # Libtool stuff
19 LT_INIT
20
21 if test "x$GCC" = "xyes"
22 then
23         CFLAGS="$CFLAGS -std=c99"
24 fi
25
26 AC_DEFINE([_ISOC99_SOURCE], [1], [Define to use C99])
27 AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Set to desired POSIX version])
28 AC_DEFINE([_XOPEN_SOURCE], [700], [Set to desired X/Open version])
29
30 # TODO: Write check for libpopulation
31 #AC_CHECK_LIB([population], [main])
32
33 # Checks for header files.
34 AC_HEADER_STDC
35 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdint.h])
36
37 # Checks for typedefs, structures, and compiler characteristics.
38 #AC_TYPE_INT64_T
39 #AC_TYPE_SIZE_T
40 #AC_TYPE_UINT32_T
41 #AC_TYPE_UINT64_T
42
43 # Checks for library functions.
44 AC_FUNC_MALLOC
45 AC_FUNC_REALLOC
46 AC_CHECK_FUNCS([memmove memset strcasecmp strchr strdup strtol])
47
48 AC_ARG_VAR([LIBPOPULATION_CPPFLAGS], [C preprocessor flags required to build with libpopulation])
49 AC_ARG_VAR([LIBPOPULATION_LDFLAGS],  [Linker flags required to build with libpopulation])
50 AC_ARG_VAR([LIBPOPULATION_LIBS],     [Other libraries required to link against libpopulation])
51
52 # --with-libpopulation {{{
53 LIBPOPULATION_CPPFLAGS="$LIBPOPULATION_CPPFLAGS"
54 LIBPOPULATION_LDFLAGS="$LIBPOPULATION_LDFLAGS"
55 LIBPOPULATION_LIBS="$LIBPOPULATION_LIBS"
56 AC_ARG_WITH(libpopulation, [AS_HELP_STRING([--with-libpopulation@<:@=PREFIX@:>@], [Path to libpopulation.])],
57 [
58         if test "x$withval" = "xyes" || test "x$withval" = "xno"
59         then
60                 with_libpopulation="$withval"
61         else
62                 LIBPOPULATION_CPPFLAGS="$LIBPOPULATION_CPPFLAGS -I$withval/include"
63                 LIBPOPULATION_LDFLAGS="$LIBPOPULATION_LDFLAGS -L$withval/lib"
64                 with_libpopulation="yes"
65         fi
66 ],
67 [
68         with_libpopulation="yes"
69 ])
70
71 SAVE_CPPFLAGS="$CPPFLAGS"
72 SAVE_LDFLAGS="$LDFLAGS"
73 CPPFLAGS="$CPPFLAGS $LIBPOPULATION_CPPFLAGS"
74 LDFLAGS="$LDFLAGS $LIBPOPULATION_LDFLAGS"
75
76 if test "x$with_libpopulation" = "xyes"
77 then
78         AC_CHECK_HEADERS(population.h,
79                          [with_libpopulation="yes"],
80                          [with_libpopulation="no"])
81 fi
82
83 if test "x$with_libpopulation" = "xyes"
84 then    
85         if test "x$LIBPOPULATION_LIBS" = "x"
86         then
87                 LIBPOPULATION_LIBS="-lpthread"
88         fi
89
90         AC_CHECK_LIB(population, population_create,
91                      [with_libpopulation="yes"],
92                      [with_libpopulation="no"],
93                      [$LIBPOPULATION_LIBS])
94         LIBPOPULATION_LIBS="-lpopulation $LIBPOPULATION_LIBS"
95 fi      
96
97 CPPFLAGS="$SAVE_CPPFLAGS"
98 LDFLAGS="$SAVE_LDFLAGS"
99
100 if test "x$with_libpopulation" = "xyes"
101 then
102         AC_DEFINE(HAVE_LIBPOPULATION, 1, [Define to 1 if you have the population library (-lpopulation).])
103 fi
104
105 AC_SUBST(LIBPOPULATION_CPPFLAGS)
106 AC_SUBST(LIBPOPULATION_LDFLAGS)
107 AC_SUBST(LIBPOPULATION_LIBS)
108 AM_CONDITIONAL(BUILD_WITH_LIBPOPULATION, test "x$with_libpopulation" = "xyes")
109 # }}} --with-libpopulation
110
111 AC_CONFIG_FILES([Makefile src/Makefile])
112 AC_OUTPUT
113
114 # vim: set fdm=marker :