diff options
author | Ingo Albrecht <prom@berlin.ccc.de> | 2010-03-07 01:41:32 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-03-07 11:47:09 +0100 |
commit | 41abd7e50055e69993d5e9c8acd9852aee51da1f (patch) | |
tree | 4f65fbe8f2f7be78262cf664be4a09933b8e19b3 /src/target | |
parent | 60bbc89c30cb0cfd88ad46640f50e35d197a0053 (diff) |
New build system.
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/firmware/.gitignore | 1 | ||||
-rw-r--r-- | src/target/firmware/Makefile | 71 | ||||
-rw-r--r-- | src/target/firmware/Makefile.inc | 122 | ||||
-rw-r--r-- | src/target/firmware/calypso/Makefile | 19 | ||||
-rw-r--r-- | src/target/firmware/comm/Makefile | 27 | ||||
-rw-r--r-- | src/target/firmware/layer1/Makefile | 29 | ||||
-rw-r--r-- | src/target/firmware/lib/Makefile | 27 |
7 files changed, 153 insertions, 143 deletions
diff --git a/src/target/firmware/.gitignore b/src/target/firmware/.gitignore index 040dc838..272f75d4 100644 --- a/src/target/firmware/.gitignore +++ b/src/target/firmware/.gitignore @@ -1,4 +1,5 @@ *.o +*.P *.a *.lst *.bin diff --git a/src/target/firmware/Makefile b/src/target/firmware/Makefile index 0e5ff2cc..06c4df40 100644 --- a/src/target/firmware/Makefile +++ b/src/target/firmware/Makefile @@ -1,69 +1,30 @@ + +# Global include path INCLUDES=-Iinclude/ -I../../../include --include Makefile.inc -# individual list of object files, they should probably become libraries +# Various objects that are currently linked into all applications FLASH_OBJS=flash/cfi_flash.o DISPLAY_OBJS=display/font_r8x8.o display/st7558.o ABB_OBJS=abb/twl3025.o RF_OBJS=rf/trf6151.o BOARD_C123_OBJS=board/common/rffe_compal_dualband.o board/compal_e88/init.o + +# Board- and environment-specific startup code and linker script START=board/common/compal_ramload_start.S LDS=board/common/compal_ramload.lds # The objects that we want to link with every application -OBJS=start.o $(ABB_OBJS) $(RF_OBJS) $(DISPLAY_OBJS) $(FLASH_OBJS) $(BOARD_C123_OBJS) - -# The libraries that we want to link with every application -LIBS=calypso/libcalypso.a layer1/liblayer1.a lib/libmini.a comm/libcomm.a - -# The list of applications we ant to build. Please add your apps here! -APPS=hello_world l1test compal_dump compal_dsp_dump layer1 - -APP_BINS=$(APPS:=.bin) -APP_ELFS=$(APPS:=.elf) -APP_OBJS=$(patsubst %,apps/%/main.o, $(APPS)) -APP_SIZES=$(APP_ELFS:.elf=.size) - -LST=$(OBJS:.o=.lst) $(APP_OBJS:.o=.lst) $(START:.S=.lst) - -all: $(APP_BINS) $(APP_ELFS) $(APP_SIZES) +APPLICATIONS=hello_world l1test compal_dump compal_dsp_dump layer1 -start.o: $(START) - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ +# Things that go in all applications +ANY_APP_OBJS+=$(START:.S=.o) $(ABB_OBJS) $(RF_OBJS) $(DISPLAY_OBJS) $(FLASH_OBJS) $(BOARD_C123_OBJS) +ANY_APP_LIBS+=calypso/libcalypso.a layer1/liblayer1.a lib/libmini.a comm/libcomm.a -%.o: %.c - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ +# Libraries are defined in subdirectories +-include calypso/Makefile +-include layer1/Makefile +-include comm/Makefile +-include lib/Makefile -%.elf: $(OBJS) apps/%/main.o $(LIBS) - $(CROSS_COMPILE)$(LD) $(LDFLAGS) -T $(LDS) -Bstatic -Map $@.map -o $@ --start-group $^ --end-group - $(CROSS_COMPILE)$(SIZE) $@ - -%.size: %.elf - $(CROSS_COMPILE)$(SIZE) -A $^ > $@ - -%.bin: %.elf - $(CROSS_COMPILE)objcopy --gap-fill=0xff -O binary $^ $@ - -# FIXME: we don't do dependencies into the subdirectories, so we always rebuild -.PHONY: calypso/libcalypso.a -calypso/libcalypso.a: - make -C calypso all - -# FIXME: we don't do dependencies into the subdirectories, so we always rebuild -.PHONY: layer1/liblayer1.a -layer1/liblayer1.a: - make -C layer1 all - -lib/libmini.a: - make -C lib all - -# FIXME: we don't do dependencies into the subdirectories, so we always rebuild -.PHONY: comm/libcomm.a -comm/libcomm.a: - make -C comm all -clean: - make -C calypso clean - make -C layer1 clean - make -C lib clean - make -C comm clean - rm -f *.map $(OBJS) $(APP_BINS) $(APP_ELFS) $(APP_SIZES) $(LST) +# Include rules +-include Makefile.inc diff --git a/src/target/firmware/Makefile.inc b/src/target/firmware/Makefile.inc index a130cd79..a4eeb7f6 100644 --- a/src/target/firmware/Makefile.inc +++ b/src/target/firmware/Makefile.inc @@ -1,6 +1,11 @@ + +#### TOOLCHAIN CONFIGURATION #### + CROSS_COMPILE?=arm-elf- + CC=gcc LD=ld +AR=ar SIZE=size OBJCOPY=objcopy @@ -22,3 +27,120 @@ CFLAGS += -g$(DEBUGF) ASFLAGS=-Wa,-adhlns=$(<:.S=.lst) $(INCLUDES) -D__ASSEMBLY__ LDFLAGS = -nostartfiles -nostdlib -nodefaultlibs --gc-sections #-Wl,-Map=$(TARGET).map,--cref + + +#### GLOBAL DATA #### + +ALL_OBJS= +ALL_DEPS= + +#### APPLICATION DATA #### + +ALL_APPS= + +ALL_APP_TARGETS=$(ALL_APPS) $(ALL_APPS:.elf=.bin) $(ALL_APPS:.elf=.map) $(ALL_APPS:.elf=.size) + +#### LIBRARY DATA #### + +ALL_LIB_ARS= + +ALL_LIB_TARGETS=$(ALL_LIB_ARS) + + +#### DEFAULT RULE #### + +.PHONY: default +default: all + + +#### APPLICATION RULES #### + +ALL_OBJS+=$(ANY_APP_OBJS) +ALL_DEPS+=$(ANY_APP_OBJS:.o=.P) + +# template for application rules +define APPLICATION_template + +$(1)_SRCS_REL=$$(patsubst %,$$($(1)_DIR)/%,$$($(1)_SRCS)) +$(1)_OBJS:=$$($(1)_SRCS_REL:.c=.o) +$(1)_OBJS:=$$($(1)_OBJS:.S=.o) + +$(1).elf $(1).map $(1).size: apps/$(1)/main.o $(ANY_APP_OBJS) $(ANY_APP_LIBS) + $(CROSS_COMPILE)$(LD) $(LDFLAGS) -T $(LDS) -Bstatic -Map $$(@:.elf=.map) -o $$@ --start-group $$^ --end-group + $(CROSS_COMPILE)$(SIZE) $$@ | tee $(1).size + +ALL_APPS+=$(1).elf + +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 +$(foreach app,$(APPLICATIONS),$(eval $(call APPLICATION_template,$(app)))) + + +#### LIBRARY RULES #### + +# template for library rules +define LIBRARY_template + +$(1)_SRCS_REL=$$(patsubst %,$$($(1)_DIR)/%,$$($(1)_SRCS)) +$(1)_OBJS:=$$($(1)_SRCS_REL:.c=.o) +$(1)_OBJS:=$$($(1)_OBJS:.S=.o) + +$$($(1)_DIR)/lib$(1).a: $$($(1)_OBJS) + $(AR) cru $$($(1)_DIR)/lib$(1).a $$($(1)_OBJS) + +ALL_LIB_ARS+=$$($(1)_DIR)/lib$(1).a + +ALL_OBJS+=$$($(1)_OBJS) +ALL_DEPS+=$$($(1)_OBJS:.o=.P) + +endef + +# define rules for all defined libraries +$(foreach lbr,$(LIBRARIES),$(eval $(call LIBRARY_template,$(lbr)))) + + +#### TOPLEVEL RULES #### + +.PHONY: all +all: $(ALL_DEPS) $(ALL_APP_TARGETS) $(ALL_LIB_TARGETS) + +.PHONY: depend +depend: $(ALL_DEPS) + + +#### COMPILATION RULES #### + +%.P: %.c + @$(CROSS_COMPILE)$(CC) $(CFLAGS) -M -o $(*).d $(<) + @sed 's|\($*)\)\.o[ :]*|\1.o $@ : |g' < $*.d > $@; \ + rm -f $*.d; [ -s $@ ] || rm -f $@ + +%.P: %.S + @$(CROSS_COMPILE)$(CC) $(ASFLAGS) -M -o $(*).d $(<) + @sed 's|\($*)\)\.o[ :]*|\1.o $@ : |g' < $*.d > $@; \ + rm -f $*.d; [ -s $@ ] || rm -f $@ + +%.o: %.c + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ + +%.o: %.S + $(CROSS_COMPILE)$(CC) $(ASFLAGS) -c -o $@ $^ + + +%.bin: %.elf + $(CROSS_COMPILE)objcopy --gap-fill=0xff -O binary $^ $@ + + +#### CLEANUP RULES #### + +clean: + rm -f $(ALL_APP_TARGETS) $(ALL_LIB_TARGETS) $(ALL_OBJS) $(ALL_DEPS) + + +#### DEPENDENCY LOAD #### + +-include $(ALL_DEPS) diff --git a/src/target/firmware/calypso/Makefile b/src/target/firmware/calypso/Makefile index 3a230f64..ef8a6a7a 100644 --- a/src/target/firmware/calypso/Makefile +++ b/src/target/firmware/calypso/Makefile @@ -1,17 +1,4 @@ -INCLUDES=-I../include/ -I../../../../include --include ../Makefile.inc -OBJS=arm.o clock.o dma.o dsp.o du.o i2c.o irq.o rtc.o spi.o tpu.o tsp.o keypad.o misc.o timer.o backlight.o uart.o uwire.o - -LST=$(OBJS:.o=.lst) - -all: libcalypso.a - -%.o: %.c - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ - -libcalypso.a: $(OBJS) - $(CROSS_COMPILE)$(AR) cru $@ $^ - -clean: - rm -f *.a $(OBJS) $(LST) +LIBRARIES+=calypso +calypso_DIR=calypso +calypso_SRCS=arm.c clock.c dma.c dsp.c du.c i2c.c irq.c rtc.c spi.c tpu.c tsp.c keypad.c misc.c timer.c backlight.c uart.c uwire.c diff --git a/src/target/firmware/comm/Makefile b/src/target/firmware/comm/Makefile index c6661e48..25fbb983 100644 --- a/src/target/firmware/comm/Makefile +++ b/src/target/firmware/comm/Makefile @@ -1,26 +1,5 @@ -INCLUDES=-I../include/ --include ../Makefile.inc -LIBNAME=comm -CSRCS=msgb.c sercomm.c sercomm_cons.c timer.c -SSRCS= +LIBRARIES+=comm +comm_DIR=comm +comm_SRCS=msgb.c sercomm.c sercomm_cons.c timer.c -COBJS=$(CSRCS:.c=.o) -SOBJS=$(SSRCS:.S=.o) -OBJS=$(COBJS) $(SOBJS) - -LST=$(OBJS:.o=.lst) - -all: lib$(LIBNAME).a - -$(COBJS): %.o : %.c - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ - -$(SOBJS): %.o : %.S - $(CROSS_COMPILE)$(CC) $(ASFLAGS) -c -o $@ $^ - -lib$(LIBNAME).a: $(OBJS) - $(CROSS_COMPILE)$(AR) cru $@ $^ - -clean: - rm -f *.a $(OBJS) $(LST) diff --git a/src/target/firmware/layer1/Makefile b/src/target/firmware/layer1/Makefile index 3587910f..6be75861 100644 --- a/src/target/firmware/layer1/Makefile +++ b/src/target/firmware/layer1/Makefile @@ -1,27 +1,6 @@ -INCLUDES=-I../include/ -I../../../../include --include ../Makefile.inc -LIBNAME=layer1 -CSRCS=avg.c agc.c afc.c sync.c gsm.c tdma_sched.c tpu_window.c init.c l23_api.c \ - mframe_sched.c sched_gsmtime.c async.c -SSRCS= +LIBRARIES+=layer1 +layer1_DIR=layer1 +layer1_SRCS=avg.c agc.c afc.c sync.c gsm.c tdma_sched.c tpu_window.c init.c l23_api.c \ + mframe_sched.c sched_gsmtime.c async.c -COBJS=$(CSRCS:.c=.o) -SOBJS=$(SSRCS:.S=.o) -OBJS=$(COBJS) $(SOBJS) - -LST=$(OBJS:.o=.lst) - -all: lib$(LIBNAME).a - -$(COBJS): %.o : %.c - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ - -$(SOBJS): %.o : %.S - $(CROSS_COMPILE)$(CC) $(ASFLAGS) -c -o $@ $^ - -lib$(LIBNAME).a: $(OBJS) - $(CROSS_COMPILE)$(AR) cru $@ $^ - -clean: - rm -f *.a $(OBJS) $(LST) diff --git a/src/target/firmware/lib/Makefile b/src/target/firmware/lib/Makefile index 4056e91b..85427439 100644 --- a/src/target/firmware/lib/Makefile +++ b/src/target/firmware/lib/Makefile @@ -1,26 +1,7 @@ -INCLUDES=-I../include/ --include ../Makefile.inc -LIBNAME=mini -CSRCS=vsprintf.c string.c ctype.c printf.c console.c -SSRCS=changebit.S clearbit.S div64.S lib1funcs.S memcpy.S memset.S setbit.S testchangebit.S testclearbit.S testsetbit.S +LIBRARIES+=mini +mini_DIR=lib +mini_SRCS=vsprintf.c string.c ctype.c printf.c console.c \ + changebit.S clearbit.S div64.S lib1funcs.S memcpy.S memset.S setbit.S testchangebit.S testclearbit.S testsetbit.S -COBJS=$(CSRCS:.c=.o) -SOBJS=$(SSRCS:.S=.o) -OBJS=$(COBJS) $(SOBJS) -LST=$(OBJS:.o=.lst) - -all: lib$(LIBNAME).a - -$(COBJS): %.o : %.c - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c -o $@ $^ - -$(SOBJS): %.o : %.S - $(CROSS_COMPILE)$(CC) $(ASFLAGS) -c -o $@ $^ - -lib$(LIBNAME).a: $(OBJS) - $(CROSS_COMPILE)$(AR) cru $@ $^ - -clean: - rm -f *.a $(OBJS) $(LST) |