Skip to content

Commit

Permalink
Refactoring the autoconf to towards always having a valid Makefile - …
Browse files Browse the repository at this point in the history
…this will allow simple build instructions
  • Loading branch information
hamishcoleman committed Apr 30, 2023
1 parent 39b9c6b commit c81889d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -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
Expand Down
21 changes: 6 additions & 15 deletions Makefile.in → 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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion 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
9 changes: 9 additions & 0 deletions 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@
18 changes: 9 additions & 9 deletions configure.ac
Expand Up @@ -11,7 +11,7 @@ if test "${AR+set}" != set; then
AR=ar
fi

N2N_LIBS=
N2N_LIBS_EXTRA=

AC_PROG_CC

Expand All @@ -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])]
)],
Expand All @@ -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])]
)],
Expand All @@ -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])]
)],
Expand All @@ -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])]
)],
Expand All @@ -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
Expand All @@ -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])]
)],
Expand Down Expand Up @@ -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

0 comments on commit c81889d

Please sign in to comment.