firmware: small makefile reorg

This commit is contained in:
Ingo Albrecht 2010-07-19 10:02:43 +02:00
parent 5305fad710
commit 5182fff914
2 changed files with 34 additions and 29 deletions

View File

@ -1,16 +1,12 @@
# Global include path
INCLUDES=-Iinclude/ -I../../../include -I../../shared/libosmocore/include
# Various objects that are currently linked into all applications
FLASH_OBJS=flash/cfi_flash.o
DISPLAY_OBJS=display/font_r8x8.o display/font_r8x8_horiz.o display/st7558.o display/ssd1783.o display/display.o
ABB_OBJS=abb/twl3025.o
RF_OBJS=rf/trf6151.o
# List of all supported boards
# List of all supported boards (meant to be overridden on command line)
BOARDS?=compal_e88 compal_e99 gta0x
# List of all applications (meant to be overridden on command line)
APPLICATIONS?=hello_world compal_dsp_dump layer1 loader simtest
# TI Calypso
calypso_COMMON_OBJS=board/common/calypso_uart.o board/common/calypso_pwl.o
@ -54,13 +50,20 @@ e99loader_OBJS=board/compal/header.o
e99flash_LDS=board/compal_e99/flash.lds
# List of all applications (add yours here!)
APPLICATIONS=hello_world compal_dsp_dump layer1 loader simtest
# Global include path
INCLUDES=-Iinclude/ -I../../../include -I../../shared/libosmocore/include
# Things that go in all applications
# Various objects that are currently linked into all applications
FLASH_OBJS=flash/cfi_flash.o
DISPLAY_OBJS=display/font_r8x8.o display/font_r8x8_horiz.o display/st7558.o display/ssd1783.o display/display.o
ABB_OBJS=abb/twl3025.o
RF_OBJS=rf/trf6151.o
# Objects that go in all applications
ANY_APP_OBJS+=$(ABB_OBJS) $(RF_OBJS) $(DISPLAY_OBJS) $(FLASH_OBJS)
ANY_APP_LIBS+=calypso/libcalypso.a layer1/liblayer1.a lib/libmini.a comm/libcomm.a ../../shared/libosmocore/build-target/src/.libs/libosmocore.a
# Libraries are defined in subdirectories
-include calypso/Makefile
-include layer1/Makefile

View File

