From e86fff93bdb438e61f27e58df0f2b3051666b5e7 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 4 Mar 2017 13:20:37 +0100 Subject: [PATCH] Makefile: Add simple compilation rule for C MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only use C as an interface (e.g. to POSIX). Thus, we keep the rules simple and don't do any dependency tracking. Change-Id: I62b4b4e4d3ae83d5e1f1811f783b559b225746e6 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/18778 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Patrick Georgi --- Makefile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 236571364c..554558abc1 100644 --- a/Makefile +++ b/Makefile @@ -28,13 +28,15 @@ include $(libhw-dir)/Makefile.proof CC = $(CROSS_COMPILE)gcc GNATBIND = $(CROSS_COMPILE)gnatbind +CFLAGS += -Wuninitialized -Wall -Werror +CFLAGS += -pipe -g +CFLAGS += -Wstrict-aliasing -Wshadow +CFLAGS += -fno-common -fomit-frame-pointer +CFLAGS += -ffunction-sections -fdata-sections + ADAFLAGS += -gnatA -gnatec=$(libhw-dir)/gnat.adc ADAFLAGS += -gnatg -gnatp -ADAFLAGS += -Wuninitialized -Wall -Werror -ADAFLAGS += -pipe -g -ADAFLAGS += -Wstrict-aliasing -Wshadow -ADAFLAGS += -fno-common -fomit-frame-pointer -ADAFLAGS += -ffunction-sections -fdata-sections +ADAFLAGS += $(CFLAGS) # Ada warning options: # # a Activate most optional warnings. @@ -97,9 +99,10 @@ $(foreach dep,$($(name)-deplibs), \ src-to-obj = \ $(addprefix $(obj)/,\ $(patsubst $(obj)/%,%, \ + $(patsubst %.c,%.o,\ $(patsubst %.ads,%.o,\ $(patsubst %.adb,%.o,\ - $(2))))) + $(2)))))) # Converts one or more source file paths to the corresponding build/ paths # of their Ada library information (.ali) files. @@ -194,7 +197,7 @@ add_ada_deps = \ $(call src-to-obj,,$(1)): $(1) \ $(call create_ada_deps,$(call src-to-ali,,$(1))) -# Writes a compilation rule for a source type +# Writes a compilation rule for Ada sources # $1 source type (ads, adb) # $2 source files (including the colon) # $3 obj path prefix (including the trailing slash) @@ -235,6 +238,11 @@ $(obj)/b__lib$(name).adb: $($(name)-alis) $(eval $(call add_ada_rule,adb,$(obj)/b__lib$(name).o:,)) $(name)-objs += $(obj)/b__lib$(name).o +# Compilation rule for C sources +$(call src-to-obj,,$(filter %.c,$($(name)-srcs))): $(obj)/%.o: %.c + @printf " COMPILE $(subst $(obj)/,,$@)\n" + $(CC) $(CFLAGS) -c -o $@ $< + $(shell mkdir -p $(alldirs)) $(name)-install-srcs = $(sort \