Commit | Line | Data |
---|---|---|
4a97c059 MJ |
1 | dnl SPDX-License-Identifier: MIT |
2 | dnl | |
3 | dnl Copyright (C) 2021 EfficiOS, Inc. | |
4 | dnl | |
5 | dnl Process this file with autoconf to produce a configure script. | |
6 | ||
7 | # Project version information | |
8 | m4_define([rseq_version_major], [0]) | |
9 | m4_define([rseq_version_minor], [1]) | |
10 | m4_define([rseq_version_patch], [0]) | |
11 | m4_define([rseq_version_dev_stage], [-pre]) | |
12 | m4_define([rseq_version], rseq_version_major[.]rseq_version_minor[.]rseq_version_patch[]rseq_version_dev_stage) | |
13 | ||
14 | # Library version information of "librseq" | |
2cbca301 MJ |
15 | # Following the numbering scheme proposed by libtool for the library version |
16 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html | |
4a97c059 MJ |
17 | m4_define([rseq_lib_version_current], [0]) |
18 | m4_define([rseq_lib_version_revision], [0]) | |
19 | m4_define([rseq_lib_version_age], [0]) | |
20 | m4_define([rseq_lib_version], rseq_lib_version_current[:]rseq_lib_version_revision[:]rseq_lib_version_age) | |
21 | ||
22 | ||
23 | ## ## | |
24 | ## Autoconf base setup ## | |
25 | ## ## | |
26 | ||
27 | AC_PREREQ([2.69]) | |
28 | AC_INIT([librseq],[rseq_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/librseq/]) | |
2cbca301 MJ |
29 | |
30 | AC_CONFIG_HEADERS([include/config.h]) | |
31 | AC_CONFIG_AUX_DIR([config]) | |
32 | AC_CONFIG_MACRO_DIR([m4]) | |
33 | ||
34 | AC_CANONICAL_TARGET | |
35 | AC_CANONICAL_HOST | |
36 | ||
4a97c059 MJ |
37 | |
38 | ## ## | |
39 | ## Automake base setup ## | |
40 | ## ## | |
41 | ||
42 | AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Werror]) | |
2cbca301 MJ |
43 | AM_MAINTAINER_MODE([enable]) |
44 | ||
4a97c059 MJ |
45 | # Enable silent rules by default |
46 | AM_SILENT_RULES([yes]) | |
2cbca301 | 47 | |
4a97c059 MJ |
48 | |
49 | ## ## | |
50 | ## C compiler checks ## | |
51 | ## ## | |
52 | ||
53 | # Choose the C compiler | |
2cbca301 | 54 | AC_PROG_CC |
4a97c059 MJ |
55 | # AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70 |
56 | m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) | |
2cbca301 | 57 | |
4a97c059 MJ |
58 | # Make sure the C compiler supports C99 |
59 | AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])]) | |
2cbca301 | 60 | |
4a97c059 MJ |
61 | # Enable available system extensions and LFS support |
62 | AC_USE_SYSTEM_EXTENSIONS | |
63 | AC_SYS_LARGEFILE | |
64 | ||
65 | # Make sure the C compiler supports __attribute__ | |
66 | AX_C___ATTRIBUTE__ | |
67 | AS_IF([test "x$ax_cv___attribute__" != "xyes"], | |
68 | [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])]) | |
69 | ||
70 | # Make sure we have pthread support | |
71 | AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])]) | |
2cbca301 MJ |
72 | |
73 | # Checks for typedefs, structures, and compiler characteristics. | |
74 | AC_C_INLINE | |
4a97c059 | 75 | AC_C_TYPEOF |
2cbca301 MJ |
76 | AC_TYPE_INT32_T |
77 | AC_TYPE_INT64_T | |
78 | AC_TYPE_OFF_T | |
79 | AC_TYPE_SIZE_T | |
80 | AC_TYPE_UINT32_T | |
81 | AC_TYPE_UINT64_T | |
82 | ||
2cbca301 | 83 | |
4a97c059 MJ |
84 | ## ## |
85 | ## Header checks ## | |
86 | ## ## | |
87 | ||
88 | AC_HEADER_STDBOOL | |
89 | AC_CHECK_HEADERS([ \ | |
90 | limits.h \ | |
91 | stddef.h \ | |
92 | sys/time.h \ | |
93 | ]) | |
94 | ||
95 | AC_CHECK_HEADER([linux/rseq.h], [], | |
96 | [AC_MSG_ERROR([Cannot find 'linux/rseq.h'.]) | |
97 | ]) | |
98 | ||
99 | ||
100 | ## ## | |
101 | ## Programs checks ## | |
102 | ## ## | |
103 | ||
104 | AM_PROG_AR | |
105 | AC_PROG_AWK | |
106 | AC_PROG_MAKE_SET | |
107 | ||
108 | # Initialize and configure libtool | |
109 | LT_INIT | |
2cbca301 | 110 | |
4a97c059 MJ |
111 | |
112 | ## ## | |
113 | ## Library checks ## | |
114 | ## ## | |
2cbca301 MJ |
115 | |
116 | # Checks for library functions. | |
117 | AC_FUNC_MMAP | |
118 | AC_FUNC_FORK | |
119 | AC_CHECK_FUNCS([ \ | |
4a97c059 | 120 | atexit \ |
2cbca301 MJ |
121 | memset \ |
122 | strerror \ | |
123 | ]) | |
124 | ||
125 | # AC_FUNC_MALLOC causes problems when cross-compiling. | |
126 | #AC_FUNC_MALLOC | |
127 | ||
9698c399 MD |
128 | # Check dor dlopen() in -ldl or -lc |
129 | AC_CHECK_LIB([dl], [dlopen], [ | |
130 | libdl_name=dl | |
131 | DL_LIBS="-ldl" | |
132 | ], [ | |
133 | # dlopen not found in libdl, check in libc | |
134 | AC_CHECK_LIB([c], [dlopen], [ | |
135 | libdl_name=c | |
136 | DL_LIBS="-lc" | |
137 | ], [ | |
138 | AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.]) | |
139 | ]) | |
140 | ]) | |
141 | AC_SUBST(DL_LIBS) | |
2cbca301 | 142 | |
4a97c059 MJ |
143 | ## ## |
144 | ## Substitute variables for use in Makefile.am ## | |
145 | ## ## | |
146 | ||
147 | # Library versions for libtool | |
148 | AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version]) | |
2cbca301 | 149 | |
4a97c059 MJ |
150 | # The order in which the include folders are searched is important. |
151 | # The top_builddir should always be searched first in the event that a build | |
152 | # time generated file is included. | |
153 | AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h" | |
2cbca301 MJ |
154 | AC_SUBST(AM_CPPFLAGS) |
155 | ||
4a97c059 | 156 | AM_CFLAGS="-Wall -Wextra $PTHREAD_CFLAGS" |
2cbca301 MJ |
157 | AC_SUBST(AM_CFLAGS) |
158 | ||
4a97c059 MJ |
159 | |
160 | ## ## | |
161 | ## Output files generated by configure ## | |
162 | ## ## | |
163 | ||
2cbca301 MJ |
164 | AC_CONFIG_FILES([ |
165 | Makefile | |
6146efae MD |
166 | doc/Makefile |
167 | doc/man/Makefile | |
2cbca301 MJ |
168 | include/Makefile |
169 | src/Makefile | |
2cbca301 | 170 | src/librseq.pc |
b848736e | 171 | tests/Makefile |
544cdc88 | 172 | tests/utils/Makefile |
2cbca301 MJ |
173 | ]) |
174 | ||
175 | AC_OUTPUT | |
aa4ed6d6 | 176 | |
4a97c059 | 177 | |
aa4ed6d6 MJ |
178 | # |
179 | # Mini-report on what will be built. | |
180 | # | |
181 | ||
182 | PPRINT_INIT | |
183 | PPRINT_SET_INDENT(1) | |
184 | PPRINT_SET_TS(38) | |
185 | ||
186 | AS_ECHO | |
187 | AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}") | |
188 | AS_ECHO | |
189 | ||
190 | PPRINT_SUBTITLE([Features]) | |
191 | ||
192 | PPRINT_PROP_STRING([Target architecture], $host_cpu) | |
193 | ||
aa4ed6d6 MJ |
194 | report_bindir="`eval eval echo $bindir`" |
195 | report_libdir="`eval eval echo $libdir`" | |
196 | ||
197 | # Print the bindir and libdir this `make install' will install into. | |
198 | AS_ECHO | |
199 | PPRINT_SUBTITLE([Install directories]) | |
200 | PPRINT_PROP_STRING([Binaries], [$report_bindir]) | |
201 | PPRINT_PROP_STRING([Libraries], [$report_libdir]) |