src/sn-apply.c: Remove unused include.
[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 PKG_PROG_PKG_CONFIG
18
19 # Libtool stuff
20 LT_INIT
21
22 if test "x$GCC" = "xyes"
23 then
24         CFLAGS="$CFLAGS -std=c99"
25 fi
26
27 AC_DEFINE([_ISOC99_SOURCE], [1], [Define to use C99])
28 AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Set to desired POSIX version])
29 AC_DEFINE([_XOPEN_SOURCE], [700], [Set to desired X/Open version])
30
31 # TODO: Write check for libpopulation
32 #AC_CHECK_LIB([population], [main])
33
34 # Checks for header files.
35 AC_HEADER_STDC
36 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdint.h])
37
38 # Checks for typedefs, structures, and compiler characteristics.
39 #AC_TYPE_INT64_T
40 #AC_TYPE_SIZE_T
41 #AC_TYPE_UINT32_T
42 #AC_TYPE_UINT64_T
43
44 # Checks for library functions.
45 AC_FUNC_MALLOC
46 AC_FUNC_REALLOC
47 AC_CHECK_FUNCS([memmove memset strcasecmp strchr strdup strtol])
48
49 AC_ARG_VAR([LIBPOPULATION_CPPFLAGS], [C preprocessor flags required to build with libpopulation])
50 AC_ARG_VAR([LIBPOPULATION_LDFLAGS],  [Linker flags required to build with libpopulation])
51 AC_ARG_VAR([LIBPOPULATION_LIBS],     [Other libraries required to link against libpopulation])
52
53 # --with-libpopulation {{{
54 LIBPOPULATION_CPPFLAGS="$LIBPOPULATION_CPPFLAGS"
55 LIBPOPULATION_LDFLAGS="$LIBPOPULATION_LDFLAGS"
56 LIBPOPULATION_LIBS="$LIBPOPULATION_LIBS"
57 AC_ARG_WITH(libpopulation, [AS_HELP_STRING([--with-libpopulation@<:@=PREFIX@:>@], [Path to libpopulation.])],
58 [
59         if test "x$withval" = "xyes" || test "x$withval" = "xno"
60         then
61                 with_libpopulation="$withval"
62         else
63                 LIBPOPULATION_CPPFLAGS="$LIBPOPULATION_CPPFLAGS -I$withval/include"
64                 LIBPOPULATION_LDFLAGS="$LIBPOPULATION_LDFLAGS -L$withval/lib"
65                 with_libpopulation="yes"
66         fi
67 ],
68 [
69         with_libpopulation="yes"
70 ])
71
72 SAVE_CPPFLAGS="$CPPFLAGS"
73 SAVE_LDFLAGS="$LDFLAGS"
74 CPPFLAGS="$CPPFLAGS $LIBPOPULATION_CPPFLAGS"
75 LDFLAGS="$LDFLAGS $LIBPOPULATION_LDFLAGS"
76
77 if test "x$with_libpopulation" = "xyes"
78 then
79         AC_CHECK_HEADERS(population.h,
80                          [with_libpopulation="yes"],
81                          [with_libpopulation="no"])
82 fi
83
84 if test "x$with_libpopulation" = "xyes"
85 then    
86         if test "x$LIBPOPULATION_LIBS" = "x"
87         then
88                 LIBPOPULATION_LIBS="-lpthread"
89         fi
90
91         AC_CHECK_LIB(population, population_create,
92                      [with_libpopulation="yes"],
93                      [with_libpopulation="no"],
94                      [$LIBPOPULATION_LIBS])
95         LIBPOPULATION_LIBS="-lpopulation $LIBPOPULATION_LIBS"
96 fi      
97
98 CPPFLAGS="$SAVE_CPPFLAGS"
99 LDFLAGS="$SAVE_LDFLAGS"
100
101 if test "x$with_libpopulation" = "xyes"
102 then
103         AC_DEFINE(HAVE_LIBPOPULATION, 1, [Define to 1 if you have the population library (-lpopulation).])
104 fi
105
106 AC_SUBST(LIBPOPULATION_CPPFLAGS)
107 AC_SUBST(LIBPOPULATION_LDFLAGS)
108 AC_SUBST(LIBPOPULATION_LIBS)
109 AM_CONDITIONAL(BUILD_WITH_LIBPOPULATION, test "x$with_libpopulation" = "xyes")
110 # }}} --with-libpopulation
111
112 PKG_CHECK_MODULES([glib], [glib-2.0],
113                   [have_libglib="yes"],
114                   [have_libglib="no"])
115
116 if test "x$have_libglib" != "xyes"
117 then
118         AC_MSG_ERROR([The GLib library could not be found. It is required when building libsortnetwork!])
119 fi
120
121 AC_CONFIG_FILES([Makefile src/Makefile])
122 AC_OUTPUT
123
124 # vim: set fdm=marker :