build.mk (2260B)
1 ## Copyright 2014 Brian Swetland <swetland@frotz.net> 2 ## 3 ## Licensed under the Apache License, Version 2.0 (the "License"); 4 ## you may not use this file except in compliance with the License. 5 ## You may obtain a copy of the License at 6 ## 7 ## http://www.apache.org/licenses/LICENSE-2.0 8 ## 9 ## Unless required by applicable law or agreed to in writing, software 10 ## distributed under the License is distributed on an "AS IS" BASIS, 11 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 ## See the License for the specific language governing permissions and 13 ## limitations under the License. 14 15 # configuration header generation heavily inspired by travisg's lk build system 16 17 # $(call chip,name,arch,rambase,ramsize,rombase,romsize,linkscript) 18 define chip 19 $(eval CHIP_$1_ARCH := $2) \ 20 $(eval CHIP_$1_RAMBASE := $3) \ 21 $(eval CHIP_$1_RAMSIZE := $4) \ 22 $(eval CHIP_$1_ROMBASE := $5) \ 23 $(eval CHIP_$1_ROMSIZE := $6) \ 24 $(eval CHIP_$1_LINKSCRIPT := build/generic-$7.ld) \ 25 $(eval CHIP_$1_DEPS := $(lastword $(MAKEFILE_LIST))) 26 endef 27 28 MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 29 30 QUIET ?= @ 31 32 SPACE := 33 SPACE += 34 COMMA := , 35 36 define underscorify 37 $(subst /,_,$(subst \,_,$(subst .,_,$(subst -,_,$1)))) 38 endef 39 40 define toupper 41 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))) 42 endef 43 44 # (call make-config-header,outfile,configlist) 45 define make-config-header 46 echo "/* Machine Generated File - Do Not Edit */" >> $1.tmp ; \ 47 echo "#ifndef __$(call underscorify,$1)" >> $1.tmp ; \ 48 echo "#define __$(call underscorify,$1)" >> $1.tmp ; \ 49 $(foreach def,$2,echo "#define CONFIG_$(subst =, ,$(call underscorify,$(call toupper,$(def))))" >> $1.tmp ;) \ 50 echo "#endif" >> $1.tmp ; \ 51 mv $1.tmp $1 52 endef 53 54 start-module-mk = $(eval M_MAKEFILE := $(lastword $(MAKEFILE_LIST))) 55 build-target-agent = $(eval include build/target-agent.mk) 56 build-target-executable = $(eval include build/target-executable.mk) 57 build-host-executable = $(eval include build/host-executable.mk) 58