Skip to content

Commit

Permalink
Makefile: add install and uninstall target
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfl authored and updateing committed Feb 3, 2018
1 parent 1c94120 commit d4d8d9a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ minieap: $(BUILD_MODULES)

.PHONY: clean
clean: $(addsuffix _clean,$(BUILD_MODULES))
rm -f minieap.service minieap.1.gz

define my-dir
$(dir $(lastword $(MAKEFILE_LIST)))
Expand All @@ -61,3 +62,36 @@ endef
APPEND := $(shell pwd)/append.mk
MK_LIST := $(shell find . -name minieap.mk)
include $(MK_LIST)

#### Install ####

DESTDIR ?=
PREFIX ?= /usr/local
BINDIR ?= /sbin
SYSCONFDIR ?= /etc
SYSTEMDDIR ?= $(SYSCONFDIR)/systemd

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

minieap.1.gz: minieap.1
gzip -k $<

.PHONY: install
install: minieap minieap.1.gz minieap.service
install -d $(DESTDIR)$(PREFIX)$(BINDIR)/
install -m 755 minieap $(DESTDIR)$(PREFIX)$(BINDIR)/
install -d $(DESTDIR)$(SYSCONFDIR)/
install -m 644 minieap.conf $(DESTDIR)$(SYSCONFDIR)/
install -d $(DESTDIR)$(PREFIX)/share/man/man1/
install -m 644 minieap.1.gz $(DESTDIR)$(PREFIX)/share/man/man1/
install -d $(DESTDIR)$(SYSTEMDDIR)/system/
install -m 644 minieap.service $(DESTDIR)$(SYSTEMDDIR)/system/
-systemctl enable minieap

.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/minieap
rm -f $(DESTDIR)$(PREFIX)/share/man/man1/minieap.1.gz
-systemctl disable minieap
rm -f $(DESTDIR)$(SYSTEMDDIR)/system/minieap.service

0 comments on commit d4d8d9a

Please sign in to comment.