@ -15,13 +15,12 @@ CFLAGS=-mcpu=arm7tdmi $(INCLUDES)
CFLAGS += -Wall -Wextra -Wcast-align -Wimplicit -Wunused
CFLAGS += -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wnested-externs
CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
CFLAGS += -Os -ffunction-sections
CFLAGS += -g$(DEBUGF)
# some older toolchains don't support this, ignore it for now
#ASFLAGS=-Wa,-adhlns=$(<:.S=.lst),--g$(DEBUGF) $(INCLUDES) -D__ASSEMBLY__
ASFLAGS=-Wa,-adhlns=$(<:.S=.lst) $(INCLUDES) -D__ASSEMBLY__
#ASFLAGS=--g$(DEBUGF) $(INCLUDES) -D__ASSEMBLY__
ASFLAGS=$(INCLUDES) -D__ASSEMBLY__
LDFLAGS = -nostartfiles -nostdlib -nodefaultlibs --gc-sections --cref
@ -38,9 +37,9 @@ CFLAGS += -DGIT_REVISION=\"$(GIT_REVISION)\"
#### GLOBAL DATA ####
ALL_OBJS=
ALL_DEPS=
ALL_LSTS=$(ALL_OBJS:.o=.lst)
ALL_DEPS=$(ALL_OBJS:.o=.p)
#### APPLICATION DATA ####
@ -63,9 +62,6 @@ default: all
#### APPLICATION RULES ####
ALL_OBJS+=$(ANY_APP_OBJS)
ALL_DEPS+=$(ANY_APP_OBJS:.o=.p)
# template for application rules
define APPLICATION_BOARD_ENVIRONMENT_template
@ -77,6 +73,10 @@ $(1)_$(2)_$(3)_LIBS := $(ANY_APP_LIBS)
board/$(2)/$(1).$(3).manifest.o: board/manifest.c
$(CROSS_COMPILE)$(CC) $(CFLAGS) -DAPPLICATION=\"$(1)\" -DBOARD=\"$(2)\" -DENVIRONMENT=\"$(3)\" -c -o $$@ $$<
# generate dummy dependencies for manifest
board/$(2)/$(1).$(3).manifest.p: board/manifest.c
@touch board/$(2)/$(1).$(3).manifest.p
# add manifest object to object list
$(1)_$(2)_$(3)_OBJS+=board/$(2)/$(1).$(3).manifest.o $$($(3)_OBJS)
@ -91,26 +91,24 @@ board/$(2)/$(1).$(3).size: board/$(2)/$(1).$(3).elf
$(CROSS_COMPILE)$(SIZE) board/$(2)/$(1).$(3).elf | tee board/$(2)/$(1).$(3).size
ALL_APPS+=board/$(2)/$(1).$(3).elf
ALL_OBJS+=$$($(1)_$(2)_$(3)_OBJS)
ALL_OBJS+=board/$(2)/$(1).$(3).manifest.o
endef
define BOARD_template
ALL_OBJS+=$$($(1)_OBJS)
endef
define BOARD_ENVIRONMENT_template
ALL_OBJS+=$$($(1)_OBJS)
endef
define APPLICATION_template
$(1)_SRCS_REL=$$(patsubst %,$$($(1)_DIR)/%,$$($(1)_SRCS))
$(1)_OBJS:=$$($(1)_SRCS_REL:.c=.o)
$(1)_OBJS:=$$($(1)_OBJS:.S=.o)
ALL_OBJS+=$$($(1)_OBJS) apps/$(1)/main.o
ALL_DEPS+=$$($(1)_OBJS:.o=.p) apps/$(1)/main.p
endef
# define rules for all defined applications
@ -120,12 +118,17 @@ $(foreach app,$(APPLICATIONS), \
$(eval $(call APPLICATION_BOARD_ENVIRONMENT_template,$(app),$(brd),$(env))))))
$(foreach brd,$(BOARDS), \
$(eval $(call BOARD_template,$(brd))))
$(eval $(call BOARD_template,$(brd)) \
$(foreach env,$($(brd)_ENVIRONMENTS), \
$(eval $(call BOARD_ENVIRONMENT_template,$(env))))))
$(foreach app,$(APPLICATIONS), \
$(eval $(call APPLICATION_template,$(app))))
# add common things to global lists
ALL_OBJS+=$(ANY_APP_OBJS)
#### LIBRARY RULES ####
# template for library rules
@ -141,7 +144,6 @@ $$($(1)_DIR)/lib$(1).a: $$($(1)_OBJS)
ALL_LIBS+=$$($(1)_DIR)/lib$(1).a
ALL_OBJS+=$$($(1)_OBJS)
ALL_DEPS+=$$($(1)_OBJS:.o=.p)
endef
@ -169,10 +171,10 @@ depend: $(ALL_DEPS)
@sed 's|.*\.o:|$(@:.p=.o): |g' < $*.d > $@; rm -f $*.d; [ -s $@ ] || rm -f $@
%.o: %.c
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $<
$(CROSS_COMPILE)$(CC) $(CFLAGS) -Wa,-adhlns=$(@:.o=.lst) -c -o $@ $<
%.o: %.S
$(CROSS_COMPILE)$(CC) $(ASFLAGS) -c -o $@ $<
$(CROSS_COMPILE)$(CC) $(ASFLAGS) -Wa,-adhlns=$(@:.o=.lst) -c -o $@ $<
%.bin: %.elf