From 6600d79325f93ee37cc1642081875e53bfd8416b Mon Sep 17 00:00:00 2001 From: "git@daemon.de" Date: Wed, 7 Jan 2015 12:31:21 +0100 Subject: [PATCH] fixed linking to be clang compatible, made -g and -O? configurable --- bindings/cpp/Makefile.am | 6 ++++- configure.ac | 56 +++++++++++++++++++++++++++++++++++----- libpcp/Makefile.am | 8 +++++- src/Makefile.am | 5 +++- tests/Makefile.am | 13 ++++++++-- 5 files changed, 76 insertions(+), 12 deletions(-) diff --git a/bindings/cpp/Makefile.am b/bindings/cpp/Makefile.am index 09833eb..360abb1 100644 --- a/bindings/cpp/Makefile.am +++ b/bindings/cpp/Makefile.am @@ -18,9 +18,13 @@ # # You can contact me by mail: . # -AM_CXXFLAGS = -I../../include -I../../libpcp/scrypt/crypto -I../../libpcp/scrypt/util -Wall -g +AM_CXXFLAGS = -I../../include -I../../libpcp/scrypt/crypto -I../../libpcp/scrypt/util lib_LTLIBRARIES = libpcp1++.la libpcp1___la_SOURCES = pcp++.h ptx.cpp key.cpp vault.cpp crypto.cpp sign.cpp buffer.cpp include_HEADERS = pcp++.h + +libpcp1___la_CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ diff --git a/configure.ac b/configure.ac index 801f456..9902c1d 100755 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,7 @@ LT_INIT ORIG_CFLAGS="${CFLAGS:-none}" + # Checks for programs AC_PROG_CXX AC_PROG_CXXCPP @@ -45,7 +46,9 @@ AC_PROG_SED AC_PROG_AWK AC_PROG_INSTALL - +# remove flags set by AC_PROG_CC (duplicates and/or invalid for clang) +CFLAGS="" +CXXFLAGS="" # Host speciffic checks @@ -291,9 +294,37 @@ if test "x$bigendian" = "xyes"; then CFLAGS="$CFLAGS -D__CPU_IS_BIG_ENDIAN=1" fi -CFLAGS="$CFLAGS -Werror -Wextra -O2" +# prepare FLAGS +CFLAGS="$CFLAGS -Werror -Wextra -Wall" + +AC_ARG_ENABLE([debug], + AS_HELP_STRING([--disable-debug], [Disable debugging])) + +AS_IF([test "x$enable_debug" != "xno"], [ + CFLAGS="$CFLAGS -g" + enable_debug="yes" +]) + +AC_ARG_ENABLE([optimize], + AS_HELP_STRING([--disable-optimize], [Disable optimization])) + +AS_IF([test "x$enable_optimize" != "xno"], [ + case $enable_optimize in + -O*) + CFLAGS="$CFLAGS $enable_optimize" + enable_optimize="$enable_optimize" + ;; + *) + CFLAGS="$CFLAGS -O2" + enable_optimize="-O2" + ;; + esac +]) + + CXXFLAGS="$CFLAGS" + # conditionals for bindings and stuff # c++ @@ -302,12 +333,17 @@ AC_ARG_ENABLE([cpp-binding], [Disable C++ binding])], ) +AS_IF([test "x$enable_cpp_binding" != "xno"], [ + enable_cpp_binding=yes + ]) + AM_CONDITIONAL([BUILDCPP], [test "x$enable_cpp_binding" != "xno"]) # py AC_ARG_ENABLE([python-binding], [AS_HELP_STRING([--enable-python-binding], - [Enable python binding])], + [Enable python binding]) + ], [python="yes"], []) @@ -336,20 +372,26 @@ AC_CONFIG_FILES([Makefile include/Makefile libpcp/Makefile src/Makefile man/Make AC_OUTPUT AC_MSG_RESULT([ - $PACKAGE $VERSION + Build configured for $PACKAGE $VERSION: CC: ${CC} CFLAGS: ${CFLAGS} CXX: ${CXX} CXXFLAGS: ${CXXFLAGS} LDFLAGS: ${LDFLAGS} LIBS: ${LIBS} - + debug: ${enable_debug} + optimize: ${enable_optimize} + prefix: ${prefix} - sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} - bigendian: ${bigendian} + target platform: ${host} + big endian cpu: ${bigendian} build python binding: ${python} + build c++ binding: ${enable_cpp_binding} + + Type 'make' to build, 'make install' to install. + To execute unit tests, type 'make test'. ]) diff --git a/libpcp/Makefile.am b/libpcp/Makefile.am index cb406fe..c5227c7 100644 --- a/libpcp/Makefile.am +++ b/libpcp/Makefile.am @@ -18,7 +18,9 @@ # # You can contact me by mail: . # -AM_CFLAGS = -I../include/pcp -Iscrypt/crypto -Iscrypt/util -Wall -g +AM_CFLAGS = -I../include/pcp -Iscrypt/crypto -Iscrypt/util + + lib_LTLIBRARIES = libpcp1.la @@ -33,3 +35,7 @@ libpcp1_la_SOURCES = platform.c mac.c mem.c pad.c version.c \ base85.c util.c buffer.c mgmt.c keysig.c pcpstream.c include_HEADERS = ../include/pcp.h + +libpcp1_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ diff --git a/src/Makefile.am b/src/Makefile.am index 17fd770..3d162af 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,7 @@ # -AM_CFLAGS = -I../include/pcp -I../libpcp/scrypt/crypto -Wall -g +AM_CFLAGS = -I../include/pcp -I../libpcp/scrypt/crypto bin_PROGRAMS = pcp1 @@ -29,3 +29,6 @@ pcp1_SOURCES = pcp.c keymgmt.c keyprint.c readpass.c \ encryption.c z85util.c signature.c \ compat_getopt.c +pcp1_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ diff --git a/tests/Makefile.am b/tests/Makefile.am index 891cf35..e402ee5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,10 +19,19 @@ # You can contact me by mail: . # -AM_CFLAGS = -I../include/pcp -I../src -I../libpcp/scrypt/crypto -Wall -g +AM_CFLAGS = -I../include/pcp -I../src -I../libpcp/scrypt/crypto check_PROGRAMS = col invalidkeys gencheader statictest cpptest \ buffertest sample streamtest pipetest decodertest mangle + +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ + +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ + gencheader_LDADD = ../libpcp/.libs/libpcp1.a gencheader_SOURCES = gencheader.c @@ -54,7 +63,7 @@ invalidkeys_LDADD = ../libpcp/.libs/libpcp1.a \ ../src/keyprint.o ../src/keymgmt.o ../src/readpass.o invalidkeys_SOURCES = invalidkeys.c -AM_CXXFLAGS = -I../include -I../bindings/cpp -I../libpcp/scrypt/crypto -Wall -g +AM_CXXFLAGS = -I../include -I../bindings/cpp -I../libpcp/scrypt/crypto cpptest_LDADD = ../bindings/cpp/.libs/libpcp1++.a ../libpcp/.libs/libpcp1.a cpptest_SOURCES = cpptest.cpp