From 41e01d4f34bb7eac9d3cba801c5f636d35e07806 Mon Sep 17 00:00:00 2001 From: Adam Kolakowski Date: Thu, 28 May 2020 23:13:19 +0200 Subject: [PATCH] Adds DESTDIR build variable Setting DESTDIR on `make install` allows for installing artefacts in staging location for automated build, packaging etc. --- APRSTransmit/Makefile | 2 +- BUILD.md | 1 + Data/Makefile | 70 ++++++++++++++++++------------------ Makefile | 26 ++++++++------ RemoteControl/Makefile | 2 +- StarNetServer/Makefile | 2 +- TextTransmit/Makefile | 2 +- TimeServer/Makefile | 2 +- TimerControl/Makefile | 2 +- VoiceTransmit/Makefile | 2 +- ircDDBGateway/Makefile | 6 ++-- ircDDBGatewayConfig/Makefile | 2 +- 12 files changed, 62 insertions(+), 57 deletions(-) diff --git a/APRSTransmit/Makefile b/APRSTransmit/Makefile index 17e82b4..c6d50c8 100644 --- a/APRSTransmit/Makefile +++ b/APRSTransmit/Makefile @@ -14,7 +14,7 @@ aprstransmitd: $(OBJECTS) ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 aprstransmitd $(BINDIR) + install -g root -o root -m 0755 aprstransmitd $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/BUILD.md b/BUILD.md index 6d22507..a3b8623 100644 --- a/BUILD.md +++ b/BUILD.md @@ -69,6 +69,7 @@ You can optionally specify some make variables to alter the default behavior: | LOGDIR | `/var/log` | location of log files | | CONFDIR | `/etc` | location of configuration files | | BINDIR | `/usr/bin` | program binaries installed here | +| DESTDIR | _not set_ | destination for staged build | ### Example diff --git a/Data/Makefile b/Data/Makefile index c115445..7af396d 100644 --- a/Data/Makefile +++ b/Data/Makefile @@ -1,37 +1,37 @@ .PHONY: install install: - install -d -g bin -o root -m 0775 $(DATADIR) - install -g bin -o root -m 0664 CCS_Hosts.txt $(DATADIR) - install -g bin -o root -m 0664 DCS_Hosts.txt $(DATADIR) - install -g bin -o root -m 0664 DExtra_Hosts.txt $(DATADIR) - install -g bin -o root -m 0664 DPlus_Hosts.txt $(DATADIR) - install -g bin -o root -m 0664 TIME_de_DE.ambe $(DATADIR) - install -g bin -o root -m 0664 TIME_de_DE.indx $(DATADIR) - install -g bin -o root -m 0664 TIME_en_GB.ambe $(DATADIR) - install -g bin -o root -m 0664 TIME_en_GB.indx $(DATADIR) - install -g bin -o root -m 0664 TIME_en_US.ambe $(DATADIR) - install -g bin -o root -m 0664 TIME_en_US.indx $(DATADIR) - install -g bin -o root -m 0664 TIME_fr_FR.ambe $(DATADIR) - install -g bin -o root -m 0664 TIME_fr_FR.indx $(DATADIR) - install -g bin -o root -m 0664 TIME_se_SE.ambe $(DATADIR) - install -g bin -o root -m 0664 TIME_se_SE.indx $(DATADIR) - install -g bin -o root -m 0664 de_DE.ambe $(DATADIR) - install -g bin -o root -m 0664 de_DE.indx $(DATADIR) - install -g bin -o root -m 0664 dk_DK.ambe $(DATADIR) - install -g bin -o root -m 0664 dk_DK.indx $(DATADIR) - install -g bin -o root -m 0664 en_GB.ambe $(DATADIR) - install -g bin -o root -m 0664 en_GB.indx $(DATADIR) - install -g bin -o root -m 0664 en_US.ambe $(DATADIR) - install -g bin -o root -m 0664 en_US.indx $(DATADIR) - install -g bin -o root -m 0664 es_ES.ambe $(DATADIR) - install -g bin -o root -m 0664 es_ES.indx $(DATADIR) - install -g bin -o root -m 0664 fr_FR.ambe $(DATADIR) - install -g bin -o root -m 0664 fr_FR.indx $(DATADIR) - install -g bin -o root -m 0664 it_IT.ambe $(DATADIR) - install -g bin -o root -m 0664 it_IT.indx $(DATADIR) - install -g bin -o root -m 0664 no_NO.ambe $(DATADIR) - install -g bin -o root -m 0664 no_NO.indx $(DATADIR) - install -g bin -o root -m 0664 pl_PL.ambe $(DATADIR) - install -g bin -o root -m 0664 pl_PL.indx $(DATADIR) - install -g bin -o root -m 0664 se_SE.ambe $(DATADIR) - install -g bin -o root -m 0664 se_SE.indx $(DATADIR) + install -d -g root -o root -m 0755 $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 CCS_Hosts.txt $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 DCS_Hosts.txt $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 DExtra_Hosts.txt $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 DPlus_Hosts.txt $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_de_DE.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_de_DE.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_en_GB.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_en_GB.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_en_US.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_en_US.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_fr_FR.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_fr_FR.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_se_SE.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 TIME_se_SE.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 de_DE.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 de_DE.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 dk_DK.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 dk_DK.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 en_GB.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 en_GB.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 en_US.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 en_US.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 es_ES.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 es_ES.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 fr_FR.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 fr_FR.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 it_IT.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 it_IT.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 no_NO.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 no_NO.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 pl_PL.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 pl_PL.indx $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 se_SE.ambe $(DESTDIR)$(DATADIR) + install -g root -o root -m 0644 se_SE.indx $(DESTDIR)$(DATADIR) diff --git a/Makefile b/Makefile index 1f8f13c..53d5d84 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ -export BUILD?=debug +export BUILD ?= debug ifeq ($(TARGET), opendv) -export DATADIR ?= "/usr/share/opendv" -export LOGDIR ?= "/var/log/opendv" -export CONFDIR ?= "/etc" -export BINDIR ?= "/usr/sbin" +export DATADIR ?= /usr/share/opendv +export LOGDIR ?= /var/log/opendv +export CONFDIR ?= /etc +export BINDIR ?= /usr/sbin else -export DATADIR ?= "/usr/share/ircddbgateway" -export LOGDIR ?= "/var/log" -export CONFDIR ?= "/etc" -export BINDIR ?= "/usr/bin" +export DATADIR ?= /usr/share/ircddbgateway +export LOGDIR ?= /var/log +export CONFDIR ?= /etc +export BINDIR ?= /usr/bin endif # Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet @@ -20,7 +20,7 @@ export CXX := $(shell wx-config --cxx) export CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' ifeq ($(BUILD), debug) export CFLAGS := $(CFLAGS) $(DEBUGFLAGS) -else ($(BUILD), release) +else ifeq ($(BUILD), release) export CFLAGS := $(CFLAGS) $(RELEASEFLAGS) endif export GUILIBS := $(shell wx-config --libs adv,core,base) @@ -67,8 +67,12 @@ Common/Common.a: force ircDDB/IRCDDB.a: force $(MAKE) -C ircDDB +.PHONY: installdirs +installdirs: force + /bin/mkdir -p $(DESTDIR)$(DATADIR) $(DESTDIR)$(LOGDIR) $(DESTDIR)$(CONFDIR) $(DESTDIR)$(BINDIR) + .PHONY: install -install: all +install: all installdirs ifeq ($(TARGET), opendv) useradd --user-group -M --system opendv --shell /bin/false || true diff --git a/RemoteControl/Makefile b/RemoteControl/Makefile index a4c399a..f5382c2 100644 --- a/RemoteControl/Makefile +++ b/RemoteControl/Makefile @@ -15,7 +15,7 @@ remotecontrold: $(OBJECTS) ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 remotecontrold $(BINDIR) + install -g root -o root -m 0755 remotecontrold $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/StarNetServer/Makefile b/StarNetServer/Makefile index a08a3b6..a12de40 100644 --- a/StarNetServer/Makefile +++ b/StarNetServer/Makefile @@ -14,7 +14,7 @@ starnetserverd: $(OBJECTS) ../Common/Common.a ../ircDDB/IRCDDB.a .PHONY: install install: - install -g bin -o root -m 0775 starnetserverd $(BINDIR) + install -g root -o root -m 0755 starnetserverd $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/TextTransmit/Makefile b/TextTransmit/Makefile index a059e2e..c1212cb 100644 --- a/TextTransmit/Makefile +++ b/TextTransmit/Makefile @@ -14,7 +14,7 @@ texttransmitd: $(OBJECTS) ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 texttransmitd $(BINDIR) + install -g root -o root -m 0755 texttransmitd $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/TimeServer/Makefile b/TimeServer/Makefile index eca5c6a..d5f5a74 100644 --- a/TimeServer/Makefile +++ b/TimeServer/Makefile @@ -14,7 +14,7 @@ timeserverd: $(OBJECTS) ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 timeserverd $(BINDIR) + install -g root -o root -m 0755 timeserverd $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/TimerControl/Makefile b/TimerControl/Makefile index 823e32c..9cd2b99 100644 --- a/TimerControl/Makefile +++ b/TimerControl/Makefile @@ -15,7 +15,7 @@ timercontrold: $(OBJECTS) ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 timercontrold $(BINDIR) + install -g root -o root -m 0755 timercontrold $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/VoiceTransmit/Makefile b/VoiceTransmit/Makefile index a81f4be..0733fc6 100644 --- a/VoiceTransmit/Makefile +++ b/VoiceTransmit/Makefile @@ -14,7 +14,7 @@ voicetransmitd: $(OBJECTS) ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 voicetransmitd $(BINDIR) + install -g root -o root -m 0755 voicetransmitd $(DESTDIR)$(BINDIR) .PHONY: clean clean: diff --git a/ircDDBGateway/Makefile b/ircDDBGateway/Makefile index 73efe6a..6118f46 100644 --- a/ircDDBGateway/Makefile +++ b/ircDDBGateway/Makefile @@ -14,10 +14,10 @@ ircddbgatewayd: $(OBJECTS) ../ircDDB/IRCDDB.a ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 ircddbgatewayd $(BINDIR) - cp ircddbgateway-emptyconfig $(CONFDIR)/ircddbgateway + install -g root -o root -m 0755 ircddbgatewayd $(DESTDIR)$(BINDIR) + cp ircddbgateway-emptyconfig $(DESTDIR)$(CONFDIR)/ircddbgateway ifeq ($(TARGET), opendv) - cp ../debian/ircddbgatewayd.ircddbgatewayd.service /lib/systemd/system/ircddbgatewayd.service + cp ../debian/ircddbgatewayd.ircddbgatewayd.service $(DESTDIR)/etc/systemd/system/ircddbgatewayd.service endif .PHONY: clean diff --git a/ircDDBGatewayConfig/Makefile b/ircDDBGatewayConfig/Makefile index 7aff717..3bff41c 100644 --- a/ircDDBGatewayConfig/Makefile +++ b/ircDDBGatewayConfig/Makefile @@ -15,7 +15,7 @@ ircddbgatewayconfig: $(OBJECTS) ../GUICommon/GUICommon.a ../Common/Common.a .PHONY: install install: - install -g bin -o root -m 0775 ircddbgatewayconfig $(BINDIR) + install -g root -o root -m 0755 ircddbgatewayconfig $(DESTDIR)$(BINDIR) .PHONY: clean clean: