aboutsummaryrefslogtreecommitdiffstats
path: root/mk/lang-c.mk
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-10 02:27:59 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-10 02:27:59 +0100
commit544831854014d160b8f9100d6442219da90aacea (patch)
treee8565f3cedb81479b0526799fd054a96ac1874cb /mk/lang-c.mk
parentm (diff)
downloadscrotty-544831854014d160b8f9100d6442219da90aacea.tar.gz
scrotty-544831854014d160b8f9100d6442219da90aacea.tar.bz2
scrotty-544831854014d160b8f9100d6442219da90aacea.tar.xz
a bunch of stuff...
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r--mk/lang-c.mk32
1 files changed, 20 insertions, 12 deletions
diff --git a/mk/lang-c.mk b/mk/lang-c.mk
index 9d5dc8d..83e305b 100644
--- a/mk/lang-c.mk
+++ b/mk/lang-c.mk
@@ -34,7 +34,7 @@
# should be the basenames. For each command
# you should be the variable _OBJ_$(COMMAND)
# that lists all objects files (without the
-# suffix and without the obj/ prefix) that
+# suffix and without the aux/ prefix) that
# are required to build the command.
@@ -60,12 +60,12 @@ endif
# BUILD VARIABLES:
# Optimisation settings for C code compilation.
-ifdef DEBUG
-OPTIMISE = -Og -g
+ifndef DEBUG
+OPTIMISE = -O2 -g
endif
ifndef DEBUG
-ifndef OPTIMISE
-OPTIMISE = -O2
+ifdef OPTIMISE
+OPTIMISE = -Og -g
endif
endif
@@ -73,6 +73,10 @@ endif
ifdef _PEDANTIC
_PEDANTIC = -pedantic
endif
+ifndef DEBUG
+WARN = -Wall
+endif
+ifdef DEBUG
ifdef __USING_GCC
WARN = -Wall -Wextra $(_PEDANTIC) -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \
-Wtrampolines -Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
@@ -89,6 +93,7 @@ endif
ifndef __USING_GCC
WARN = -Wall -Wextra $(_PEDANTIC)
endif
+endif
# Support for internationalisation?
ifndef WITHOUT_GETTEXT
@@ -102,10 +107,13 @@ _CPPFLAGS += $(foreach D,$(_ALL_DIRS),-D'$(D)="$($(D))"')
# MORE HELP VARIABLES:
# Compilation and linking flags, and command.
-__CC = $(CC) -std=$(_C_STD) $(OPTIMISE) $(WARN) $(_CPPFLAGS) $(_CFLAGS) -c
-__LD = $(CC) -std=$(_C_STD) $(OPTIMISE) $(WARN) $(_LDFLAGS)
-__CC_POST = $(CPPFLAGS) $(CFLAGS)
-__LD_POST = $(LDFLAGS)
+CPPFLAGS = $(_CPPFLAGS)
+CFLAGS = $(OPTIMISE) $(WARN) $(_CFLAGS)
+LDFLAGS = $(OPTIMISE) $(WARN) $(_LDFLAGS)
+__CC = $(CC) -std=$(_C_STD) -c
+__LD = $(CC) -std=$(_C_STD)
+__CC_POST = $(CPPFLAGS) $(CFLAGS) $(EXTRA_CPPFLAGS) $(EXTRA_CFLAGS)
+__LD_POST = $(LDFLAGS) $(EXTRA_LDFLAGS)
# Header files.
__H =
@@ -133,9 +141,9 @@ endif
cmd-c: $(foreach B,$(_BIN),bin/$(B))
# Compile a C file into an object file.
-obj/%.o: src/%.c $(__H)
+aux/%.o: $(v)src/%.c $(foreach H,$(__H),$(v)$(H))
@$(PRINTF_INFO) '\e[00;01;31mCC\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell dirname $@)
+ @$(MKDIR) -p $(shell $(DIRNAME) $@)
$(Q)$(__CC) -o $@ $< $(__CC_POST) #$Z
@$(ECHO_EMPTY)
@@ -148,7 +156,7 @@ bin/%:
@$(ECHO_EMPTY)
# Dependencies for the rule above.
-$(foreach B,$(_BIN),$(foreach O,$(_OBJ_$(B)),bin/$(B): obj/$(O).o\
+$(foreach B,$(_BIN),$(foreach O,$(_OBJ_$(B)),bin/$(B): aux/$(O).o\
))