From c4f3dfae3a5f51a0598f9d9baac265126c9d07af Mon Sep 17 00:00:00 2001 From: Dominic Reich Date: Sat, 18 Feb 2023 14:11:46 +0100 Subject: [PATCH] adds Makefile (removes build.sh); new Versioning method --- Makefile | 22 ++++++++++++++++++++++ blacklist.cpp | 14 ++++++++++---- build.sh | 5 ----- 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100755 Makefile delete mode 100755 build.sh diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..c409d28 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +GIT_VERSION := "$(shell git describe --abbrev=6 --dirty --always --tags)" + +PREFIX=/usr/local/sbin + +CC = g++ +CFLAGS = -O2 -pipe -fomit-frame-pointer -Wall -s -pie -fpie +LFLAGS = -lboost_system +VERSION_FLAGS = -DVERSION=\"$(GIT_VERSION)\" + +.PHONY: all clean install + +all: clean blacklist + +blacklist:blacklist.cpp + $(CC) $(CFLAGS) $(LFLAGS) $(VERSION_FLAGS) -o $@ $^ + +clean: + rm -f blacklist + +install: + install -D -o root -g root -m 750 blacklist $(PREFIX)/blacklist + diff --git a/blacklist.cpp b/blacklist.cpp index 60cf829..aab4b0c 100644 --- a/blacklist.cpp +++ b/blacklist.cpp @@ -43,7 +43,6 @@ #include // get duplicates in vector #include // remove duplicates in vectora #include // find ip in file (string compare) -#include "version.h" // Code::Blocks AutoVersioning /** \brief Some definitions @@ -56,6 +55,13 @@ * */ +#define STATUS "RCx [nod.oe7drt.com]" +#define COPYRIGHT "Copyright (C)2015-2023 Dominic Reich" + +#ifndef VERSION +#define VERSION "0.0-noversion (check Makefile)" +#endif + #define DEFAULT_FILENAME "/etc/blacklist-ip" #define TMP_FILENAME "/tmp/blacklist" #define IPTABLES "/sbin/iptables" @@ -295,9 +301,9 @@ inline bool fileExists(const string &name) { */ void printHelp(bool printAll) { - cout << "blacklist " << Version::VERSION_STRING << ", "; - cout << Version::STATUS << endl; - cout << Version::COPYRIGHT << endl; + cout << "blacklist " << VERSION << ", "; + cout << STATUS << endl; + cout << COPYRIGHT << endl; cout << "Usage: blacklist [options] " << endl; if(printAll == true) { diff --git a/build.sh b/build.sh deleted file mode 100755 index 7fb4f55..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -g++ blacklist.cpp -o blacklist -O2 -pipe -fomit-frame-pointer -Wall -s -pie -fpie -lboost_system - -#cp blacklist /usr/local/bin/ -cp blacklist /usr/local/sbin/blacklist