Browse Source

Merge pull request #1094 from hamishcoleman/autoconf

Autoconf Refactoring
pull/1098/head
Hamish Coleman 2 years ago
committed by GitHub
parent
commit
40c99fcdee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .github/workflows/tests.yml
  2. 4
      .gitignore
  3. 60
      Makefile
  4. 2
      autogen.sh
  5. 15
      config.mak.in
  6. 23
      configure.ac
  7. 1
      include/n2n_typedefs.h
  8. 20
      scripts/hack_fakeautoconf.sh
  9. 21
      tools/Makefile
  10. 5
      win32/CMakeLists.txt
  11. 6
      win32/Makefile

6
.github/workflows/tests.yml

@ -106,7 +106,6 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
os: os:
- ubuntu-22.04
- ubuntu-20.04 - ubuntu-20.04
- ubuntu-22.04 - ubuntu-22.04
@ -178,7 +177,6 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
os: os:
- macos-12
- macos-11 - macos-11
- macos-12 - macos-12
@ -282,6 +280,10 @@ jobs:
./scripts/hack_fakeautoconf.sh ./scripts/hack_fakeautoconf.sh
shell: bash shell: bash
- name: Build the project
run: make
shell: bash
- name: Run embedded unit tests - name: Run embedded unit tests
run: make test.units run: make test.units
shell: bash shell: bash

4
.gitignore

@ -3,12 +3,12 @@
*.gz *.gz
configure configure
config.log config.log
config.mak
config.rpath config.rpath
config.status config.status
include/config.h include/config.h
include/config.h.in include/config.h.in
/Makefile tools/config.mak
tools/Makefile
autom4te.cache autom4te.cache
edge edge
example_edge_embed_quick_edge_init example_edge_embed_quick_edge_init

60
Makefile.in → Makefile

@ -1,24 +1,10 @@
# NOTE: these are needed by the configure.in inside the packages folder include config.mak
N2N_VERSION=@N2N_VERSION@
########
export CC
export AR
CC=@CC@
AR=@AR@
#Ultrasparc64 users experiencing SIGBUS should try the following gcc options #Ultrasparc64 users experiencing SIGBUS should try the following gcc options
#(thanks to Robert Gibbon) #(thanks to Robert Gibbon)
PLATOPTS_SPARC64=-mcpu=ultrasparc -pipe -fomit-frame-pointer -ffast-math -finline-functions -fweb -frename-registers -mapp-regs 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 $$?) OPENSSL_CFLAGS=$(shell pkg-config openssl; echo $$?)
ifeq ($(OPENSSL_CFLAGS), 0) ifeq ($(OPENSSL_CFLAGS), 0)
CFLAGS+=$(shell pkg-config --cflags-only-I openssl) CFLAGS+=$(shell pkg-config --cflags-only-I openssl)
@ -78,8 +64,44 @@ MAN7DIR=$(MANDIR)/man7
MAN8DIR=$(MANDIR)/man8 MAN8DIR=$(MANDIR)/man8
N2N_LIB=libn2n.a N2N_LIB=libn2n.a
N2N_OBJS=$(patsubst src/%.c, src/%.o, $(wildcard src/*.c)) N2N_OBJS=\
N2N_DEPS=$(wildcard include/*.h) $(wildcard src/*.c) Makefile src/aes.o \
src/auth.o \
src/cc20.o \
src/curve25519.o \
src/edge_management.o \
src/edge_utils.o \
src/edge_utils_win32.o \
src/header_encryption.o \
src/hexdump.o \
src/json.o \
src/management.o \
src/minilzo.o \
src/n2n.o \
src/n2n_port_mapping.o \
src/n2n_regex.o \
src/network_traffic_filter.o \
src/pearson.o \
src/random_numbers.o \
src/sn_management.o \
src/sn_selection.o \
src/sn_utils.o \
src/speck.o \
src/tf.o \
src/transform_aes.o \
src/transform_cc20.o \
src/transform_lzo.o \
src/transform_null.o \
src/transform_speck.o \
src/transform_tf.o \
src/transform_zstd.o \
src/tuntap_freebsd.o \
src/tuntap_linux.o \
src/tuntap_netbsd.o \
src/tuntap_osx.o \
src/wire.o \
N2N_DEPS=$(wildcard include/*.h) $(wildcard src/*.c) config.mak
# As source files pass the linter, they can be added here (If all the source # As source files pass the linter, they can be added here (If all the source
# is passing the linter tests, this can be refactored) # is passing the linter tests, this can be refactored)
@ -119,10 +141,9 @@ LINT_CCODE=\
tools/tests-transform.c \ tools/tests-transform.c \
tools/tests-wire.c \ tools/tests-wire.c \
export LDLIBS
LDLIBS+=-ln2n LDLIBS+=-ln2n
LDLIBS+=@N2N_LIBS@ LDLIBS+=$(LDLIBS_EXTRA)
#For OpenSolaris (Solaris too?) #For OpenSolaris (Solaris too?)
ifeq ($(CONFIG_TARGET), sunos) ifeq ($(CONFIG_TARGET), sunos)
@ -259,6 +280,7 @@ endif
.PHONY: clean .PHONY: clean
clean: clean:
rm -f src/edge.o src/supernode.o src/example_edge_embed.o src/example_edge_embed_quick_edge_init.o src/example_sn_embed.o
rm -rf $(N2N_OBJS) $(N2N_LIB) $(APPS) $(DOCS) $(COVERAGEDIR)/ *.dSYM *~ rm -rf $(N2N_OBJS) $(N2N_LIB) $(APPS) $(DOCS) $(COVERAGEDIR)/ *.dSYM *~
rm -f tests/*.out src/*.gcno src/*.gcda rm -f tests/*.out src/*.gcno src/*.gcda
for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean; done for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean; done

2
autogen.sh

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/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..." echo "Wait please..."
autoreconf -if autoreconf -if

15
config.mak.in

@ -0,0 +1,15 @@
export N2N_VERSION
export CC
export AR
export CFLAGS
export LDFLAGS
export LDLIBS_EXTRA
export TOOLS_ADDITIONAL
N2N_VERSION=@N2N_VERSION@
CC=@CC@
AR=@AR@
CFLAGS=@CFLAGS@ -I./include
LDFLAGS=@LDFLAGS@ -L.
LDLIBS_EXTRA=@N2N_LIBS_EXTRA@
TOOLS_ADDITIONAL=@TOOLS_ADDITIONAL@

23
configure.ac

@ -11,7 +11,7 @@ if test "${AR+set}" != set; then
AR=ar AR=ar
fi fi
N2N_LIBS= N2N_LIBS_EXTRA=
AC_PROG_CC AC_PROG_CC
@ -35,7 +35,7 @@ AS_IF([test "x$with_zstd" != "xno"],
[AC_CHECK_LIB([zstd], [ZSTD_compress], [AC_CHECK_LIB([zstd], [ZSTD_compress],
[ [
AC_DEFINE([HAVE_ZSTD], [1], [Have ZSTD support]) 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])] [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_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset],
[ [
AC_DEFINE([HAVE_OPENSSL_1_1], [1], [OpenSSL 1.1 is present]) 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])] [AC_MSG_ERROR([openssl library not found])]
)], )],
@ -62,7 +62,7 @@ AS_IF([test "x$enable_miniupnp" != xno],
[AC_CHECK_LIB([miniupnpc], [upnpDiscover], [AC_CHECK_LIB([miniupnpc], [upnpDiscover],
[ [
AC_DEFINE([HAVE_MINIUPNP], [1], [Have miniupnp library]) 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])] [AC_MSG_ERROR([miniupnp library not found])]
)], )],
@ -75,7 +75,7 @@ AS_IF([test "x$enable_natpmp" != xno],
[AC_CHECK_LIB([natpmp], [initnatpmp], [AC_CHECK_LIB([natpmp], [initnatpmp],
[ [
AC_DEFINE([HAVE_NATPMP], [1], [Have natpmp library]) 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])] [AC_MSG_ERROR([natpmp library not found])]
)], )],
@ -88,8 +88,8 @@ AS_IF([test "x$enable_pcap" != xno],
[AC_CHECK_LIB([pcap], [pcap_open_live], [AC_CHECK_LIB([pcap], [pcap_open_live],
[ [
AC_DEFINE([N2N_HAVE_PCAP], [1], [Have PCAP library]) 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" TOOLS_ADDITIONAL="$TOOLS_ADDITIONAL n2n-decode"
# TODO # TODO
# - pcap_set_immediate_mode has been available since libpcap 1.5 # - pcap_set_immediate_mode has been available since libpcap 1.5
@ -109,7 +109,7 @@ AS_IF([test "x$enable_cap" != xno],
[AC_CHECK_LIB([cap], [cap_get_proc], [AC_CHECK_LIB([cap], [cap_get_proc],
[ [
AC_DEFINE([HAVE_LIBCAP],[1],[Support for linux capabilities]) 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])] [AC_MSG_ERROR([cap library not found])]
)], )],
@ -150,10 +150,9 @@ AC_SUBST(AR)
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGS)
AC_SUBST(N2N_VERSION) AC_SUBST(N2N_VERSION)
AC_SUBST(N2N_LIBS) AC_SUBST(N2N_LIBS_EXTRA)
AC_SUBST(ADDITIONAL_TOOLS) AC_SUBST(TOOLS_ADDITIONAL)
AC_CONFIG_HEADERS(include/config.h) AC_CONFIG_HEADERS(include/config.h)
AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(config.mak)
AC_CONFIG_FILES(tools/Makefile)
AC_OUTPUT AC_OUTPUT

1
include/n2n_typedefs.h

@ -51,6 +51,7 @@ typedef int ssize_t;
typedef unsigned long in_addr_t; typedef unsigned long in_addr_t;
#include "n2n_win32.h" #include "n2n_win32.h"
// FIXME - the above include is from a different subdir
#endif /* #if defined(_MSC_VER) || defined(__MINGW32__) */ #endif /* #if defined(_MSC_VER) || defined(__MINGW32__) */

20
scripts/hack_fakeautoconf.sh

@ -3,17 +3,17 @@
# Specifically for windows, where installing autoconf looks suspiciously # Specifically for windows, where installing autoconf looks suspiciously
# like boiling the ocean. # like boiling the ocean.
sed \ cat >config.mak <<EOF
-e "s%@CC@%gcc%g" \ CC=gcc
-e "s%@AR@%ar%g" \ AR=ar
-e "s%@CFLAGS@%$CFLAGS%g" \ CFLAGS=$CFLAGS -g -O2 -I./include
-e "s%@LDFLAGS@%$LDFLAGS%g" \ LDFLAGS=$LDFLAGS -L.
-e "s%@N2N_LIBS@%$LDLIBS%g" \ N2N_LIBS_EXTRA=$LDLIBS
< Makefile.in > Makefile EOF
sed \ cat >tools/config.mak <<EOF
-e "s%@ADDITIONAL_TOOLS@%%g" \ TOOLS_ADDITIONAL=
< tools/Makefile.in > tools/Makefile EOF
cat <<EOF >include/config.h cat <<EOF >include/config.h
#define PACKAGE_VERSION "FIXME" #define PACKAGE_VERSION "FIXME"

21
tools/Makefile.in → tools/Makefile

@ -2,13 +2,20 @@
# This is not a standalone makefile, it must be called from the toplevel # This is not a standalone makefile, it must be called from the toplevel
# makefile to inherit the correct environment # makefile to inherit the correct environment
# The vars included here should be part of the environment.
# TODO - refactor this and debug why they need to be included for windows
include ../config.mak
DEBUG?=-g3 DEBUG?=-g3
HEADERS=$(wildcard include/*.h) HEADERS=$(wildcard include/*.h)
CFLAGS+=-I../include CFLAGS+=-I../include
LDLIBS+=-ln2n
ifeq ($(CONFIG_TARGET),mingw) ifeq ($(CONFIG_TARGET),mingw)
CFLAGS+=-I../win32 CFLAGS+=-I../win32
LDLIBS+=-lnetapi32 LDLIBS+=$(abspath ../win32/n2n_win32.a)
LDLIBS+=-lnetapi32 -lws2_32 -liphlpapi
endif endif
CFLAGS+=$(DEBUG) CFLAGS+=$(DEBUG)
LDFLAGS+=-L.. LDFLAGS+=-L..
@ -16,7 +23,7 @@ LDFLAGS+=-L..
N2N_LIB=../libn2n.a N2N_LIB=../libn2n.a
TOOLS=n2n-benchmark n2n-keygen n2n-route n2n-portfwd TOOLS=n2n-benchmark n2n-keygen n2n-route n2n-portfwd
TOOLS+=@ADDITIONAL_TOOLS@ TOOLS+=$(TOOLS_ADDITIONAL)
TESTS=tests-compress tests-elliptic tests-hashing tests-transform TESTS=tests-compress tests-elliptic tests-hashing tests-transform
TESTS+=tests-wire TESTS+=tests-wire
@ -25,12 +32,12 @@ TESTS+=tests-auth
.PHONY: all clean install .PHONY: all clean install
all: $(TOOLS) $(TESTS) all: $(TOOLS) $(TESTS)
n2n-benchmark.o: $(N2N_LIB) $(HEADERS) ../Makefile Makefile n2n-benchmark.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-keygen.o: $(N2N_LIB) $(HEADERS) ../Makefile Makefile n2n-keygen.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-route.o: $(N2N_LIB) $(HEADERS) ../Makefile Makefile n2n-route.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-portfwd.o: $(N2N_LIB) $(HEADERS) ../Makefile Makefile n2n-portfwd.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-decode: n2n-decode.c $(N2N_LIB) $(HEADERS) ../Makefile Makefile n2n-decode: n2n-decode.c $(N2N_LIB) $(HEADERS) ../config.mak
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDLIBS) -lpcap -o $@ $(CC) $(CFLAGS) $< $(LDFLAGS) $(LDLIBS) -lpcap -o $@
# See comments in the topdir Makefile about how to generate coverage # See comments in the topdir Makefile about how to generate coverage

5
win32/CMakeLists.txt

@ -1,5 +0,0 @@
add_library(n2n_win32
getopt1.c
getopt.c
wintap.c)
target_link_libraries(n2n_win32 PUBLIC ws2_32.lib)

6
win32/Makefile

@ -2,7 +2,11 @@
# This is not a standalone makefile, it must be called from the toplevel # This is not a standalone makefile, it must be called from the toplevel
# makefile to inherit the correct environment # makefile to inherit the correct environment
CFLAGS+=-I../include # The vars included here should be part of the environment.
# TODO - refactor this and debug why they need to be included for windows
include ../config.mak
CFLAGS+=-I../include -I.
LDFLAGS+=-L.. LDFLAGS+=-L..
.PHONY: all clean install .PHONY: all clean install

Loading…
Cancel
Save