-
Notifications
You must be signed in to change notification settings - Fork 17
/
configure.ac
161 lines (134 loc) · 3.75 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
AC_PREREQ([2.67])
AC_INIT(ndtypes, 0.2.0dev3, [email protected], ndtypes, https://github.com/plures/)
AC_CONFIG_HEADER(config.h)
AC_CONFIG_FILES([
Makefile
libndtypes/Makefile libndtypes/tests/Makefile libndtypes/ndtypes.h
libndtypes/compat/Makefile
libndtypes/serialize/Makefile
])
# System and machine type (only used for Darwin):
AC_MSG_CHECKING(system as reported by uname -s)
ac_sys_system=`uname -s`
AC_MSG_RESULT($ac_sys_system)
LIBSTATIC=libndtypes.a
case $ac_sys_system in
darwin*|Darwin*)
LIBRARY_PATH="DYLD_LIBRARY_PATH"
LIBNAME="libndtypes.dylib"
LIBSONAME="libndtypes.0.dylib"
LIBSHARED="libndtypes.0.2.0dev3.dylib"
CONFIGURE_LDFLAGS="-dynamiclib -install_name @rpath/$LIBSONAME -compatibility_version 0.2 -current_version 0.2.0"
;;
*)
LIBRARY_PATH="LD_LIBRARY_PATH"
LIBNAME="libndtypes.so"
LIBSONAME="libndtypes.so.0"
LIBSHARED="libndtypes.so.0.2.0dev3"
CONFIGURE_LDFLAGS="-shared -Wl,-soname,$LIBSONAME"
;;
esac
AC_SUBST(LIBSTATIC)
AC_SUBST(LIBRARY_PATH)
AC_SUBST(LIBNAME)
AC_SUBST(LIBSONAME)
AC_SUBST(LIBSHARED)
# Apparently purely informational for this particular build:
AC_CANONICAL_HOST
AC_SUBST(build)
AC_SUBST(host)
# Language and compiler:
AC_LANG_C
saved_cflags=$CFLAGS
AC_PROG_CC
CFLAGS=$saved_cflags
# ar and ranlib:
AC_CHECK_TOOL(AR, ar, ar)
AC_PROG_RANLIB
AC_SUBST(RANLIB)
# Checks for header files:
AC_HEADER_STDC
# Install program:
AC_PROG_INSTALL
AC_SUBST(INSTALL)
# Endianness:
AC_C_BIGENDIAN
if test "$ac_cv_c_bigendian" = "yes"; then
NDT_SYS_BIG_ENDIAN=1
else
NDT_SYS_BIG_ENDIAN=0
fi
AC_SUBST(NDT_SYS_BIG_ENDIAN)
# Exact memcheck:
AC_MSG_CHECKING([for --with-valgrind])
AC_ARG_WITH([valgrind],
AS_HELP_STRING([--with-valgrind], [enable exact memcheck]),,
with_valgrind=no)
AC_MSG_RESULT([$with_valgrind])
if test "$with_valgrind" != no; then
AC_CHECK_HEADER([valgrind/memcheck.h],
[AC_DEFINE([WITH_VALGRIND], 1, [required for exact memcheck])],
[AC_MSG_ERROR([exact memcheck requested but headers not available])]
)
fi
# Without documentation:
AC_MSG_CHECKING([for --with-docs])
AC_ARG_WITH([docs],
AS_HELP_STRING([--with-docs], [install documentation - enabled by default]),,
with_docs=yes)
AC_MSG_RESULT([$with_docs])
if test "$with_docs" = yes; then
NDT_INSTALL_DOCS="install_docs"
else
NDT_INSTALL_DOCS=""
fi
AC_SUBST(NDT_INSTALL_DOCS)
# Compiler dependent settings:
NDT_WARN=
NDT_OPT="-O2 -g"
case $CC in
*gcc*)
NDT_WARN="-Wall -Wextra -std=c11 -pedantic"
NDT_OPT="-O2 -g"
NDT_COV_CFLAGS="-O0 -g -fno-inline -fprofile-arcs -ftest-coverage"
NDT_COV_LDFLAGS="-fprofile-arcs"
;;
*icc*)
AR=xiar
NDT_WARN="-Wall"
NDT_OPT="-O2 -g"
NDT_COV_CFLAGS=""
NDT_COV_LDFLAGS=""
;;
*clang*)
NDT_WARN="-Wall -Wextra -std=c11 -pedantic"
NDT_OPT="-O2 -g"
NDT_COV_CFLAGS="-O0 -g -fno-inline -fprofile-arcs -ftest-coverage"
NDT_COV_LDFLAGS="-fprofile-arcs"
;;
esac
# Substitute variables and generate output:
if test -z "$LD"; then
LD="$CC"
fi
AC_SUBST(LD)
AC_SUBST(AR)
AC_SUBST(NDT_WARN)
AC_SUBST(NDT_OPT)
if test -z "$CFLAGS"; then
CONFIGURE_CFLAGS="-I.. $NDT_WARN $NDT_OPT"
CONFIGURE_COV_CFLAGS="-I.. $NDT_WARN $NDT_COV_CFLAGS"
else
CONFIGURE_CFLAGS="-I.. $NDT_WARN $NDT_OPT $CFLAGS"
CONFIGURE_COV_CFLAGS="-I.. $NDT_WARN $NDT_COV_CFLAGS $CFLAGS"
fi
CONFIGURE_COV_LDFLAGS="$CONFIGURE_LDFLAGS $NDT_COV_LDFLAGS"
if test -n "$LDFLAGS"; then
CONFIGURE_LDFLAGS="$CONFIGURE_LDFLAGS $LDFLAGS"
CONFIGURE_COV_LDFLAGS="$CONFIGURE_COV_LDFLAGS $LDFLAGS"
fi
AC_SUBST(CONFIGURE_CFLAGS)
AC_SUBST(CONFIGURE_LDFLAGS)
AC_SUBST(CONFIGURE_COV_CFLAGS)
AC_SUBST(CONFIGURE_COV_LDFLAGS)
AC_OUTPUT