Skip to content

Commit

Permalink
Simplify makefiles by removing special cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishcoleman committed Oct 31, 2023
1 parent 2b57b32 commit 8c08cd5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 52 deletions.
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export AR
export EXE
export CFLAGS
export LDFLAGS
export LDLIBS
export LDLIBS_EXTRA
export CONFIG_HOST_OS

-include config.mak
Expand Down Expand Up @@ -98,8 +98,6 @@ N2N_OBJS=\
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
# is passing the linter tests, this can be refactored)
LINT_CCODE=\
Expand All @@ -112,9 +110,6 @@ LINT_CCODE=\
# TODO: change either the files or the linter to remove these failures
LINT_EXCLUDE=include/uthash.h|include/lzodefs.h|src/minilzo.c

LDLIBS+=-ln3n
LDLIBS+=$(LDLIBS_EXTRA)

DOCS=edge.8.gz supernode.1.gz n3n.7.gz

# This is the list of Debian/Ubuntu packages that are needed during the build.
Expand Down Expand Up @@ -249,12 +244,11 @@ distclean:
rm -f packages/rpm/config.log packages/rpm/config.status

.PHONY: install
install: apps/edge$(EXE) apps/supernode$(EXE) edge.8.gz supernode.1.gz n3n.7.gz
install: apps tools edge.8.gz supernode.1.gz n3n.7.gz
echo "MANDIR=$(MANDIR)"
$(MKDIR) $(SBINDIR) $(MAN1DIR) $(MAN7DIR) $(MAN8DIR)
$(INSTALL_PROG) apps/supernode$(EXE) $(SBINDIR)/
$(INSTALL_PROG) apps/edge$(EXE) $(SBINDIR)/
$(MAKE) -C apps install SBINDIR=$(abspath $(SBINDIR))
$(MAKE) -C tools install SBINDIR=$(abspath $(SBINDIR))
$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/
$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/
$(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/
$(MAKE) -C tools install SBINDIR=$(abspath $(SBINDIR))
11 changes: 9 additions & 2 deletions apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ EXAMPLES+=example_edge_embed_quick_edge_init
EXAMPLES+=example_edge_embed
EXAMPLES+=example_sn_embed

all: $(APPS) $(EXAMPLES)

CFLAGS+=-I$(INCDIR)
LDFLAGS+=-L$(LIBDIR)
LDLIBS+=-ln3n
LDLIBS+=$(LDLIBS_EXTRA)

all: $(APPS) $(EXAMPLES)

.PHONY: install
install: $(addsuffix $(EXE),$APPS)
$(INSTALL_PROG) supernode$(EXE) $(SBINDIR)/
$(INSTALL_PROG) edge$(EXE) $(SBINDIR)/

clean:
rm -f $(APPS) $(EXAMPLES)
58 changes: 18 additions & 40 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,29 @@

DEBUG?=-g3

HEADERS=$(wildcard include/*.h)
CFLAGS+=-I../include

CFLAGS+=$(DEBUG)
LDFLAGS+=-L..

N2N_LIB=../libn3n.a

TOOLS+=n3n-benchmark$(EXE)
TOOLS+=n3n-keygen$(EXE)
TOOLS+=n3n-route$(EXE)
TOOLS+=n3n-portfwd$(EXE)
TOOLS+=n3n-decode$(EXE)

TESTS=tests-compress$(EXE)
TESTS+=tests-elliptic$(EXE)
TESTS+=tests-hashing$(EXE)
TESTS+=tests-transform$(EXE)
TESTS+=tests-wire$(EXE)
TESTS+=tests-auth$(EXE)
CFLAGS+=-I../include
LDFLAGS+=-L..
LDLIBS+=-ln3n
LDLIBS+=$(LDLIBS_EXTRA)

TOOLS+=n3n-benchmark
TOOLS+=n3n-keygen
TOOLS+=n3n-route
TOOLS+=n3n-portfwd
TOOLS+=n3n-decode

TESTS=tests-compress
TESTS+=tests-elliptic
TESTS+=tests-hashing
TESTS+=tests-transform
TESTS+=tests-wire
TESTS+=tests-auth

.PHONY: all clean install
all: $(TOOLS) $(TESTS)

n3n-benchmark.o: $(N2N_LIB) $(HEADERS) ../config.mak
n3n-keygen.o: $(N2N_LIB) $(HEADERS) ../config.mak
n3n-route.o: $(N2N_LIB) $(HEADERS) ../config.mak
n3n-portfwd.o: $(N2N_LIB) $(HEADERS) ../config.mak
n3n-decode.o: $(N2N_LIB) $(HEADERS) ../config.mak

ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
# HACK for windows.
n3n-benchmark.exe: n3n-benchmark
n3n-keygen.exe: n3n-keygen
n3n-route.exe: n3n-route
n3n-portfwd.exe: n3n-portfwd
n3n-decode.exe: n3n-decode
tests-compress.exe: tests-compress
tests-elliptic.exe: tests-elliptic
tests-hashing.exe: tests-hashing
tests-transform.exe: tests-transform
tests-wire.exe: tests-wire
tests-auth.exe: tests-auth
endif

# See comments in the topdir Makefile about how to generate coverage
# data.
gcov:
Expand All @@ -59,4 +37,4 @@ clean:
rm -f $(TESTS) *.gcno *.gcda

install: $(TOOLS)
$(INSTALL_PROG) $(TOOLS) $(SBINDIR)/
$(INSTALL_PROG) $(addsuffix $(EXE),$(TOOLS)) $(SBINDIR)/

0 comments on commit 8c08cd5

Please sign in to comment.