Improve Makefile

This commit is contained in:
2018-02-18 23:27:22 +02:00
parent bd9ebee627
commit 19268ecafb

View File

@@ -1,16 +1,16 @@
CC ?= cc CC ?= cc
WFLAGS ?= -Wall \ CFLAGS ?= -O2 \
-pipe \
-fstack-protector-strong \
-Wall \
-Wextra \ -Wextra \
-Wmissing-declarations \ -Wmissing-declarations \
-pedantic -pedantic
SQLCFLAGS ?= $(shell mysql_config --cflags) LDFLAGS ?= -lcrypto -lssl \
SQLLDFLAGS += $(shell mysql_config --libs) -lpthread \
ifndef CFLAGS -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
OLEVEL ?= -O2 CFLAGS += $(shell mysql_config --cflags)
CFLAGS += -pipe \ LDFLAGS += $(shell mysql_config --libs)
-fstack-protector-strong \
$(OLEVEL) $(WFLAGS)
endif
# Use this to store compile flags and debug info. # Use this to store compile flags and debug info.
# You may simply check the flags later with: # You may simply check the flags later with:
@@ -19,11 +19,6 @@ ifeq ($(DEBUG), yes)
CFLAGS += -frecord-gcc-switches -g CFLAGS += -frecord-gcc-switches -g
endif endif
ifndef LDFLAGS
LDFLAGS = -O1 -lcrypto -lssl -lpthread
LDFLAGS += -Wl,-z,relro,-z,now
endif
SRCDIR = src SRCDIR = src
OBJDIR = obj OBJDIR = obj
BUILDDIR = build BUILDDIR = build
@@ -36,18 +31,18 @@ INSTALLDIR := $(DESTDIR)/usr/bin
$(BUILDDIR)/$(EXECUTABLE): $(OBJECTS) $(BUILDDIR)/$(EXECUTABLE): $(OBJECTS)
ifeq ($(VERBOSE), yes) ifeq ($(VERBOSE), yes)
$(CC) $(SQLLDFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ $(CC) $(OBJECTS) $(LDFLAGS) -o $@
else else
@echo ' LD $@' @echo ' LD $@'
@$(CC) $(SQLLDFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ @$(CC) $(OBJECTS) $(LDFLAGS) -o $@
endif endif
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c $(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
ifeq ($(VERBOSE), yes) ifeq ($(VERBOSE), yes)
$(CC) $(CFLAGS) $(SQLCFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
else else
@echo ' CC $<' @echo ' CC $<'
@$(CC) $(CFLAGS) $(SQLCFLAGS) -c $< -o $@ @$(CC) $(CFLAGS) -c $< -o $@
endif endif
clean: clean: