Skip to content

Commit

Permalink
Makefile: install only what was built
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Nov 12, 2024
1 parent 3224c30 commit 1fbd9e9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 23 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ 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

Expand All @@ -112,38 +111,41 @@ install-bin: app
@install -m 755 $(BIN)/smax-postgres $(bindir)/

.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)
@install -m 644 README-smax-postgres.md $(docdir)/README.md
@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
Expand Down

0 comments on commit 1fbd9e9

Please sign in to comment.