Skip to content

Commit

Permalink
Merge pull request #2 from hamishcoleman/main
Browse files Browse the repository at this point in the history
All included programs linking against the built library are now in the same apps dir
  • Loading branch information
hamishcoleman authored Oct 25, 2023
2 parents 5683a49 + 96220b7 commit 16c8511
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 52 deletions.
34 changes: 10 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ 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=\
examples/example_edge_embed_quick_edge_init.c \
apps/example_edge_embed_quick_edge_init.c \
include/curve25519.h \
include/header_encryption.h \
include/hexdump.h \
Expand Down Expand Up @@ -140,9 +140,6 @@ LINT_CCODE=\
LDLIBS+=-ln3n
LDLIBS+=$(LDLIBS_EXTRA)

APPS=edge$(EXE)
APPS+=supernode$(EXE)

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 All @@ -159,14 +156,14 @@ BUILD_DEP:=\
yamllint \

SUBDIRS+=tools
SUBDIRS+=examples
SUBDIRS+=apps

COVERAGEDIR?=coverage

.PHONY: $(SUBDIRS)

.PHONY: all
all: version $(APPS) $(DOCS) $(SUBDIRS)
all: version apps $(DOCS) $(SUBDIRS)

# This allows breaking the build if the version.sh script discovers
# any inconsistancies
Expand All @@ -175,15 +172,9 @@ version:
@echo -n "Build for version: "
@scripts/version.sh

examples tools: $(N2N_LIB)
apps tools: $(N2N_LIB)
$(MAKE) -C $@

src/edge.o: $(N2N_DEPS)
src/supernode.o: $(N2N_DEPS)

src/edge: $(N2N_LIB)
src/supernode: $(N2N_LIB)

ifneq (,$(findstring mingw,$(CONFIG_HOST_OS)))
N2N_OBJS+=src/win32/edge_utils_win32.o
N2N_OBJS+=src/win32/getopt1.o
Expand All @@ -196,9 +187,6 @@ src/win32/edge.rc: src/win32/edge.manifest
src/win32/edge_rc.o: src/win32/edge.rc
$(WINDRES) $< -O coff -o $@

src/edge.exe: src/edge
src/supernode.exe: src/supernode

%: src/%
cp $< $@

Expand All @@ -215,7 +203,7 @@ test: test.units test.integration
test.units: tools
scripts/test_harness.sh tests/tests_units.list

test.integration: $(APPS)
test.integration: apps
scripts/test_harness.sh tests/tests_integration.list

.PHONY: lint lint.python lint.ccode lint.shell lint.yaml
Expand Down Expand Up @@ -270,8 +258,7 @@ build-dep-brew:

