Description: Made target up to PREFIX and pass path to binary at compiling.
Author: Lucas de Castro Borges <lucascastroborges@gmail.com>
Last-Update: 2016-05-09
Forwarded: yes
Index: lsm-1.0.4/Makefile
===================================================================
--- lsm-1.0.4.orig/Makefile
+++ lsm-1.0.4/Makefile
@@ -16,12 +16,20 @@ override CFLAGS	+= -Wall -O2 -DLSM_VERSI
 
 LDFLAGS =
 
-INITDDIR ?= /etc/init.d
-DOCDIR	?= /usr/share/doc/lsm
+PREFIX ?= /usr/local
+DESTDIR ?=
+BINDIR ?= $(PREFIX)/sbin
+ETCDIR ?= /etc/lsm
+DOCDIR ?= $(PREFIX)/share/doc/lsm
+EXAMPLEDIR ?= $(DOCDIR)/examples
+SCRIPTDIR ?= $(PREFIX)/share/lsm
 
 DOCFILES = README lsm.conf.sample default_script.sample rsyslog-lsm.conf.sample
 SCRIPTS	= shorewall_script shorewall6_script default_script group_script
 
+override CFLAGS += -DETCDIR=\"$(ETCDIR)\"
+override CFLAGS += -DSCRIPTDIR=\"$(SCRIPTDIR)\"
+
 .PHONY:	all clean distclean tar rpm
 
 all: $(PROGS)
@@ -52,20 +60,13 @@ Makefile.depend: *.c *.h Makefile
 	$(CC) -MM *.c > $@
 
 install: all
-	mkdir -p $(DESTDIR)/etc/lsm
-	mkdir -p $(DESTDIR)$(INITDDIR)
-	mkdir -p $(DESTDIR)/usr/sbin
-	mkdir -p $(DESTDIR)$(DOCDIR)
-	mkdir -p $(DESTDIR)/usr/share/lsm
-	mkdir -p $(DESTDIR)/usr/libexec/lsm
-	mkdir -p $(DESTDIR)/var/lib/lsm
-	install -m0644 lsm.conf $(DESTDIR)/etc/lsm
-	install -m0755 lsm.init $(DESTDIR)$(INITDDIR)/lsm
-	install -m0755 lsm $(DESTDIR)/usr/sbin
-	install -m0644 $(DOCFILES) $(DESTDIR)$(DOCDIR)
-	install -m0755 $(SCRIPTS) $(DESTDIR)/usr/libexec/lsm
-	ln -sf ../../libexec/lsm/default_script $(DESTDIR)/usr/share/lsm/default_script
-	ln -sf ../../libexec/lsm/shorewall_script $(DESTDIR)/usr/share/lsm/shorewall_script
+	install -d $(DESTDIR)$(EXAMPLEDIR)
+	install -d $(DESTDIR)$(SCRIPTDIR)
+	install -d $(DESTDIR)/var/lib/lsm
+	install -D -m0644 lsm.conf $(DESTDIR)$(ETCDIR)/lsm.conf
+	install -D -m0755 lsm $(DESTDIR)$(BINDIR)/lsm
+	install -m0644 $(DOCFILES) $(DESTDIR)$(EXAMPLEDIR)
+	install -m0755 $(SCRIPTS) $(DESTDIR)$(SCRIPTDIR)
 
 -include Makefile.depend
 
