Simplify win32 build process

When building on win32 systems, simply add the win32 specific functions
to the libn2n.a, which simplifies the commands needed.

By moving the win32 source code into the src directory, the source code
is better consolidated.
This commit is contained in:
Hamish Coleman 2023-07-05 20:19:55 +01:00
parent 6957b16537
commit 83078c8104
16 changed files with 10 additions and 40 deletions

View File

@ -139,16 +139,8 @@ LINT_CCODE=\
tools/tests-wire.c \ tools/tests-wire.c \
LDLIBS+=-ln2n LDLIBS+=-ln2n
ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
LDLIBS+=$(abspath win32/n2n_win32.a)
endif
LDLIBS+=$(LDLIBS_EXTRA) LDLIBS+=$(LDLIBS_EXTRA)
ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
N2N_DEPS+=win32/n2n_win32.a
SUBDIRS+=win32
endif
APPS=edge$(EXE) APPS=edge$(EXE)
APPS+=supernode$(EXE) APPS+=supernode$(EXE)
APPS+=example_edge_embed_quick_edge_init$(EXE) APPS+=example_edge_embed_quick_edge_init$(EXE)
@ -189,12 +181,6 @@ version:
tools: $(N2N_LIB) tools: $(N2N_LIB)
$(MAKE) -C $@ $(MAKE) -C $@
win32:
$(MAKE) -C $@
win32/edge_rc.o: win32/edge.rc win32/edge.manifest
$(WINDRES) win32/edge.rc -O coff -o win32/edge_rc.o
src/edge.o: $(N2N_DEPS) src/edge.o: $(N2N_DEPS)
src/supernode.o: $(N2N_DEPS) src/supernode.o: $(N2N_DEPS)
src/example_edge_embed_quick_edge_init.o: $(N2N_DEPS) src/example_edge_embed_quick_edge_init.o: $(N2N_DEPS)
@ -208,7 +194,15 @@ src/example_sn_embed: $(N2N_LIB)
src/example_edge_embed: $(N2N_LIB) src/example_edge_embed: $(N2N_LIB)
ifneq (,$(findstring mingw,$(CONFIG_HOST_OS))) ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
src/edge: win32/edge_rc.o N2N_OBJS+=src/win32/getopt1.o
N2N_OBJS+=src/win32/getopt.o
N2N_OBJS+=src/win32/wintap.o
src/win32/edge.rc: src/win32/edge.manifest
src/win32/edge_rc.o: src/win32/edge.rc
$(WINDRES) $< -O coff -o $@
src/edge: src/win32/edge_rc.o
src/edge.exe: src/edge src/edge.exe: src/edge
src/supernode.exe: src/supernode src/supernode.exe: src/supernode
src/example_edge_embed_quick_edge_init.exe: src/example_edge_embed_quick_edge_init src/example_edge_embed_quick_edge_init.exe: src/example_edge_embed_quick_edge_init
@ -226,8 +220,6 @@ $(N2N_LIB): $(N2N_OBJS)
$(AR) rcs $(N2N_LIB) $(N2N_OBJS) $(AR) rcs $(N2N_LIB) $(N2N_OBJS)
# $(RANLIB) $@ # $(RANLIB) $@
win32/n2n_win32.a: win32
.PHONY: test test.units test.integration .PHONY: test test.units test.integration
test: test.units test.integration test: test.units test.integration

View File

@ -52,7 +52,7 @@ typedef int ssize_t;
typedef unsigned long in_addr_t; typedef unsigned long in_addr_t;
#include "../win32/n2n_win32.h" #include "../src/win32/n2n_win32.h"
// FIXME - continue untangling the build and includes - dont have a ".." here // FIXME - continue untangling the build and includes - dont have a ".." here
#endif /* #if defined(_MSC_VER) || defined(__MINGW32__) */ #endif /* #if defined(_MSC_VER) || defined(__MINGW32__) */

View File

@ -7,9 +7,6 @@ DEBUG?=-g3
HEADERS=$(wildcard include/*.h) HEADERS=$(wildcard include/*.h)
CFLAGS+=-I../include CFLAGS+=-I../include
ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
CFLAGS+=-I../win32
endif
CFLAGS+=$(DEBUG) CFLAGS+=$(DEBUG)
LDFLAGS+=-L.. LDFLAGS+=-L..

View File

@ -1,19 +0,0 @@
#
# This is not a standalone makefile, it must be called from the toplevel
# makefile to inherit the correct environment
CFLAGS+=-I../include -I.
LDFLAGS+=-L..
.PHONY: all clean install
all: n2n_win32.a
n2n_win32.a: getopt1.o getopt.o wintap.o
$(AR) rcs $@ $+
clean:
rm -rf n2n_win32.a *.o *.gcno *.gcda
install:
true