.PHONY: clean
clean:
rm -f src/edge.o src/supernode.o
rm -rf $(N2N_OBJS) $(N2N_LIB) $(APPS) $(DOCS) $(COVERAGEDIR)/ *.dSYM *~
rm -rf $(N2N_OBJS) $(N2N_LIB) $(DOCS) $(COVERAGEDIR)/ *.dSYM *~
rm -f tests/*.out src/*.gcno src/*.gcda
for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean; done

Expand All @@ -281,18 +268,17 @@ distclean:
rm -rf autom4te.cache/
rm -f config.mak config.log config.status configure include/config.h include/config.h.in
rm -f edge.8.gz n3n.7.gz supernode.1.gz
rm -f edge supernode libn3n.a
rm -f libn3n.a
rm -f packages/debian/config.log packages/debian/config.status
rm -rf packages/debian/autom4te.cache/
rm -f packages/rpm/config.log packages/rpm/config.status
rm -f $(addprefix src/,$(APPS))

.PHONY: install
install: edge$(EXE) supernode$(EXE) edge.8.gz supernode.1.gz n3n.7.gz
install: apps/edge$(EXE) apps/supernode$(EXE) edge.8.gz supernode.1.gz n3n.7.gz
echo "MANDIR=$(MANDIR)"
$(MKDIR) $(SBINDIR) $(MAN1DIR) $(MAN7DIR) $(MAN8DIR)
$(INSTALL_PROG) supernode$(EXE) $(SBINDIR)/
$(INSTALL_PROG) edge$(EXE) $(SBINDIR)/
$(INSTALL_PROG) apps/supernode$(EXE) $(SBINDIR)/
$(INSTALL_PROG) apps/edge$(EXE) $(SBINDIR)/
$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/
$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/
$(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/
Expand Down
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ make install

For Windows, MacOS, optimizations and general building options, please check out [Building documentation](doc/Building.md) for compilation and running.

**IMPORTANT** It is generally recommended to use the [latest stable release](https://github.com/ntop/n2n/releases). Please note that the current _dev_ branch usually is not guaranteed to be backward compatible neither with the latest stable release nor with previous _dev_ states. On the other hand, if you dare to try bleeding edge features, you are encouraged to compile from _dev_ – just keep track of sometimes rapidly occuring changes. Feedback in the _Issues_ section is appreciated.
**IMPORTANT** It is generally recommended to use the [latest stable release](https://github.com/n42n/n3n/releases). Please note that the current _main_ branch usually is not guaranteed to be backward compatible neither with the latest stable release nor with previous _main_ states. On the other hand, if you dare to try bleeding edge features, you are encouraged to compile from _main_ – just keep track of sometimes rapidly occuring changes. Feedback in the _Issues_ section is appreciated.


## Security Considerations
Expand Down Expand Up @@ -101,26 +101,19 @@ a service is available in the [more detailed documentation](doc/Advanced.md).

You can contribute to n2n in various ways:

- Update an [open issue](https://github.com/ntop/n2n/issues) or create a new one with detailed information
- Update an [open issue](https://github.com/n42n/n3n/issues) or create a new one with detailed information
- Propose new features
- Improve the documentation
- Provide pull requests with enhancements

For details about the internals of n2n check out the [Hacking guide](https://github.com/ntop/n2n/blob/dev/doc/Hacking.md).
For details about the internals of n2n check out the [Hacking guide](doc/Hacking.md).


## Further Readings and Related Projects

Answers to frequently asked questions can be found in our [FAQ document](https://github.com/ntop/n2n/blob/dev/doc/Faq.md).

Here is a list of third-party projects connected to this repository:

- Collection of pre-built binaries for Windows: [lucktu](https://github.com/lucktu/n2n)
- n2n for Android: [hin2n](https://github.com/switch-iot/hin2n)
- Docker images: [Docker Hub](https://hub.docker.com/r/supermock/supernode/)
- Go bindings, management daemons and CLIs for n2n edges and supernodes, Docker, Kubernetes & Helm Charts: [pojntfx/gon2n](https://pojntfx.github.io/gon2n/)
- Windows GUI (along with a custom version of n2n) but also working with regular n2n: [HappyNet](https://github.com/happynclient/happynwindows)
Answers to frequently asked questions can be found in our [FAQ document](doc/Faq.md).

---

(C) 2007-22 - ntop.org and contributors
Copyright (C) 2023 Hamish Coleman
11 changes: 6 additions & 5 deletions examples/Makefile → apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
# service within other software.
#

APPS+=edge
APPS+=supernode

EXAMPLES+=example_edge_embed_quick_edge_init
EXAMPLES+=example_edge_embed
EXAMPLES+=example_sn_embed

all: $(EXAMPLES)
all: $(APPS) $(EXAMPLES)

CFLAGS+=-I../include
LDFLAGS+=-L../

example_edge_embed_quick_edge_init: ../libn3n.a
example_sn_embed: ../libn3n.a
example_edge_embed: ../libn3n.a
$(APPS) $(EXAMPLES): ../libn3n.a

clean:
rm -f $(EXAMPLES)
rm -f $(APPS) $(EXAMPLES)
2 changes: 1 addition & 1 deletion src/edge.c → apps/edge.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ADD, HASH_C...

#ifdef _WIN32
#include "win32/defs.h"
#include "../src/win32/defs.h" // FIXME: untangle the include path
#else
#include <arpa/inet.h> // for inet_addr, inet_ntop
#include <netinet/in.h> // for INADDR_ANY, INADDR_NONE, ntohl
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/supernode.c → apps/supernode.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_ADD_STR

#ifdef _WIN32
#include "win32/defs.h"
#include "../src/win32/defs.h" // FIXME: untangle the include path
#else
#include <arpa/inet.h> // for inet_addr
#include <netinet/in.h> // for ntohl, INADDR_ANY, INADDR_NONE, in_addr_t
Expand Down
4 changes: 2 additions & 2 deletions packages/debian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pkg:
if test -e "${N2N_BUILD}"; then /bin/rm -fr ${N2N_BUILD}; fi
mkdir -p ${N2N_BUILD}/usr/sbin ${N2N_BUILD}/usr/share/man/man1 ${N2N_BUILD}/usr/share/man/man7 ${N2N_BUILD}/usr/share/man/man8
mkdir -p ${N2N_BUILD}/usr/share/doc/n3n/examples
install -m755 ../../supernode ${N2N_BUILD}/usr/sbin/
install -m755 ../../edge ${N2N_BUILD}/usr/sbin/
install -m755 ../../apps/supernode ${N2N_BUILD}/usr/sbin/
install -m755 ../../apps/edge ${N2N_BUILD}/usr/sbin/
install -m644 ../../edge.8.gz ${N2N_BUILD}/usr/share/man/man8/
install -m644 ../../supernode.1.gz ${N2N_BUILD}/usr/share/man/man1/
install -m644 ../../n3n.7.gz ${N2N_BUILD}/usr/share/man/man7/
Expand Down
4 changes: 2 additions & 2 deletions packages/openwrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endef

define Package/n3n-edge/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/edge $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/edge $(1)/etc/init.d/edge
$(INSTALL_DIR) $(1)/etc/n3n
Expand All @@ -89,7 +89,7 @@ endef

define Package/n3n-supernode/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/supernode $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/supernode $(1)/etc/init.d/supernode
$(INSTALL_DIR) $(1)/etc/n3n
Expand Down
4 changes: 2 additions & 2 deletions packages/rpm/n3n.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/
# TODO: move to %install
cd ../../n3n # FIXME: dont hardcode sourcecode dir name

cp edge $RPM_BUILD_ROOT/usr/sbin
cp supernode $RPM_BUILD_ROOT/usr/sbin
cp apps/edge $RPM_BUILD_ROOT/usr/sbin
cp apps/supernode $RPM_BUILD_ROOT/usr/sbin
cp n3n.7.gz $RPM_BUILD_ROOT/usr/share/man/man7
cp supernode.1.gz $RPM_BUILD_ROOT/usr/share/man/man1
cp edge.8.gz $RPM_BUILD_ROOT/usr/share/man/man8
Expand Down
4 changes: 2 additions & 2 deletions scripts/test_integration_edge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ docmd() {
}

# start a supernode
docmd "${BINDIR}"/supernode -v
docmd "${BINDIR}"/apps/supernode -v

# Start the edge in the background
docmd sudo "${BINDIR}"/edge -l localhost:7654 -c test >/dev/null
docmd sudo "${BINDIR}"/apps/edge -l localhost:7654 -c test >/dev/null
# TODO:
# - send edge messages to stderr?

Expand Down
2 changes: 1 addition & 1 deletion scripts/test_integration_supernode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ docmd() {
}

# start it running in the background
docmd "${BINDIR}"/supernode -v
docmd "${BINDIR}"/apps/supernode -v

# TODO: probe the api endpoint, waiting for the supernode to be available?
sleep 0.1
Expand Down

0 comments on commit 16c8511

Please sign in to comment.