2019-07-06 14:40:16 +02:00
# NOTE: these are needed by the configure.in inside the packages folder
N2N_VERSION_SHORT = @N2N_VERSION_SHORT@
GIT_COMMITS = @GIT_COMMITS@
########
2018-08-18 09:10:03 +02:00
CC ?= gcc
2016-10-23 10:46:15 +02:00
DEBUG ?= -g3
2020-06-03 18:25:49 +02:00
OPTIMIZATION ?= -O3 -march= native
2019-09-21 16:12:43 +02:00
WARN ?= -Wall
2016-10-23 10:46:15 +02:00
#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
N2N_OBJS_OPT =
2018-10-07 11:37:19 +02:00
LIBS_EDGE_OPT = @N2N_LIBS@
2020-04-24 00:36:32 +02:00
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
2016-10-23 10:46:15 +02:00
2018-10-09 17:28:09 +02:00
OPENSSL_CFLAGS = $( shell pkg-config openssl; echo $$ ?)
i f e q ( $( OPENSSL_CFLAGS ) , 0 )
2020-04-24 00:36:32 +02:00
CFLAGS += $( shell pkg-config --cflags-only-I openssl)
2018-10-09 17:28:09 +02:00
e n d i f
2016-10-23 10:46:15 +02:00
2018-10-07 11:37:19 +02:00
CFLAGS += $( DEBUG) $( OPTIMIZATION) $( WARN) $( OPTIONS) $( PLATOPTS)
2016-10-23 10:46:15 +02:00
INSTALL = install
MKDIR = mkdir -p
2018-09-22 09:08:58 +02:00
OS := $( shell uname -s)
2016-10-23 10:46:15 +02:00
INSTALL_PROG = $( INSTALL) -m755
INSTALL_DOC = $( INSTALL) -m644
# DESTDIR set in debian make system
PREFIX ?= $( DESTDIR) /usr
#BINDIR=$(PREFIX)/bin
2018-09-22 09:08:58 +02:00
i f e q ( $( OS ) , D a r w i n )
SBINDIR = $( PREFIX) /local/sbin
e l s e
2016-10-23 10:46:15 +02:00
SBINDIR = $( PREFIX) /sbin
2018-09-22 09:08:58 +02:00
e n d i f
2016-10-23 10:46:15 +02:00
MANDIR ?= $( PREFIX) /share/man
MAN1DIR = $( MANDIR) /man1
MAN7DIR = $( MANDIR) /man7
MAN8DIR = $( MANDIR) /man8
2018-06-08 11:26:25 +02:00
N2N_LIB = libn2n.a
2020-05-27 23:32:21 +02:00
N2N_OBJS = n2n.o wire.o minilzo.o twofish.o speck.o \
2020-03-16 15:03:03 +01:00
edge_utils.o sn_utils.o \
2020-05-27 23:32:21 +02:00
transform_null.o transform_tf.o transform_aes.o transform_cc20.o transform_speck.o \
2018-06-08 00:17:42 +02:00
tuntap_freebsd.o tuntap_netbsd.o tuntap_linux.o \
2019-04-14 18:08:51 +02:00
tuntap_osx.o
2016-10-23 10:46:15 +02:00
LIBS_EDGE += $( LIBS_EDGE_OPT)
LIBS_SN =
#For OpenSolaris (Solaris too?)
i f e q ( $( shell uname ) , S u n O S )
LIBS_EDGE += -lsocket -lnsl
LIBS_SN += -lsocket -lnsl
e n d i f
APPS = edge
APPS += supernode
2020-03-16 15:03:03 +01:00
APPS += example_edge_embed_quick_edge_init
2018-06-08 08:19:06 +02:00
APPS += example_edge_embed
2020-03-16 15:03:03 +01:00
APPS += example_sn_embed
2016-10-23 10:46:15 +02:00
2018-06-20 20:23:28 +02:00
DOCS = edge.8.gz supernode.1.gz n2n.7.gz
2016-10-23 10:46:15 +02:00
2019-09-21 16:12:43 +02:00
.PHONY : steps build push all clean install tools
all : $( APPS ) $( DOCS ) tools
tools : $( N 2N_LIB )
$( MAKE) -C $@
2016-10-23 10:46:15 +02:00
edge : edge .c $( N 2N_LIB ) n 2n_wire .h n 2n .h Makefile
2020-04-24 00:36:32 +02:00
$( CC) $( CFLAGS) $< $( LDFLAGS) $( N2N_LIB) $( LIBS_EDGE) -o $@
2016-10-23 10:46:15 +02:00
supernode : sn .c $( N 2N_LIB ) n 2n .h Makefile
2020-04-24 00:36:32 +02:00
$( CC) $( CFLAGS) $< $( LDFLAGS) $( N2N_LIB) $( LIBS_SN) -o $@
2019-09-20 02:13:07 +02:00
2020-03-16 15:03:03 +01:00
example_edge_embed_quick_edge_init : example_edge_embed_quick_edge_init .c $( N 2N_LIB ) n 2n .h
2020-04-24 00:36:32 +02:00
$( CC) $( CFLAGS) $< $( LDFLAGS) $( N2N_LIB) $( LIBS_EDGE) -o $@
2020-03-16 15:03:03 +01:00
example_sn_embed : example_sn_embed .c $( N 2N_LIB ) n 2n .h
2020-04-24 00:36:32 +02:00
$( CC) $( CFLAGS) $< $( LDFLAGS) $( N2N_LIB) $( LIBS_EDGE) -o $@
2020-03-16 15:03:03 +01:00
2018-06-08 08:19:06 +02:00
example_edge_embed : example_edge_embed .c $( N 2N_LIB ) n 2n .h
2020-04-24 00:36:32 +02:00
$( CC) $( CFLAGS) $< $( LDFLAGS) $( N2N_LIB) $( LIBS_EDGE) -o $@
2018-06-08 08:19:06 +02:00
2016-10-23 10:46:15 +02:00
%.gz : %
gzip -c $< > $@
$(N2N_LIB) : $( N 2N_OBJS )
ar rcs $( N2N_LIB) $( N2N_OBJS)
# $(RANLIB) $@
clean :
2019-09-20 02:13:07 +02:00
rm -rf $( N2N_OBJS) $( N2N_LIB) $( APPS) $( DOCS) test n2n-decode *.dSYM *~
2019-09-21 16:12:43 +02:00
$( MAKE) -C tools clean
2016-10-23 10:46:15 +02:00
2018-06-20 20:23:28 +02:00
install : edge supernode edge .8.gz supernode .1.gz n 2n .7.gz
2016-10-23 10:46:15 +02:00
echo " MANDIR= $( MANDIR) "
$( MKDIR) $( SBINDIR) $( MAN1DIR) $( MAN7DIR) $( MAN8DIR)
$( INSTALL_PROG) supernode $( SBINDIR) /
$( INSTALL_PROG) edge $( SBINDIR) /
$( INSTALL_DOC) edge.8.gz $( MAN8DIR) /
$( INSTALL_DOC) supernode.1.gz $( MAN1DIR) /
2018-06-20 20:23:28 +02:00
$( INSTALL_DOC) n2n.7.gz $( MAN7DIR) /
2019-09-21 16:12:43 +02:00
$( MAKE) -C tools install
2018-08-17 14:25:35 +02:00
# Docker builder section
DOCKER_IMAGE_NAME = ntop/supernode
2019-07-06 14:40:16 +02:00
DOCKER_IMAGE_VERSION = $N2N_VERSION_SHORT
2019-07-06 12:30:33 +02:00
N2N_COMMIT_HASH = @GIT_REVISION@
2018-08-17 14:25:35 +02:00
default : steps
steps :
if [ " $( TARGET_ARCHITECTURE) " = "arm32v7" ] || [ " $( TARGET_ARCHITECTURE) " = "" ] ; then DOCKER_IMAGE_FILENAME = "Dockerfile.arm32v7" DOCKER_IMAGE_TAGNAME = $( DOCKER_IMAGE_NAME) :$( DOCKER_IMAGE_VERSION) -arm32v7 make build; fi
if [ " $( TARGET_ARCHITECTURE) " = "x86_64" ] || [ " $( TARGET_ARCHITECTURE) " = "" ] ; then DOCKER_IMAGE_FILENAME = "Dockerfile.x86_64" DOCKER_IMAGE_TAGNAME = $( DOCKER_IMAGE_NAME) :$( DOCKER_IMAGE_VERSION) -x86_64 make build; fi
build :
$( eval OS := $( shell uname -s) )
$( eval ARCHITECTURE := $( shell export DOCKER_IMAGE_TAGNAME = " $( DOCKER_IMAGE_TAGNAME) " ; echo $$ DOCKER_IMAGE_TAGNAME | grep -oe -.*) )
docker build --target builder --build-arg COMMIT_HASH = $( N2N_COMMIT_HASH) -t $( DOCKER_IMAGE_TAGNAME) -f image-platforms/$( DOCKER_IMAGE_FILENAME) .
docker container create --name builder $( DOCKER_IMAGE_TAGNAME)
if [ ! -d "./build" ] ; then mkdir ./build; fi
docker container cp builder:/usr/src/n2n/supernode ./build/supernode-$( OS) $( ARCHITECTURE)
docker container cp builder:/usr/src/n2n/edge ./build/edge-$( OS) $( ARCHITECTURE)
docker container rm -f builder
docker build --build-arg COMMIT_HASH = $( N2N_COMMIT_HASH) -t $( DOCKER_IMAGE_TAGNAME) -f image-platforms/$( DOCKER_IMAGE_FILENAME) .
docker tag $( DOCKER_IMAGE_TAGNAME) $( DOCKER_IMAGE_NAME) :latest$( ARCHITECTURE)
push :
if [ ! " $( TARGET_ARCHITECTURE) " = "" ] ; then \
docker push $( DOCKER_IMAGE_NAME) :$( DOCKER_IMAGE_VERSION) -$( TARGET_ARCHITECTURE) ; \
docker push $( DOCKER_IMAGE_NAME) :latest-$( TARGET_ARCHITECTURE) ; \
else \
echo "Please pass TARGET_ARCHITECTURE, see README.md." ; \
fi
2018-08-18 09:10:03 +02:00
# End Docker builder section