Makefile is now more flexible

This commit is contained in:
2017-05-18 18:05:04 +03:00
parent 88d4942e2c
commit f10b75c4b7
2 changed files with 17 additions and 8 deletions

View File

@@ -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)"