Commit 177a2a14 authored by Marek Vavruša's avatar Marek Vavruša

build: `make CFLAGS=...` and `CFLAGS=... make` are identical

same for LDFLAGS. this fixes common problem where CFLAGS after make
was evaluated as a make variable and replaced the default, while
before as env variable and was prepended to the default string.
now they both behave as an env. variable
parent 3e7844f8
......@@ -11,7 +11,7 @@ doc: doc-html
# Options
ifdef COVERAGE
CFLAGS += --coverage
BUILD_CFLAGS += --coverage
endif
# Dependencies
......@@ -38,7 +38,7 @@ ifneq (,$(findstring luajit, $(lua_LIBS)))
endif
endif
CFLAGS += $(libknot_CFLAGS) $(libuv_CFLAGS) $(cmocka_CFLAGS) $(python_CFLAGS) $(lua_CFLAGS) $(libdnssec_CFLAGS)
BUILD_CFLAGS += $(libknot_CFLAGS) $(libuv_CFLAGS) $(cmocka_CFLAGS) $(python_CFLAGS) $(lua_CFLAGS) $(libdnssec_CFLAGS)
# Sub-targets
include help.mk
......
......@@ -12,8 +12,9 @@ MODULEDIR := $(LIBDIR)/kdns_modules
# Tools
CC ?= cc
CFLAGS += -std=c99 -D_GNU_SOURCE -fPIC -Wall -I$(abspath .) -I$(abspath lib/generic) -I$(abspath contrib)
CFLAGS += -DPACKAGE_VERSION="\"$(MAJOR).$(MINOR)\"" -DPREFIX="\"$(PREFIX)\"" -DMODULEDIR="\"$(MODULEDIR)\""
BUILD_LDFLAGS += $(LDFLAGS)
BUILD_CFLAGS := $(CFLAGS) -std=c99 -D_GNU_SOURCE -fPIC -Wall -I$(abspath .) -I$(abspath lib/generic) -I$(abspath contrib)
BUILD_CFLAGS += -DPACKAGE_VERSION="\"$(MAJOR).$(MINOR)\"" -DPREFIX="\"$(PREFIX)\"" -DMODULEDIR="\"$(MODULEDIR)\""
RM := rm -f
LN := ln -s
XXD := ./scripts/embed.sh
......
info:
$(info )
$(info Target: Knot DNS Resolver $(MAJOR).$(MINOR).$(PATCH)-$(PLATFORM))
$(info Compiler: $(CC) $(CFLAGS))
$(info Linker: $(LD) $(LDFLAGS))
$(info Compiler: $(CC) $(BUILD_CFLAGS))
$(info Linker: $(LD) $(BUILD_LDFLAGS))
$(info PREFIX: $(PREFIX))
$(info BINDIR: $(BINDIR))
$(info LIBDIR: $(LIBDIR))
......
......@@ -58,11 +58,11 @@ $(1)_OBJS := $(addprefix $(2)/_obj/,_cgo_defun.c _cgo_export.c $(subst /,_,$(2))
$(1)_GOBJS := $(addprefix $(2)/_obj/,_cgo_gotypes.go $(subst /,_,$(2))_$(1).cgo1.go)
$(2)/_obj/_cgo_export.h: $$($(1)_SOURCES)
@$(INSTALL) -d $(2)/_obj
$(call quiet,CGO,$$^) -gccgo=true -objdir=$(2)/_obj -- $(CFLAGS) $$^
$(call quiet,CGO,$$^) -gccgo=true -objdir=$(2)/_obj -- $(BUILD_CFLAGS) $$^
$(2)/$(1).o: $(2)/_obj/_cgo_export.h
$(call quiet,GCCGO,$$@) -I$(2)/_obj -c -fPIC $$($(1)_GOBJS) -o $$@
$(2)/$(1)$(LIBEXT): $(2)/$(1).o $$($(1)_DEPEND)
$(call quiet,GCCGO,$$@) -g -fPIC $(CFLAGS) -I$(2)/_obj $(2)/$(1).o $$($(1)_OBJS) -o $$@ -$(LIBTYPE) -lgcc -lgo $$($(1)_LIBS)
$(call quiet,GCCGO,$$@) -g -fPIC $(BUILD_CFLAGS) -I$(2)/_obj $(2)/$(1).o $$($(1)_OBJS) -o $$@ -$(LIBTYPE) -lgcc -lgo $$($(1)_LIBS)
$(1)-clean:
$(RM) -r $(2)/_obj $(2)/$(1)$(LIBEXT)
$(1)-install: $(2)/$(1)$(LIBEXT)
......
......@@ -39,7 +39,7 @@ else
endif
%.o: %.c
$(call quiet,CC,$<) $(CFLAGS) -MMD -MP -c $< -o $@
$(call quiet,CC,$<) $(BUILD_CFLAGS) -MMD -MP -c $< -o $@
# Make objects and depends (name)
define make_objs
......@@ -56,7 +56,7 @@ $(2)/$(1)$(3): $$($(1)_OBJ) $$($(1)_DEPEND)
ifeq ($(4),-$(ARTYPE))
$(call quiet,AR,$$@) rcs $$@ $$($(1)_OBJ)
else
$(call quiet,CCLD,$$@) $(CFLAGS) $$($(1)_OBJ) -o $$@ $(4) $$($(1)_LIBS) $(LDFLAGS)
$(call quiet,CCLD,$$@) $(BUILD_CFLAGS) $$($(1)_OBJ) -o $$@ $(4) $$($(1)_LIBS) $(BUILD_LDFLAGS)
endif
$(1)-clean:
$(RM) $$($(1)_OBJ) $$($(1)_DEP) $(2)/$(1)$(3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment