Skip to content

Commit

Permalink
Merge pull request #17 from hamishcoleman/main
Browse files Browse the repository at this point in the history
Attempts to improve install path flexibility
  • Loading branch information
hamishcoleman authored Mar 10, 2024
2 parents 0f9cf6e + ceb46d9 commit 6473b80
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 48 deletions.
73 changes: 37 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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/[email protected] $(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/[email protected] $(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
Expand Down
6 changes: 3 additions & 3 deletions apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion config.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@

Expand Down
36 changes: 34 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion edge.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion n3n.7
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/rpm/n3n.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion supernode.1 → supernode.8
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)/

0 comments on commit 6473b80

Please sign in to comment.