diff --git a/Makefile b/Makefile index 21669032..d786b9a9 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,19 @@ # Our default make target all: -export CC export AR -export EXE +export CC export CFLAGS +export CONFIG_HOST_OS +export EXE +export INSTALL +export INSTALL_DOC +export INSTALL_PROG export LDFLAGS -export LDLIBS_LOCAL export LDLIBS_EXTRA -export CONFIG_HOST_OS +export LDLIBS_LOCAL +export MKDIR + VERSION:=$(shell scripts/version.sh) CFLAGS+=-DVERSION='"$(VERSION)"' @@ -49,33 +54,29 @@ ifndef UNAME_S $(error Could not run uname command, cannot continue) endif -export MKDIR -export INSTALL -export INSTALL_PROG -export INSTALL_DOC -export SBINDIR - MKDIR=mkdir -p INSTALL=install INSTALL_PROG=$(INSTALL) -m555 INSTALL_DOC=$(INSTALL) -m444 # DESTDIR set in debian make system -PREFIX?=$(DESTDIR)/$(CONFIG_PREFIX) - -# TODO: both these dirs are outside of the CONFIG_PREFIX, which means that -# they would not be in /usr/local if that is the expected install destination +PREFIX=$(DESTDIR)/$(CONFIG_PREFIX) + +# Note that both these install dirs are outside of the CONFIG_PREFIX. +# The ETCDIR is not configurable in the code, so no changes should be done +# without code changes. +# The systemd unit dir should default to /lib for most Debian packages (if +# CONFIG_PREFIX is /usr) otherwise it should be based on the prefix. +# The current autotools has hacks to apply this logic. ETCDIR=$(DESTDIR)/etc/n3n -SYSTEMDDIR=$(DESTDIR)/lib/systemd/system - -BINDIR=$(PREFIX)/bin -SBINDIR=$(PREFIX)/sbin -MANDIR?=$(PREFIX)/share/man -MAN1DIR=$(MANDIR)/man1 -MAN7DIR=$(MANDIR)/man7 -MAN8DIR=$(MANDIR)/man8 -DOCDIR=$(PREFIX)/share/doc/n3n +CONFIG_SYSTEMDDIR?=$(DESTDIR)/lib/systemd/system +CONFIG_BINDIR?=$(PREFIX)/bin +CONFIG_SBINDIR?=$(PREFIX)/sbin +CONFIG_MANDIR?=$(PREFIX)/share/man +MAN7DIR=$(CONFIG_MANDIR)/man7 +MAN8DIR=$(CONFIG_MANDIR)/man8 +CONFIG_DOCDIR?=$(PREFIX)/share/doc/n3n ####################################### # All the additiona needed for using the n3n library @@ -209,7 +210,7 @@ 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 -DOCS=edge.8.gz supernode.1.gz n3n.7.gz +DOCS=edge.8.gz supernode.8.gz n3n.7.gz # This is the list of Debian/Ubuntu packages that are needed during the build. # Mostly of use in automated build systems. @@ -345,7 +346,7 @@ distclean: rm -f tests/*.out src/*.indent src/*.unc-backup* 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.8.gz n3n.7.gz supernode.8.gz 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 @@ -359,26 +360,26 @@ dpkg: .PHONY: install.bin install.bin: apps - $(MAKE) -C apps install SBINDIR=$(abspath $(SBINDIR)) - $(INSTALL) -d $(BINDIR) $(ETCDIR) - $(INSTALL_PROG) scripts/n3nctl $(BINDIR) + $(MAKE) -C apps install CONFIG_SBINDIR=$(abspath $(CONFIG_SBINDIR)) + $(INSTALL) -d $(CONFIG_BINDIR) $(ETCDIR) + $(INSTALL_PROG) scripts/n3nctl $(CONFIG_BINDIR) # TODO: dont install.systemd for a non systemd host .PHONY: install.systemd install.systemd: - $(INSTALL) -d $(SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/edge@.service $(SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/edge.service $(SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/supernode.service $(SYSTEMDDIR) + $(INSTALL) -d $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/edge@.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/edge.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/supernode.service $(CONFIG_SYSTEMDDIR) .PHONY: install.doc -install: edge.8.gz supernode.1.gz n3n.7.gz - $(INSTALL) -d $(MAN1DIR) $(MAN7DIR) $(MAN8DIR) $(DOCDIR) +install: edge.8.gz supernode.8.gz n3n.7.gz + $(INSTALL) -d $(MAN7DIR) $(MAN8DIR) $(CONFIG_DOCDIR) $(INSTALL_DOC) edge.8.gz $(MAN8DIR)/ - $(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/ + $(INSTALL_DOC) supernode.8.gz $(MAN8DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ - $(INSTALL_DOC) doc/*.md doc/*.sample $(DOCDIR)/ + $(INSTALL_DOC) doc/*.md doc/*.sample $(CONFIG_DOCDIR)/ # TODO: # install wireshark dissector diff --git a/apps/Makefile b/apps/Makefile index 35a606c9..794a4435 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -37,9 +37,9 @@ $(APPS) $(EXAMPLES): ../src/libn3n.a .PHONY: install install: $(addsuffix $(EXE),$(APPS)) - $(INSTALL) -d $(SBINDIR) - $(INSTALL_PROG) supernode$(EXE) $(SBINDIR)/ - $(INSTALL_PROG) edge$(EXE) $(SBINDIR)/ + $(INSTALL) -d $(CONFIG_SBINDIR) + $(INSTALL_PROG) supernode$(EXE) $(CONFIG_SBINDIR)/ + $(INSTALL_PROG) edge$(EXE) $(CONFIG_SBINDIR)/ # See comments in the topdir Makefile about how to generate coverage data. gcov: diff --git a/config.mak.in b/config.mak.in index ece0046a..f45bc230 100644 --- a/config.mak.in +++ b/config.mak.in @@ -3,7 +3,11 @@ CONFIG_HOST=@host@ CONFIG_HOST_OS=@host_os@ -CONFIG_PREFIX=@prefix@ + +CONFIG_PREFIX=@CONFIG_PREFIX@ +CONFIG_DOCDIR=$(DESTDIR)/@CONFIG_DOCDIR@ +CONFIG_MANDIR=$(DESTDIR)/@CONFIG_MANDIR@ +CONFIG_SYSTEMDDIR=$(DESTDIR)/@CONFIG_SYSTEMDDIR@ CONFIG_WITH_OPENSSL=@with_openssl@ diff --git a/configure.ac b/configure.ac index 1e9fe7c5..29c0d4d0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -odnl> Do not add anything above -AC_INIT([edge], m4_esyscmd([scripts/version.sh | tr -d '\n'])) +dnl> Do not add anything above +AC_INIT([n3n], m4_esyscmd([scripts/version.sh | tr -d '\n'])) dnl> Do not add anything above # Older versions of the autotools expect to find install-sh here. @@ -43,6 +43,12 @@ case "$host_os" in ;; esac +AC_ARG_WITH([systemddir], + AS_HELP_STRING([--with-systemddir=DIR], [Where to install systemd units]), + [systemddir=$withval], + [systemddir=""] +) + # TODO: ideally, should use AC_ARG_ENABLE AC_ARG_WITH([zstd], AS_HELP_STRING([--with-zstd], [use zstd library]), @@ -108,6 +114,32 @@ AS_IF([test "x$enable_pthread" != xno], )], ) +# The prefix var has no default at this point, so we cannot eval it without +# this hack +AS_IF([test "x$prefix" = "xNONE" ], + prefix=/usr/local +) + +# The systemd unit dir should be in a sane location (based on the prefix) but +# that is not always a dir underneath the prefix. Apply another hack +AS_IF([test "x$systemddir" = "x" ], + AS_IF([test "x$prefix" = "x/usr"], + systemddir=/lib/systemd/system, + systemddir=$prefix/lib/systemd/system + ) +) + +# All this indirection would be great, if the namespace wasnt poluted +# (and for many of the dirs, if the directories were more modern) +CONFIG_DOCDIR=$(eval echo $(eval echo $docdir)) +CONFIG_MANDIR=$(eval echo $(eval echo $mandir)) +CONFIG_PREFIX=$prefix +CONFIG_SYSTEMDDIR=$systemddir + +AC_SUBST(CONFIG_DOCDIR) +AC_SUBST(CONFIG_MANDIR) +AC_SUBST(CONFIG_PREFIX) +AC_SUBST(CONFIG_SYSTEMDDIR) AC_SUBST(host) AC_SUBST(host_os) diff --git a/edge.8 b/edge.8 index 9102e140..835d8bb7 100644 --- a/edge.8 +++ b/edge.8 @@ -233,7 +233,7 @@ deri (at) ntop.org - original author of n2n Don Bindner (--) - significant contributions to n2n-1 .SH SEE ALSO -ifconfig(8) supernode(1) tunctl(8) n3n(7) +ifconfig(8) supernode(8) tunctl(8) n3n(7) .br the documentation contained in the source code .br diff --git a/n3n.7 b/n3n.7 index aaeaf9fa..1f442a98 100644 --- a/n3n.7 +++ b/n3n.7 @@ -129,7 +129,7 @@ deri (at) ntop.org - original author of n2n Don Bindner (--) - significant contributions to n2n-1 .SH SEE ALSO -ifconfig(8) edge(8) supernode(1) +ifconfig(8) edge(8) supernode(8) .br the documentation contained in the source code .br diff --git a/packages/rpm/n3n.spec b/packages/rpm/n3n.spec index b7beeb41..dd1da6e1 100644 --- a/packages/rpm/n3n.spec +++ b/packages/rpm/n3n.spec @@ -70,9 +70,9 @@ rm -fr $RPM_BUILD_ROOT /usr/share/doc/n3n/community.list.sample /usr/share/doc/n3n/edge.conf.sample /usr/share/doc/n3n/supernode.conf.sample -/usr/share/man/man1/supernode.1.gz /usr/share/man/man7/n3n.7.gz /usr/share/man/man8/edge.8.gz +/usr/share/man/man8/supernode.8.gz # Set the default attributes of all of the files specified to have an # owner and group of root and to inherit the permissions of the file diff --git a/supernode.1 b/supernode.8 similarity index 98% rename from supernode.1 rename to supernode.8 index ca35bd41..ddc86316 100644 --- a/supernode.1 +++ b/supernode.8 @@ -1,4 +1,4 @@ -.TH supernode 1 "5 Jan 2024" "version 3" "USER COMMANDS" +.TH supernode 8 "5 Jan 2024" "version 3" "USER COMMANDS" .SH NAME supernode \- n3n supernode daemon .SH SYNOPSIS diff --git a/tools/Makefile b/tools/Makefile index fd78a431..36fc12e2 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -37,5 +37,5 @@ clean: rm -f $(TESTS) *.gcno *.gcda install: $(TOOLS) - $(INSTALL) -d $(SBINDIR) - $(INSTALL_PROG) $(addsuffix $(EXE),$(TOOLS)) $(SBINDIR)/ + $(INSTALL) -d $(CONFIG_SBINDIR) + $(INSTALL_PROG) $(addsuffix $(EXE),$(TOOLS)) $(CONFIG_SBINDIR)/