From f10b75c4b7c9d9bf132e3a7eb9f493a64660ca68 Mon Sep 17 00:00:00 2001 From: Bogomil Vasilev Date: Thu, 18 May 2017 18:05:04 +0300 Subject: [PATCH] Makefile is now more flexible --- .gitignore | 1 + Makefile | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index cbe6280..2364f80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ tmp/* *.o +*.bak rmpsd agent/*.o agent/agent diff --git a/Makefile b/Makefile index b0ad1b0..07b7194 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,23 @@ CC ?= cc -CCFLAGS ?= -O2 -CCFLAGS += -Wall \ +OLEVEL ?= -O2 +WFLAGS ?= -Wall \ -Wextra \ - -pipe \ -Wmissing-declarations \ - -pedantic \ + -pedantic +SQLCCFLAGS ?= $(shell mysql_config --cflags) +CCFLAGS += -pipe \ -fstack-protector-strong -CCFLAGS += $(shell mysql_config --cflags) + +# Use this to store compile flags and debug info. +# You may simply check the flags later with: +# $ readelf -p .GCC.command.line rmpsd +ifeq "$(DEBUG)" "yes" +CCFLAGS += -frecord-gcc-switches -g +endif LDFLAGS = -O1 -lcrypto -lssl -lpthread LDFLAGS += -Wl,-z,relro,-z,now -LDFLAGS += $(shell mysql_config --libs) +SQLLDFLAGS += $(shell mysql_config --libs) SOURCES = main.c \ confparser.c \ @@ -30,11 +37,11 @@ all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) @echo ' LD $@' - @$(CC) $(LDFLAGS) $(OBJECTS) $(DBFLAGS) -o $@ + @$(CC) $(LDFLAGS) $(SQLLDFLAGS) $(OBJECTS) -o $@ .c.o: @echo ' CC $@' - @$(CC) $(CCFLAGS) $(DBFLAGS) -c $< -o $@ + @$(CC) $(CCFLAGS) $(WFLAGS) $(SQLCCFLAGS) $(OLEVEL) -c $< -o $@ clean: rm -f $(OBJECTS) $(EXECUTABLE) @@ -47,3 +54,4 @@ install: uninstall: rm -f "$(INSTALLDIR)/$(EXECUTABLE)" +