X-Git-Url: https://git.stg.codes/ssmd.git/blobdiff_plain/25dd1ac0696ca47e586e58d4309fc4c36e11d1dc..refs/heads/master:/Makefile diff --git a/Makefile b/Makefile index 1d3630f..5b86f16 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,26 @@ -DEFS = -INCS = -Iinclude -I3rdparty/snmp++/include +ifeq ($(BUILD),Debug) + DEFS += -DDEBUG + CXXFLAGS += -g3 +endif + +UNAME = $(shell uname -s) + +ifeq ($(UNAME), Darwin) + BOOST_SUFFIX = -mt +endif + +INCS = -I/opt/local/include -Iinclude -I3rdparty/snmp++/include CXXFLAGS += -W -Wall -Wextra $(INCS) $(DEFS) -LIBS = -lpthread \ - -lssl \ +LIBS = -L/opt/local/lib \ + 3rdparty/snmp++/libsnmp++.a \ + -lboost_system$(BOOST_SUFFIX) \ + -lboost_program_options$(BOOST_SUFFIX) \ -lcurl \ - -lboost_system \ - -lboost_program_options \ - 3rdparty/snmp++/libsnmp++.a + -lssl \ + -lcrypto \ + -lpthread PROG = ssmd # SNMP Switch Management Daemon -VERSION = 1.1.2 +VERSION = 1.2.2 SOURCES = src/main.cpp \ src/pidfile.cpp \ @@ -22,7 +34,12 @@ SOURCES = src/main.cpp \ src/snmptable.cpp \ src/dataparser.cpp -.PHONY: all clean snmplib version tests +PREFIX = +BIN_MODE = 0755 +DATA_MODE = 0644 +OWNER = root + +.PHONY: all clean snmplib version tests install uninstall all: $(PROG) @@ -35,8 +52,9 @@ snmplib: include/version.h: version version: - @sed 's/@VERSION@/$(VERSION)/g' include/version.h.in > include/version.h - @sed -i 's/@GIT_SHA@/'`git rev-parse --short HEAD`'/g' include/version.h + @sed 's/@VERSION@/$(VERSION)/g' include/version.h.in > include/version.h.tmp + @sed "s/@GIT_SHA@/$$(git rev-parse --short HEAD)/g" include/version.h.tmp > include/version.h + @rm include/version.h.tmp $(PROG): version $(subst .cpp,.o,$(SOURCES)) snmplib $(CXX) $(subst .cpp,.o,$(SOURCES)) $(LIBS) -o $@ @@ -44,6 +62,26 @@ $(PROG): version $(subst .cpp,.o,$(SOURCES)) snmplib clean: snmplib rm -f src/*.o src/*.d $(PROG) include/version.h +install: install-bin install-data + +install-bin: +ifeq ($(findstring $(DEFS), -DDEBUG),) + install -D -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/sbin/$(PROG) +else + install -D -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG) +endif + +install-data: + install -D -m $(DATA_MODE) -o $(OWNER) ./ssmd.conf $(PREFIX)/etc/ssmd/ssmd.conf + +uninstall: uninstall-bin uninstall-data + +uninstall-bin: + rm -f $(PREFIX)/usr/sbin/$(PROG) + +uninstall-data: + rm -f $(PREFIX)/etc/ssmd/ssmd.conf + ifneq ($(MAKECMDGOALS),distclean) ifneq ($(MAKECMDGOALS),clean) -include $(subst .cpp,.d,$(SOURCES))