This commit has been accessed 5 times via Git panel.
commit 6c33e2c5f5577f554079bf22ec9f057849a409d9
tree 89d9746be280e441d1b38f79b297803c7f03ce5f
parent 1229ef93b92abd28420162846c3bc3e042ac9272
author Engels Antonio <engels@kalasag.org> 1782532971 +0800
committer Engels Antonio <engels@kalasag.org> 1782532971 +0800
Makefile: add .PHONY, fix clean target, add install guard and daemon-reload
- Declare .PHONY for all, clean, install, uninstall
- Fix clean: use rm -f, clean *.o too
- Fail install early if binary hasn't been built
- Run systemctl daemon-reload after service install/uninstall
diff --git a/Makefile b/Makefile
index cd989e0..1503b30 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,8 @@ BSD_CFLAGS = $(BASE_CFLAGS) -fPIE -Wl,-pie -fstack-protector-strong
INSTALLDIR = /opt
CHILDDIR=/kalasag
+.PHONY: all clean install uninstall
+
all:
@echo "Usage: make <systype>"
@echo "<systype> is one of: linux, linux-x86_64, debian-linux, bsd, solaris, hpux, hpux-gcc,"
@@ -68,7 +70,7 @@ all:
@echo ""
clean:
- /bin/rm ./kalasag
+ /bin/rm -f ./kalasag *.o
uninstall:
@for svc in kalasag-tcp kalasag-udp; do \
@@ -78,9 +80,14 @@ uninstall:
rm -f /usr/lib/systemd/system/$$svc.service; \
fi; \
done
+ @systemctl daemon-reload 2>/dev/null || true
@if [ -d $(INSTALLDIR)$(CHILDDIR) ]; then rm -rf $(INSTALLDIR)$(CHILDDIR)/*; fi
-install:
+install:
+ @if [ ! -f ./kalasag ]; then \
+ echo "Error: ./kalasag not found. Build first (e.g. make linux)"; \
+ exit 1; \
+ fi
@if [ ! -d $(INSTALLDIR)$(CHILDDIR) ]; then mkdir -p $(INSTALLDIR)$(CHILDDIR); fi
@chmod 700 $(INSTALLDIR)$(CHILDDIR)
@cp ./kalasag.conf $(INSTALLDIR)$(CHILDDIR)
@@ -89,6 +96,7 @@ install:
@if [ -d /usr/lib/systemd/system ]; then \
cp ./kalasag-tcp.service /usr/lib/systemd/system/; \
cp ./kalasag-udp.service /usr/lib/systemd/system/; \
+ systemctl daemon-reload; \
systemctl enable kalasag-tcp.service; \
systemctl enable kalasag-udp.service; \
fi
tree 89d9746be280e441d1b38f79b297803c7f03ce5f
parent 1229ef93b92abd28420162846c3bc3e042ac9272
author Engels Antonio <engels@kalasag.org> 1782532971 +0800
committer Engels Antonio <engels@kalasag.org> 1782532971 +0800
Makefile: add .PHONY, fix clean target, add install guard and daemon-reload
- Declare .PHONY for all, clean, install, uninstall
- Fix clean: use rm -f, clean *.o too
- Fail install early if binary hasn't been built
- Run systemctl daemon-reload after service install/uninstall
diff --git a/Makefile b/Makefile
index cd989e0..1503b30 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,8 @@ BSD_CFLAGS = $(BASE_CFLAGS) -fPIE -Wl,-pie -fstack-protector-strong
INSTALLDIR = /opt
CHILDDIR=/kalasag
+.PHONY: all clean install uninstall
+
all:
@echo "Usage: make <systype>"
@echo "<systype> is one of: linux, linux-x86_64, debian-linux, bsd, solaris, hpux, hpux-gcc,"
@@ -68,7 +70,7 @@ all:
@echo ""
clean:
- /bin/rm ./kalasag
+ /bin/rm -f ./kalasag *.o
uninstall:
@for svc in kalasag-tcp kalasag-udp; do \
@@ -78,9 +80,14 @@ uninstall:
rm -f /usr/lib/systemd/system/$$svc.service; \
fi; \
done
+ @systemctl daemon-reload 2>/dev/null || true
@if [ -d $(INSTALLDIR)$(CHILDDIR) ]; then rm -rf $(INSTALLDIR)$(CHILDDIR)/*; fi
-install:
+install:
+ @if [ ! -f ./kalasag ]; then \
+ echo "Error: ./kalasag not found. Build first (e.g. make linux)"; \
+ exit 1; \
+ fi
@if [ ! -d $(INSTALLDIR)$(CHILDDIR) ]; then mkdir -p $(INSTALLDIR)$(CHILDDIR); fi
@chmod 700 $(INSTALLDIR)$(CHILDDIR)
@cp ./kalasag.conf $(INSTALLDIR)$(CHILDDIR)
@@ -89,6 +96,7 @@ install:
@if [ -d /usr/lib/systemd/system ]; then \
cp ./kalasag-tcp.service /usr/lib/systemd/system/; \
cp ./kalasag-udp.service /usr/lib/systemd/system/; \
+ systemctl daemon-reload; \
systemctl enable kalasag-tcp.service; \
systemctl enable kalasag-udp.service; \
fi