From c81889d02f716eede7602cf24dcd50a24db2f01b Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Sun, 30 Apr 2023 14:37:45 -0500 Subject: [PATCH] Refactoring the autoconf to towards always having a valid Makefile - this will allow simple build instructions --- .gitignore | 2 +- Makefile.in => Makefile | 21 ++++++--------------- autogen.sh | 2 +- config.mak.in | 9 +++++++++ configure.ac | 18 +++++++++--------- 5 files changed, 26 insertions(+), 26 deletions(-) rename Makefile.in => Makefile (97%) create mode 100644 config.mak.in diff --git a/.gitignore b/.gitignore index caf8f6f..cf9a09d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,11 +3,11 @@ *.gz configure config.log +config.mak config.rpath config.status include/config.h include/config.h.in -/Makefile tools/Makefile autom4te.cache edge diff --git a/Makefile.in b/Makefile similarity index 97% rename from Makefile.in rename to Makefile index d1062ab..1bb818f 100644 --- a/Makefile.in +++ b/Makefile @@ -1,24 +1,16 @@ -# NOTE: these are needed by the configure.in inside the packages folder -N2N_VERSION=@N2N_VERSION@ - -######## - export CC export AR -CC=@CC@ -AR=@AR@ +export CFLAGS +export LDFLAGS +export LDLIBS + +include config.mak #Ultrasparc64 users experiencing SIGBUS should try the following gcc options #(thanks to Robert Gibbon) PLATOPTS_SPARC64=-mcpu=ultrasparc -pipe -fomit-frame-pointer -ffast-math -finline-functions -fweb -frename-registers -mapp-regs -export CFLAGS -export LDFLAGS - -CFLAGS=@CFLAGS@ -I./include -LDFLAGS=@LDFLAGS@ -L. - OPENSSL_CFLAGS=$(shell pkg-config openssl; echo $$?) ifeq ($(OPENSSL_CFLAGS), 0) CFLAGS+=$(shell pkg-config --cflags-only-I openssl) @@ -119,10 +111,9 @@ LINT_CCODE=\ tools/tests-transform.c \ tools/tests-wire.c \ -export LDLIBS LDLIBS+=-ln2n -LDLIBS+=@N2N_LIBS@ +LDLIBS+=$(LDLIBS_EXTRA) #For OpenSolaris (Solaris too?) ifeq ($(CONFIG_TARGET), sunos) diff --git a/autogen.sh b/autogen.sh index 0ff6b12..d6aac56 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -rm -f include/config.h include/config.h.in include/config.h.in~ Makefile configure +rm -f include/config.h include/config.h.in include/config.h.in~ config.mak configure echo "Wait please..." autoreconf -if diff --git a/config.mak.in b/config.mak.in new file mode 100644 index 0000000..692a5aa --- /dev/null +++ b/config.mak.in @@ -0,0 +1,9 @@ + +# NOTE: these are needed by the configure.in inside the packages folder +N2N_VERSION=@N2N_VERSION@ + +CC=@CC@ +AR=@AR@ +CFLAGS=@CFLAGS@ -I./include +LDFLAGS=@LDFLAGS@ -L. +LDLIBS_EXTRA+=@N2N_LIBS_EXTRA@ diff --git a/configure.ac b/configure.ac index 105cd32..0b81865 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ if test "${AR+set}" != set; then AR=ar fi -N2N_LIBS= +N2N_LIBS_EXTRA= AC_PROG_CC @@ -35,7 +35,7 @@ AS_IF([test "x$with_zstd" != "xno"], [AC_CHECK_LIB([zstd], [ZSTD_compress], [ AC_DEFINE([HAVE_ZSTD], [1], [Have ZSTD support]) - N2N_LIBS="-lzstd ${N2N_LIBS}" + N2N_LIBS_EXTRA="-lzstd ${N2N_LIBS_EXTRA}" ], [AC_MSG_ERROR([zstd library not found])] )], @@ -49,7 +49,7 @@ AS_IF([test "x$with_openssl" != xno], [AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset], [ AC_DEFINE([HAVE_OPENSSL_1_1], [1], [OpenSSL 1.1 is present]) - N2N_LIBS="-lcrypto ${N2N_LIBS}" + N2N_LIBS_EXTRA="-lcrypto ${N2N_LIBS_EXTRA}" ], [AC_MSG_ERROR([openssl library not found])] )], @@ -62,7 +62,7 @@ AS_IF([test "x$enable_miniupnp" != xno], [AC_CHECK_LIB([miniupnpc], [upnpDiscover], [ AC_DEFINE([HAVE_MINIUPNP], [1], [Have miniupnp library]) - N2N_LIBS="-lminiupnpc ${N2N_LIBS}" + N2N_LIBS_EXTRA="-lminiupnpc ${N2N_LIBS_EXTRA}" ], [AC_MSG_ERROR([miniupnp library not found])] )], @@ -75,7 +75,7 @@ AS_IF([test "x$enable_natpmp" != xno], [AC_CHECK_LIB([natpmp], [initnatpmp], [ AC_DEFINE([HAVE_NATPMP], [1], [Have natpmp library]) - N2N_LIBS="-lnatpmp ${N2N_LIBS}" + N2N_LIBS_EXTRA="-lnatpmp ${N2N_LIBS_EXTRA}" ], [AC_MSG_ERROR([natpmp library not found])] )], @@ -88,7 +88,7 @@ AS_IF([test "x$enable_pcap" != xno], [AC_CHECK_LIB([pcap], [pcap_open_live], [ AC_DEFINE([N2N_HAVE_PCAP], [1], [Have PCAP library]) - N2N_LIBS="-lpcap ${N2N_LIBS}" + N2N_LIBS_EXTRA="-lpcap ${N2N_LIBS_EXTRA}" ADDITIONAL_TOOLS="$ADDITIONAL_TOOLS n2n-decode" # TODO @@ -109,7 +109,7 @@ AS_IF([test "x$enable_cap" != xno], [AC_CHECK_LIB([cap], [cap_get_proc], [ AC_DEFINE([HAVE_LIBCAP],[1],[Support for linux capabilities]) - N2N_LIBS="${N2N_LIBS} -lcap" + N2N_LIBS_EXTRA="${N2N_LIBS_EXTRA} -lcap" ], [AC_MSG_ERROR([cap library not found])] )], @@ -150,10 +150,10 @@ AC_SUBST(AR) AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(N2N_VERSION) -AC_SUBST(N2N_LIBS) +AC_SUBST(N2N_LIBS_EXTRA) AC_SUBST(ADDITIONAL_TOOLS) AC_CONFIG_HEADERS(include/config.h) -AC_CONFIG_FILES(Makefile) +AC_CONFIG_FILES(config.mak) AC_CONFIG_FILES(tools/Makefile) AC_OUTPUT