From 10cad7732d46d6875895ec55f9c469b304f0f9c8 Mon Sep 17 00:00:00 2001 From: Attila Kovacs Date: Tue, 12 Nov 2024 23:02:07 +0100 Subject: [PATCH] Makefile: install only what was built --- .github/workflows/install.yml | 12 ++++++++ Makefile | 54 +++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 67ff729..714737b 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -63,15 +63,27 @@ jobs: with: repository: Smithsonian/smax-clib path: smax-clib + + - name: Build xchange dependency + run: make -C xchange shared - name: Install xchange dependency run: sudo make -C xchange install + + - name: Build RedisX dependency + run: make -C redisx shared - name: Install RedisX dependency run: sudo make -C redisx install + + - name: Build smax-clib dependency + run: make -C smax-clib shared - name: Install smax-clib dependency run: sudo make -C smax-clib install + + - name: Build smax-postgres distro + run: make distro - name: Install smax-postgres in default location run: sudo make install diff --git a/Makefile b/Makefile index 6961cb9..8a50115 100644 --- a/Makefile +++ b/Makefile @@ -101,34 +101,39 @@ CONFIG := "cfg/smax-postgres.cfg" install-sma: CONFIG := "cfg/smax-postgres.cfg.sma" install-sma: install - .PHONY: install install: install-bin install-cfg install-systemd install-doc .PHONY: install-bin -install-bin: app - @echo "installing executable under $(bindir)." +install-bin: +ifneq ($(wildcard $(BIN)/*),) + @echo "installing executable(s) under $(bindir)." @install -d $(bindir) - @install -m 755 $(BIN)/smax-postgres $(bindir)/ + @install -m 755 -D $(BIN)/* $(bindir)/ +else + @echo "WARNING! Skipping bin install: needs 'app'" +endif .PHONY: install-cfg - @if [ ! -e $(sysconfdir)/smax-postgres.cfg ] ; then \ - echo "installing configuration file under $(sysconfdir)." ; \ - install -d $(sysconfdir) ; \ - install -m 644 cfg/smax-postgres.cfg $(sysconfdir)/smax-postgres.cfg ; \ - fi +ifeq ($(wildcard $(sysconfdir)/smax-postgres.cfg),) + @echo "installing configuration file under $(sysconfdir)." + install -d $(sysconfdir) + install -m 644 cfg/smax-postgres.cfg $(sysconfdir)/smax-postgres.cfg +else + @echo "WARNING! Will not override existing $(sysconfdir)/smax-postgres.cfg" +endif .PHONY: install-systemd install-systemd: - @if [ $(SYSTEMD) -ne 0 ] ; then \ - echo "installing systemd unit file under $(systemddir)." ; \ - mkdir -p $(systemddir) ; \ - install -m 644 smax-postgres.service $(systemddir) ; \ - sed -i "s:/usr/:$(prefix):g" $(systemddir)/smax-postgres.service ; \ - fi +ifneq ($(SYSTEMD), 0) + @echo "installing systemd unit file under $(systemddir)." + mkdir -p $(systemddir) + install -m 644 smax-postgres.service $(systemddir) + sed -i "s:/usr/:$(prefix):g" $(systemddir)/smax-postgres.service +endif .PHONY: install-doc -install-doc: install-apidoc $(DOC_TARGETS) +install-doc: install-apidoc @echo "installing docs under $(docdir)." @install -d $(docdir) @install -m 644 LICENSE $(docdir) @@ -136,14 +141,15 @@ install-doc: install-apidoc $(DOC_TARGETS) @install -m 644 CHANGELOG.md $(docdir) .PHONY: install-apidoc -install-apidoc: $(DOC_TARGETS) - @if [ -e apidoc/html/index.html ] ; then \ - echo "installing API docs under $(htmldir)." ; \ - install -d $(htmldir)/search ; \ - install -m 644 -D apidoc/html/* $(htmldir)/smax-postgres/ ; \ - install -m 644 -D apidoc/html/search/* $(htmldir)/search/ ; \ - fi - +install-apidoc: +ifneq ($(wildcard apidoc/html/search/*,) + @echo "installing API docs under $(htmldir)." + install -d $(htmldir)/search + install -m 644 -D apidoc/html/* $(htmldir)/smax-postgres/ + install -m 644 -D apidoc/html/search/* $(htmldir)/search/ +else + @echo "WARNING! Skipping apidoc install: needs doxygen and 'local-dox'" +endif # Built-in help screen for `make help` .PHONY: help