Skip to content

Commit f9cbff7

Browse files
committed
Improve build system (including some compiler/linker flags from libsodium and Debian Hardening). Fix tests.
1 parent 8b18a89 commit f9cbff7

14 files changed

Lines changed: 3735 additions & 98 deletions

Makefile.am

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
ACLOCAL_AMFLAGS = -I m4
22

3-
LIBCURVECPR_API_VERSION = 1:0:0
4-
53
lib_LTLIBRARIES = libcurvecpr.la
64

75
libcurvecpr_la_CPPFLAGS = -I$(top_srcdir)/include
8-
libcurvecpr_la_CFLAGS = \
9-
-Wall -W -Wcast-qual -Wcast-align -Winline -Wmissing-prototypes -Wwrite-strings \
10-
-Wredundant-decls -Wpointer-arith -Wchar-subscripts -Wshadow -Wstrict-prototypes -Werror
11-
libcurvecpr_la_LDFLAGS = -version-info $(LIBCURVECPR_API_VERSION)
6+
libcurvecpr_la_LDFLAGS = -version-info $(CURVECPR_LIBRARY_VERSION)
127

13-
AUTOMAKE_OPTIONS = subdir-objects
148
libcurvecpr_la_SOURCES = \
159
lib/bytes.c \
1610
lib/chicago.c \

autogen.sh

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,2 @@
11
#! /bin/sh
2-
3-
PROGRAM="libcurvecpr"
4-
5-
SCRIPT=$( basename $0 )
6-
ERROR=0
7-
8-
error() {
9-
MESSAGE=$1
10-
echo "error: ${MESSAGE}"
11-
12-
ERROR=1
13-
}
14-
15-
hint() {
16-
MESSAGE=$1
17-
echo "hint: ${MESSAGE}"
18-
}
19-
20-
status() {
21-
MESSAGE=$1
22-
echo "${SCRIPT}: ${MESSAGE}"
23-
}
24-
25-
die_if_error() {
26-
if [ $ERROR -ne 0 ]; then
27-
exit 1
28-
fi
29-
}
30-
31-
( autoconf --version >/dev/null 2>&1 ) || {
32-
error "The \`autoconf\` program must be installed to compile ${PROGRAM}."
33-
}
34-
35-
( automake --version >/dev/null 2>&1 ) || {
36-
error "The \`automake\` program must be installed to compile ${PROGRAM}."
37-
}
38-
39-
( aclocal --version >/dev/null 2>&1 ) || {
40-
error "The \`aclocal\` program must be installed to compile ${PROGRAM}."
41-
hint "\`aclocal\` is usually provided by \`automake\`. Is your version of \`automake\`"
42-
hint "up to date?"
43-
}
44-
45-
( libtool --version >/dev/null 2>&1 ) || {
46-
error "The \`libtool\` program must be installed to compile ${PROGRAM}."
47-
}
48-
49-
( libtoolize --version >/dev/null 2>&1 ) || {
50-
error "The \`libtoolize\` program must be installed to compile ${PROGRAM}."
51-
hint "\`libtoolize\` is usually provided by \`libtool\`. Is your version of \`libtool\`"
52-
hint "up to date?"
53-
}
54-
55-
( pkg-config --version >/dev/null 2>&1 ) || {
56-
error "The \`pkg-config\` program must be installed to compile ${PROGRAM}."
57-
}
58-
59-
die_if_error
60-
61-
status "Running libtoolize"
62-
( libtoolize --force --copy ) || {
63-
error "libtoolize failed"
64-
exit 1
65-
}
66-
67-
status "Running aclocal"
68-
( aclocal ) || {
69-
error "aclocal failed"
70-
exit 1
71-
}
72-
73-
status "Running autoheader"
74-
( autoheader ) || {
75-
error "autoheader failed"
76-
exit 1
77-
}
78-
79-
status "Running automake"
80-
( automake --add-missing ) || {
81-
error "automake failed"
82-
exit 1
83-
}
84-
85-
status "Running autoconf"
86-
( autoconf ) || {
87-
error "autoconf failed"
88-
exit 1
89-
}
2+
exec autoreconf -fvi

configure.ac

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
AC_PREREQ(2.67)
22
AC_INIT(libcurvecpr, 0.1.0, nfontes+libcurvecpr@cynigram.com, libcurvecpr)
3-
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
3+
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
44

55
AC_CONFIG_SRCDIR([include/server.h])
66
AC_CONFIG_HEADER([include/config.h])
77
AC_CONFIG_MACRO_DIR([m4])
88

9+
# Library version.
10+
CURVECPR_LIBRARY_VERSION=1:0:0
11+
AC_SUBST(CURVECPR_LIBRARY_VERSION)
12+
913
# Checks for programs.
1014
AC_PROG_CC
1115
AC_PROG_CPP
@@ -38,6 +42,20 @@ AC_CHECK_TYPE([struct timespec], [], [AC_MSG_ERROR([missing struct timespec])],
3842
# Checks for functions.
3943
AC_CHECK_FUNCS([clock_gettime], [], [AC_MSG_ERROR([missing clock_gettime])])
4044

45+
# Checks for compiler flags.
46+
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
47+
AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -fno-strict-overflow], [], [-Wno-error])
48+
AX_CHECK_LINK_FLAG([-fstack-protector], [AX_APPEND_COMPILE_FLAGS([-fstack-protector], [], [-Wno-error])], [], [], [-Wno-error])
49+
AX_CHECK_LINK_FLAG([-fstack-protector-all], [AX_APPEND_COMPILE_FLAGS([-fstack-protector-all], [], [-Wno-error])], [], [], [-Wno-error])
50+
AX_APPEND_COMPILE_FLAGS([ dnl
51+
-Wall -Wextra -Wcast-qual -Wcast-align -Winline -Wmissing-prototypes -Wmissing-declarations dnl
52+
-Wwrite-strings -Wredundant-decls -Wpointer-arith -Wchar-subscripts -Wshadow -Wstrict-prototypes dnl
53+
-Wvariable-decl -Winit-self -Wdiv-by-zero -Wsometimes-uninitialized -Wbad-function-cast -Wcomment dnl
54+
-Wfloat-equal -Wformat=2 -Wimplicit -Wnormalized=id -Woverride-init -Wparentheses -Wswitch-enum dnl
55+
-Wno-unused-parameter dnl
56+
], [], [-Wno-error])
57+
AX_APPEND_LINK_FLAGS([-Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack], [], [-Wno-error])
58+
4159
# Done!
4260
AC_CONFIG_FILES([Makefile libcurvecpr.pc])
4361
AC_OUTPUT

m4/ax_append_compile_flags.m4

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# ===========================================================================
2+
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
8+
#
9+
# DESCRIPTION
10+
#
11+
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
12+
# flag. If it does, the flag is added FLAGS-VARIABLE
13+
#
14+
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15+
# CFLAGS) is used. During the check the flag is always added to the
16+
# current language's flags.
17+
#
18+
# If EXTRA-FLAGS is defined, it is added to the current language's default
19+
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
20+
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
21+
# force the compiler to issue an error when a bad flag is given.
22+
#
23+
# NOTE: This macro depends on the AX_APPEND_FLAG and
24+
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
25+
# AX_APPEND_LINK_FLAGS.
26+
#
27+
# LICENSE
28+
#
29+
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
30+
#
31+
# This program is free software: you can redistribute it and/or modify it
32+
# under the terms of the GNU General Public License as published by the
33+
# Free Software Foundation, either version 3 of the License, or (at your
34+
# option) any later version.
35+
#
36+
# This program is distributed in the hope that it will be useful, but
37+
# WITHOUT ANY WARRANTY; without even the implied warranty of
38+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
39+
# Public License for more details.
40+
#
41+
# You should have received a copy of the GNU General Public License along
42+
# with this program. If not, see <http://www.gnu.org/licenses/>.
43+
#
44+
# As a special exception, the respective Autoconf Macro's copyright owner
45+
# gives unlimited permission to copy, distribute and modify the configure
46+
# scripts that are the output of Autoconf when processing the Macro. You
47+
# need not follow the terms of the GNU General Public License when using
48+
# or distributing such scripts, even though portions of the text of the
49+
# Macro appear in them. The GNU General Public License (GPL) does govern
50+
# all other use of the material that constitutes the Autoconf Macro.
51+
#
52+
# This special exception to the GPL applies to versions of the Autoconf
53+
# Macro released by the Autoconf Archive. When you make and distribute a
54+
# modified version of the Autoconf Macro, you may extend this special
55+
# exception to the GPL to apply to your modified version as well.
56+
57+
#serial 3
58+
59+
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
60+
[AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
61+
AC_REQUIRE([AX_APPEND_FLAG])
62+
for flag in $1; do
63+
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
64+
done
65+
])dnl AX_APPEND_COMPILE_FLAGS

0 commit comments

Comments
 (0)