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

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
tmp/* tmp/*
*.o *.o
*.bak
rmpsd rmpsd
agent/*.o agent/*.o
agent/agent agent/agent

View File

@@ -1,16 +1,23 @@
CC ?= cc CC ?= cc
CCFLAGS ?= -O2 OLEVEL ?= -O2
CCFLAGS += -Wall \ WFLAGS ?= -Wall \
-Wextra \ -Wextra \
-pipe \
-Wmissing-declarations \ -Wmissing-declarations \
-pedantic \ -pedantic
SQLCCFLAGS ?= $(shell mysql_config --cflags)
CCFLAGS += -pipe \
-fstack-protector-strong -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 = -O1 -lcrypto -lssl -lpthread
LDFLAGS += -Wl,-z,relro,-z,now LDFLAGS += -Wl,-z,relro,-z,now
LDFLAGS += $(shell mysql_config --libs) SQLLDFLAGS += $(shell mysql_config --libs)
SOURCES = main.c \ SOURCES = main.c \
confparser.c \ confparser.c \
@@ -30,11 +37,11 @@ all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS) $(EXECUTABLE): $(OBJECTS)
@echo ' LD $@' @echo ' LD $@'
@$(CC) $(LDFLAGS) $(OBJECTS) $(DBFLAGS) -o $@ @$(CC) $(LDFLAGS) $(SQLLDFLAGS) $(OBJECTS) -o $@
.c.o: .c.o:
@echo ' CC $@' @echo ' CC $@'
@$(CC) $(CCFLAGS) $(DBFLAGS) -c $< -o $@ @$(CC) $(CCFLAGS) $(WFLAGS) $(SQLCCFLAGS) $(OLEVEL) -c $< -o $@
clean: clean:
rm -f $(OBJECTS) $(EXECUTABLE) rm -f $(OBJECTS) $(EXECUTABLE)
@@ -47,3 +54,4 @@ install:
uninstall: uninstall:
rm -f "$(INSTALLDIR)/$(EXECUTABLE)" rm -f "$(INSTALLDIR)/$(EXECUTABLE)"