1b0104773SPascal Brand# Input 2b0104773SPascal Brand# 3b0104773SPascal Brand# The output from mk/sub.mk 4b0104773SPascal Brand# base-prefix 5b0104773SPascal Brand# 6b0104773SPascal Brand# Output 7b0104773SPascal Brand# 8b0104773SPascal Brand# set objs 9b0104773SPascal Brand# update cleanfiles 10b0104773SPascal Brand# 11b0104773SPascal Brand# Generates explicit rules for all objs 12b0104773SPascal Brand 13b0104773SPascal Brandobjs := 14b0104773SPascal Brand 15b0104773SPascal Brand# Disable all builtin rules 16b0104773SPascal Brand.SUFFIXES: 17b0104773SPascal Brand 18b0104773SPascal Brandcomp-cflags$(sm) = -std=gnu99 19b0104773SPascal Brandcomp-aflags$(sm) = 20b0104773SPascal Brandcomp-cppflags$(sm) = 21b0104773SPascal Brand 22b0104773SPascal Brandifndef NOWERROR 23b0104773SPascal Brandcomp-cflags$(sm) += -Werror 24b0104773SPascal Brandendif 25b0104773SPascal Brandcomp-cflags$(sm) += -fdiagnostics-show-option 26b0104773SPascal Brand 27b0104773SPascal Brandcomp-cflags-warns-high = \ 28b0104773SPascal Brand -Wall -Wcast-align \ 29b0104773SPascal Brand -Werror-implicit-function-declaration -Wextra -Wfloat-equal \ 30b0104773SPascal Brand -Wformat-nonliteral -Wformat-security -Wformat=2 -Winit-self \ 31b0104773SPascal Brand -Wmissing-declarations -Wmissing-format-attribute \ 32b0104773SPascal Brand -Wmissing-include-dirs -Wmissing-noreturn \ 33b0104773SPascal Brand -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ 34b0104773SPascal Brand -Wshadow -Wstrict-prototypes -Wswitch-default \ 35b0104773SPascal Brand -Wwrite-strings \ 36b0104773SPascal Brand -Wno-missing-field-initializers -Wno-format-zero-length 37b0104773SPascal Brandcomp-cflags-warns-medium = \ 38b0104773SPascal Brand -Waggregate-return -Wredundant-decls 39b0104773SPascal Brandcomp-cflags-warns-low = \ 40b0104773SPascal Brand -Winline \ 41b0104773SPascal Brand -Wold-style-definition -Wstrict-aliasing=2 \ 42b0104773SPascal Brand -Wundef -pedantic \ 43b0104773SPascal Brand -Wdeclaration-after-statement 44b0104773SPascal Brand 45b0104773SPascal Brandcomp-cflags-warns-1:= $(comp-cflags-warns-high) 46b0104773SPascal Brandcomp-cflags-warns-2:= $(comp-cflags-warns-1) $(comp-cflags-warns-medium) 47b0104773SPascal Brandcomp-cflags-warns-3:= $(comp-cflags-warns-2) $(comp-cflags-warns-low) 48b0104773SPascal Brand 49b0104773SPascal BrandWARNS ?= 3 50b0104773SPascal Brand 51b0104773SPascal Brandcomp-cflags$(sm) += $(comp-cflags-warns-$(WARNS)) 52b0104773SPascal Brand 53b0104773SPascal Brand.PHONY: FORCE 54b0104773SPascal BrandFORCE: 55b0104773SPascal Brand 56b0104773SPascal Branddefine process_srcs 57b0104773SPascal Brandobjs += $2 58b0104773SPascal Brandcomp-dep-$2 := $$(dir $2).$$(notdir $2).d 59b0104773SPascal Brandcomp-cmd-file-$2:= $$(dir $2).$$(notdir $2).cmd 60b0104773SPascal Brandcomp-sm-$2 := $(sm) 61b0104773SPascal Brand 62b0104773SPascal Brandcleanfiles := $$(cleanfiles) $$(comp-dep-$2) $$(comp-cmd-file-$2) $2 63b0104773SPascal Brand 64b0104773SPascal Brandifeq ($$(filter %.c,$1),$1) 65b0104773SPascal Brandcomp-flags-$2 = $$(filter-out $$(CFLAGS_REMOVE) $$(cflags-remove) \ 66b0104773SPascal Brand $$(cflags-remove-$2), \ 67b0104773SPascal Brand $$(CFLAGS) $$(CFLAGS_WARNS) \ 68b0104773SPascal Brand $$(comp-cflags$$(comp-sm-$2)) $$(cflags$$(comp-sm-$2)) \ 69b0104773SPascal Brand $$(cflags-$2)) 70b0104773SPascal Brandelse ifeq ($$(filter %.S,$1),$1) 71b0104773SPascal Brandcomp-flags-$2 = -DASM=1 $$(filter-out $$(AFLAGS_REMOVE) $$(aflags-remove) \ 72b0104773SPascal Brand $$(aflags-remove-$2), \ 73b0104773SPascal Brand $$(AFLAGS) $$(comp-aflags$$(comp-sm-$2)) \ 74b0104773SPascal Brand $$(aflags$$(comp-sm-$2)) $$(aflags-$2)) 75b0104773SPascal Brandelse 76b0104773SPascal Brand$$(error "Don't know what to do with $1") 77b0104773SPascal Brandendif 78b0104773SPascal Brand 79b0104773SPascal Brand 80aaac0982SJerome Forissiercomp-flags-$2 += -MD -MF $$(comp-dep-$2) -MT $$@ \ 81b0104773SPascal Brand $$(filter-out $$(CPPFLAGS_REMOVE) $$(cppflags-remove) \ 82b0104773SPascal Brand $$(cppflags-remove-$2), \ 83b0104773SPascal Brand $$(nostdinc) $$(CPPFLAGS) \ 84b0104773SPascal Brand $$(addprefix -I,$$(incdirs$$(comp-sm-$2))) \ 85b0104773SPascal Brand $$(cppflags$$(comp-sm-$2)) $$(cppflags-$2)) 86b0104773SPascal Brand 87b0104773SPascal Brandcomp-cmd-$2 = $$(CC) $$(comp-flags-$2) -c $$< -o $$@ 88b0104773SPascal Brand 89b0104773SPascal Brand-include $$(comp-cmd-file-$2) 90b0104773SPascal Brand-include $$(comp-dep-$2) 91b0104773SPascal Brand 92b0104773SPascal Brand 93b0104773SPascal Brand$2: $1 FORCE 94b0104773SPascal Brand# Check if any prerequisites are newer than the target and 95b0104773SPascal Brand# check if command line has changed 96b0104773SPascal Brand $$(if $$(strip $$? $$(filter-out $$(comp-cmd-$2), $$(old-cmd-$2)) \ 97b0104773SPascal Brand $$(filter-out $$(old-cmd-$2), $$(comp-cmd-$2))), \ 98b0104773SPascal Brand @set -e ;\ 99b0104773SPascal Brand mkdir -p $$(dir $2) ;\ 100*0047cb63SJerome Forissier echo ' CC $$@' ;\ 101b0104773SPascal Brand $(cmd-echo) $$(subst \",\\\",$$(comp-cmd-$2)) ;\ 102b0104773SPascal Brand $$(comp-cmd-$2) ;\ 103b0104773SPascal Brand echo "old-cmd-$2 := $$(subst \",\\\",$$(comp-cmd-$2))" > \ 104b0104773SPascal Brand $$(comp-cmd-file-$2) ;\ 105b0104773SPascal Brand ) 106b0104773SPascal Brand 107b0104773SPascal Brandendef 108b0104773SPascal Brand 109b0104773SPascal Brand$(foreach f, $(srcs), $(eval $(call \ 110b0104773SPascal Brand process_srcs,$(f),$(out-dir)$(base-prefix)$$(basename $f).o))) 111