Skip to content

Commit

Permalink
Makefile respect user's SERVER_CFLAGS and OPT
Browse files Browse the repository at this point in the history
Signed-off-by: Roshan Khatri <[email protected]>
  • Loading branch information
roshkhatri committed Mar 27, 2024
1 parent 11ddd8b commit fe951d3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh')
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
CLANG := $(findstring clang,$(shell sh -c '$(CC) --version | head -1'))

# Optimization flags. To override, the OPTIMIZATION variable can be passed, but
# some automatic defaults are added to it. To specify optimization flags
# explicitly without any defaults added, pass the OPT variable instead.
OPTIMIZATION?=-O3
ifeq ($(OPTIMIZATION),-O3)
ifeq (clang,$(CLANG))
SERVER_CFLAGS+=-flto
OPTIMIZATION+=-flto
else
SERVER_CFLAGS+=-flto=auto
OPTIMIZATION+=-flto=auto
endif
SERVER_LDFLAGS+=-O3 -flto
endif
ifneq ($(OPTIMIZATION),-O0)
SERVER_CFLAGS+=-fno-omit-frame-pointer
OPTIMIZATION+=-fno-omit-frame-pointer
endif
DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram fpconv
NODEPS:=clean distclean
Expand Down Expand Up @@ -120,7 +123,7 @@ endif
-include .make-settings

FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(SERVER_CFLAGS)
FINAL_LDFLAGS=$(LDFLAGS) $(SERVER_LDFLAGS) $(DEBUG)
FINAL_LDFLAGS=$(LDFLAGS) $(OPT) $(SERVER_LDFLAGS) $(DEBUG)
FINAL_LIBS=-lm
DEBUG=-g -ggdb

Expand Down

0 comments on commit fe951d3

Please sign in to comment.