~rcr/rirc

3677744e47d9547597f5f28747614cb8d5437b8c — Richard Robbins 2 months ago 3847d59
fix debug build linker flags
2 files changed, 20 insertions(+), 15 deletions(-)

M Makefile
M lib/mbedtls.Makefile
M Makefile => Makefile +18 -13
@@ 18,12 18,17 @@ CFLAGS += -DNDEBUG

CFLAGS_DEBUG += -O0 -g3 -Wall -Wextra -Werror

RIRC_CFLAGS += -std=c11 -I. -DVERSION=\"$(VERSION)\"
RIRC_CFLAGS += -D_POSIX_C_SOURCE=200809L
RIRC_CFLAGS += -D_DARWIN_C_SOURCE
CLFAGS_RIRC += -std=c11 -I. -DVERSION=\"$(VERSION)\"
CLFAGS_RIRC += -D_POSIX_C_SOURCE=200809L
CLFAGS_RIRC += -D_DARWIN_C_SOURCE

LDFLAGS_RIRC += -lpthread

LDFLAGS ?= -flto
LDFLAGS += -lpthread
LDFLAGS += $(LDFLAGS_RIRC)

LDFLAGS_DEBUG ?=
LDFLAGS_DEBUG += $(LDFLAGS_RIRC)

SRC       := $(shell find $(PATH_SRC) -name '*.c' | sort)
SRC_GPERF := $(patsubst %, %.out, $(shell find $(PATH_SRC) -name '*.gperf'))


@@ 39,24 44,24 @@ rirc: $(RIRC_LIBS) $(SRC_GPERF) $(OBJS_R)
	@$(CC) $(LDFLAGS) -o $@ $(OBJS_R) $(RIRC_LIBS)

rirc.debug: $(RIRC_LIBS) $(SRC_GPERF) $(OBJS_D)
	@echo "$(CC) $(LDFLAGS) $@"
	@$(CC) $(LDFLAGS) -o $@ $(OBJS_D) $(RIRC_LIBS)
	@echo "$(CC) $(LDFLAGS_DEBUG) $@"
	@$(CC) $(LDFLAGS_DEBUG) -o $@ $(OBJS_D) $(RIRC_LIBS)

$(PATH_BUILD)/%.o: $(PATH_SRC)/%.c $(CONFIG) | $(PATH_BUILD)
	@echo "$(CC) $(CFLAGS) $<"
	@$(CPP) $(CFLAGS) $(RIRC_CFLAGS) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
	@$(CC)  $(CFLAGS) $(RIRC_CFLAGS) -c -o $@ $<
	@$(CPP) $(CFLAGS) $(CLFAGS_RIRC) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
	@$(CC)  $(CFLAGS) $(CLFAGS_RIRC) -c -o $@ $<

$(PATH_BUILD)/%.db.o: $(PATH_SRC)/%.c $(CONFIG) | $(PATH_BUILD)
	@echo "$(CC) $(CFLAGS_DEBUG) $<"
	@$(CPP) $(CFLAGS_DEBUG) $(RIRC_CFLAGS) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
	@$(CC)  $(CFLAGS_DEBUG) $(RIRC_CFLAGS) -c -o $@ $<
	@$(CPP) $(CFLAGS_DEBUG) $(CLFAGS_RIRC) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
	@$(CC)  $(CFLAGS_DEBUG) $(CLFAGS_RIRC) -c -o $@ $<

$(PATH_BUILD)/%.t: $(PATH_TEST)/%.c $(SRC_GPERF) $(CONFIG) | $(PATH_BUILD)
	@rm -f $(@:.t=.td)
	@$(CPP) $(CFLAGS_DEBUG) $(RIRC_CFLAGS) -MM -MP -MT $@ -MF $(@:.t=.t.d) $<
	@$(CC)  $(CFLAGS_DEBUG) $(RIRC_CFLAGS) -c -o $(@:.t=.t.o) $<
	@$(CC)  $(CFLAGS_DEBUG) $(RIRC_CFLAGS) -o $@ $(@:.t=.t.o)
	@$(CPP) $(CFLAGS_DEBUG) $(CLFAGS_RIRC) -MM -MP -MT $@ -MF $(@:.t=.t.d) $<
	@$(CC)  $(CFLAGS_DEBUG) $(CLFAGS_RIRC) -c -o $(@:.t=.t.o) $<
	@$(CC)  $(CFLAGS_DEBUG) $(CLFAGS_RIRC) -o $@ $(@:.t=.t.o)
	@./$@ || mv $@ $(@:.t=.td)

$(PATH_BUILD):

M lib/mbedtls.Makefile => lib/mbedtls.Makefile +2 -2
@@ 30,8 30,8 @@ MBEDTLS_SHA_FILE  := 'echo "$(MBEDTLS_VER_SHA)  $(MBEDTLS_TAR)" > $(MBEDTLS_SHA)
MBEDTLS_SHA_CHECK := 'shasum -c $(MBEDTLS_SHA)'
endif

RIRC_CFLAGS += -I$(MBEDTLS_SRC)/include/
RIRC_CFLAGS += -DMBEDTLS_CONFIG_FILE='<$(MBEDTLS_CFG)>'
CLFAGS_RIRC += -I$(MBEDTLS_SRC)/include/
CLFAGS_RIRC += -DMBEDTLS_CONFIG_FILE='<$(MBEDTLS_CFG)>'

RIRC_LIBS += $(MBEDTLS_LIBS)