Skip to content

Commit

Permalink
Makefile: factor in PREFIX to install directories
Browse files Browse the repository at this point in the history
Sometimes we want to set PREFIX and leave the installation directories relative
to the PREFIX.

Other times we want to set some of these installation directories to absolute
values.

Sometimes we want both.

This commit patch achieves this with a reasonably small effort, by not
propagating PREFIX around the Makefile.
  • Loading branch information
AndersonTorres authored and rfjakob committed Sep 4, 2024
1 parent 01d8a0e commit f7d6f1c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ CFLAGS += -Wall -Wextra -Wformat-security -Wconversion -DVERSION=\"$(VERSION)\"

DESTDIR ?=
PREFIX ?= /usr/local
BINDIR ?= /bin
MANDIR ?= /share/man
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
MAN1DIR ?= $(MANDIR)/man1
SYSCONFDIR ?= /etc
SYSCONFDIR ?= $(PREFIX)/etc
SYSTEMDUNITDIR ?= $(SYSCONFDIR)/systemd/system
PANDOC := $(shell command -v pandoc 2> /dev/null)

Expand Down Expand Up @@ -49,20 +49,20 @@ install-initscript: earlyoom.initscript install-bin install-default
-update-rc.d earlyoom start 18 2 3 4 5 . stop 20 0 1 6 .

earlyoom.%: earlyoom.%.in
sed "s|:TARGET:|$(PREFIX)$(BINDIR)|g;s|:SYSCONFDIR:|$(SYSCONFDIR)|g" $< > $@
sed "s|:TARGET:|$(BINDIR)|g;s|:SYSCONFDIR:|$(SYSCONFDIR)|g" $< > $@

install-default: earlyoom.default install-man
install -d $(DESTDIR)$(SYSCONFDIR)/default/
install -m 644 $< $(DESTDIR)$(SYSCONFDIR)/default/earlyoom

install-bin: earlyoom
install -d $(DESTDIR)$(PREFIX)$(BINDIR)/
install -m 755 $< $(DESTDIR)$(PREFIX)$(BINDIR)/
install -d $(DESTDIR)$(BINDIR)/
install -m 755 $< $(DESTDIR)$(BINDIR)/

install-man: earlyoom.1.gz
ifdef PANDOC
install -d $(DESTDIR) $(PREFIX)$(MAN1DIR)/
install -m 644 $< $(DESTDIR)$(PREFIX)$(MAN1DIR)/
install -d $(DESTDIR) $(MAN1DIR)/
install -m 644 $< $(DESTDIR)$(MAN1DIR)/
endif

earlyoom.1.gz: earlyoom.1
Expand All @@ -75,14 +75,14 @@ uninstall: uninstall-bin uninstall-man
rm -f $(DESTDIR)$(SYSTEMDUNITDIR)/earlyoom.service

uninstall-man:
rm -f $(DESTDIR)$(PREFIX)$(MAN1DIR)/earlyoom.1.gz
rm -f $(DESTDIR)$(MAN1DIR)/earlyoom.1.gz

uninstall-initscript: uninstall-bin
rm -f $(DESTDIR)$(SYSCONFDIR)/init.d/earlyoom
update-rc.d earlyoom remove

uninstall-bin:
rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/earlyoom
rm -f $(DESTDIR)$(BINDIR)/earlyoom

# Depends on earlyoom compilation to make sure the syntax is ok.
format: earlyoom
Expand Down

0 comments on commit f7d6f1c

Please sign in to comment.