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 626ab9c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 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
54 changes: 30 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,49 +101,55 @@ 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)
@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 626ab9c

Please sign in to comment.