From 1e665b49dedb73950c166a0bd3d62520a4cec15f Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sat, 21 Dec 2013 15:02:53 +0100 Subject: [PATCH] build everything in the project directory --- Makefile.include | 36 ++++++++++++------------- Makefile.modules | 1 - boards/avsextrem/Makefile | 3 +-- boards/avsextrem/drivers/Makefile | 1 - boards/chronos/Makefile | 3 +-- boards/chronos/Makefile.include | 2 +- boards/chronos/drivers/Makefile | 1 - boards/mbed_lpc1768/Makefile | 1 - boards/msb-430-common/Makefile | 1 - boards/msb-430-common/Makefile.include | 2 +- boards/msb-430-common/drivers/Makefile | 1 - boards/msb-430/Makefile | 3 +-- boards/msb-430h/Makefile | 3 +-- boards/msba2-common/Makefile | 1 - boards/msba2-common/Makefile.include | 2 +- boards/msba2-common/drivers/Makefile | 1 - boards/msba2/Makefile | 3 +-- boards/native/Makefile | 3 +-- boards/native/drivers/Makefile | 1 - boards/redbee-econotag/Makefile | 3 +-- boards/redbee-econotag/drivers/Makefile | 1 - boards/telosb/Makefile | 3 +-- boards/telosb/Makefile.include | 2 +- boards/wsn430-common/Makefile | 1 - boards/wsn430-common/Makefile.include | 2 +- boards/wsn430-v1_3b/Makefile | 5 ++-- boards/wsn430-v1_4/Makefile | 3 +-- 27 files changed, 34 insertions(+), 55 deletions(-) diff --git a/Makefile.include b/Makefile.include index 84c5c990b0..fe82ff7a6f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -17,16 +17,16 @@ CPUDEF = $(shell echo $(CPU)|tr 'a-z' 'A-Z') CFLAGS += -DBOARD=$(BB) -DCPU_$(CPUDEF) export CFLAGS +export BINDIR =$(CURDIR)/bin/ + # mandatory includes! include $(RIOTBOARD)/$(BOARD)/Makefile.include include $(RIOTCPU)/Makefile.include include $(RIOTBASE)/Makefile.modules # your binaries to link -BASELIBS += $(RIOTBOARD)/$(BOARD)/bin/$(BOARD)_base.a -BASELIBS += $(PROJBINDIR)/${PROJECT}.a - -PROJBINDIR =$(CURDIR)/bin +BASELIBS += $(BINDIR)/$(BOARD)_base.a +BASELIBS += $(BINDIR)/${PROJECT}.a # clumsy way to enable building native on osx: BUILDOSXNATIVE = 0 @@ -48,46 +48,46 @@ endif .PHONY: all clean flash doc term ## make script for your project. Build RIOT-base here! -all: $(PROJBINDIR)/$(PROJECT).a +all: $(BINDIR)/$(PROJECT).a @echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)." "$(MAKE)" -C $(RIOTBOARD) "$(MAKE)" -C $(RIOTBASE) @for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i ; done ; ifeq ($(BUILDOSXNATIVE),1) - @$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie + @$(LINK) $(UNDEF) -o $(BINDIR)/$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie else - @$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(PROJBINDIR)/$(PROJECT).map $(LINKFLAGS) - @$(SIZE) $(PROJBINDIR)/$(PROJECT).elf - @$(OBJCOPY) $(OFLAGS) $(PROJBINDIR)/$(PROJECT).elf $(PROJBINDIR)/$(PROJECT).hex + @$(LINK) $(UNDEF) -o $(BINDIR)/$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(BINDIR)/$(PROJECT).map $(LINKFLAGS) + @$(SIZE) $(BINDIR)/$(PROJECT).elf + @$(OBJCOPY) $(OFLAGS) $(BINDIR)/$(PROJECT).elf $(BINDIR)/$(PROJECT).hex endif ## your make rules ## Only basic example - modify it for larger projects!! -#$(PROJBINDIR)/$(PROJECT).a: $(PROJBINDIR)/$(PROJECT).o -# $(AR) -rc $(PROJBINDIR)/project.a $(PROJBINDIR)/$(PROJECT).o +#$(BINDIR)/$(PROJECT).a: $(BINDIR)/$(PROJECT).o +# $(AR) -rc $(BINDIR)/project.a $(BINDIR)/$(PROJECT).o # string array of all names of c files in dir SRC = $(wildcard *.c) # string array of all names replaced .c with .o -OBJ = $(SRC:%.c=${PROJBINDIR}/%.o) +OBJ = $(SRC:%.c=${BINDIR}/%.o) -$(PROJBINDIR)/$(PROJECT).a: $(OBJ) - $(AR) -rc $(PROJBINDIR)/$(PROJECT).a $(OBJ) +$(BINDIR)/$(PROJECT).a: $(OBJ) + $(AR) -rc $(BINDIR)/$(PROJECT).a $(OBJ) # pull in dependency info for *existing* .o files -include $(OBJ:.o=.d) -$(PROJBINDIR)/%.o: %.c $(PROJDEPS) +$(BINDIR)/%.o: %.c $(PROJDEPS) @echo; echo "Compiling.... $*.c"; echo - @test -d $(PROJBINDIR) || mkdir -p $(PROJBINDIR) - $(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(PROJBINDIR)/$*.o + @test -d $(BINDIR) || mkdir -p $(BINDIR) + $(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)/$*.o clean: "$(MAKE)" -C $(RIOTBOARD) clean "$(MAKE)" -C $(RIOTBASE) clean @for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i clean ; done ; - rm -rf $(PROJBINDIR) + rm -rf $(BINDIR) flash: all $(FLASHER) $(FFLAGS) diff --git a/Makefile.modules b/Makefile.modules index 12019c1f68..2cc5ff9f88 100644 --- a/Makefile.modules +++ b/Makefile.modules @@ -1,5 +1,4 @@ export MAKEBASE =$(RIOTBASE) -export BINDIR =$(RIOTBASE)/bin/ UNDEF += $(BINDIR)startup.o USEMODULE += cpu core sys diff --git a/boards/avsextrem/Makefile b/boards/avsextrem/Makefile index 3597e18c73..fafe03573e 100644 --- a/boards/avsextrem/Makefile +++ b/boards/avsextrem/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = avsextrem_base.a @@ -33,6 +32,6 @@ clean: "$(MAKE)" -C drivers clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi diff --git a/boards/avsextrem/drivers/Makefile b/boards/avsextrem/drivers/Makefile index 71736befcc..37cb219309 100644 --- a/boards/avsextrem/drivers/Makefile +++ b/boards/avsextrem/drivers/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o) DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/chronos/Makefile b/boards/chronos/Makefile index c4cf57edb5..1e22ecf219 100644 --- a/boards/chronos/Makefile +++ b/boards/chronos/Makefile @@ -1,7 +1,6 @@ export ARCH = chronos_base.a SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o) DEP = $(SRC:%.c=$(BINDIR)%.d) @@ -32,4 +31,4 @@ clean: $(MAKE) -C drivers clean rm -f $(OBJ) $(DEP) rm -f $(BINDIR)$(ARCH) - -rmdir $(BINDIR) + -rm -rf $(BINDIR) diff --git a/boards/chronos/Makefile.include b/boards/chronos/Makefile.include index a0f331e5c8..0669f85ea1 100644 --- a/boards/chronos/Makefile.include +++ b/boards/chronos/Makefile.include @@ -15,7 +15,7 @@ export AS = $(PREFIX)as export LINK = $(PREFIX)gcc export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy -export LINKFLAGS = -mmcu=$(MCU) -lgcc $(RIOTBASE)/bin/startup.o +export LINKFLAGS = -mmcu=$(MCU) -lgcc $(BINDIR)/startup.o export FLASHER = mspdebug export HEXFILE = bin/$(PROJECT).hex export USEMODULE += msp430_common diff --git a/boards/chronos/drivers/Makefile b/boards/chronos/drivers/Makefile index bf355bf8e2..03df5e6745 100644 --- a/boards/chronos/drivers/Makefile +++ b/boards/chronos/drivers/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o) DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/mbed_lpc1768/Makefile b/boards/mbed_lpc1768/Makefile index e706445a92..e8e0c5ab51 100644 --- a/boards/mbed_lpc1768/Makefile +++ b/boards/mbed_lpc1768/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) export ARCH = mbed_lpc1768_base.a diff --git a/boards/msb-430-common/Makefile b/boards/msb-430-common/Makefile index 4ca6a9248b..7bf77e33de 100644 --- a/boards/msb-430-common/Makefile +++ b/boards/msb-430-common/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/msb-430-common/Makefile.include b/boards/msb-430-common/Makefile.include index 4f5bb857d3..d21fc1215d 100644 --- a/boards/msb-430-common/Makefile.include +++ b/boards/msb-430-common/Makefile.include @@ -12,7 +12,7 @@ export AS = $(PREFIX)as export LINK = $(PREFIX)gcc export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy -export LINKFLAGS = -mmcu=$(MCU) -lgcc $(RIOTBASE)/bin/startup.o +export LINKFLAGS = -mmcu=$(MCU) -lgcc $(BINDIR)/startup.o TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm.py export HEXFILE = bin/$(PROJECT).hex diff --git a/boards/msb-430-common/drivers/Makefile b/boards/msb-430-common/drivers/Makefile index d4b65dc031..7ee93dddd6 100644 --- a/boards/msb-430-common/drivers/Makefile +++ b/boards/msb-430-common/drivers/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o) DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/msb-430/Makefile b/boards/msb-430/Makefile index 196aeceab7..52bc6e8e76 100644 --- a/boards/msb-430/Makefile +++ b/boards/msb-430/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = msb-430_base.a @@ -30,5 +29,5 @@ clean: $(MAKE) -C ../msb-430-common clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi diff --git a/boards/msb-430h/Makefile b/boards/msb-430h/Makefile index 2bd0f63c26..0375b98d6a 100644 --- a/boards/msb-430h/Makefile +++ b/boards/msb-430h/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = msb-430h_base.a @@ -31,7 +30,7 @@ clean: $(MAKE) -C ../msb-430-common clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi diff --git a/boards/msba2-common/Makefile b/boards/msba2-common/Makefile index 29f64c8ecb..1a59172180 100644 --- a/boards/msba2-common/Makefile +++ b/boards/msba2-common/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/msba2-common/Makefile.include b/boards/msba2-common/Makefile.include index 5d3ba0fb0d..7fda39a44a 100644 --- a/boards/msba2-common/Makefile.include +++ b/boards/msba2-common/Makefile.include @@ -20,7 +20,7 @@ ifeq ($(strip $(PORT)),) export PORT = /dev/ttyUSB0 endif export HEXFILE = bin/$(PROJECT).hex -export FFLAGS = $(PORT) $(PROJBINDIR)/$(PROJECT).hex +export FFLAGS = $(PORT) $(BINDIR)/$(PROJECT).hex include $(RIOTBOARD)/msba2-common/Makefile.dep export INCLUDES += -I$(RIOTCPU)/lpc2387/include diff --git a/boards/msba2-common/drivers/Makefile b/boards/msba2-common/drivers/Makefile index c2ec597162..2da449b98c 100644 --- a/boards/msba2-common/drivers/Makefile +++ b/boards/msba2-common/drivers/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o) DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/msba2/Makefile b/boards/msba2/Makefile index 0aff0df0b1..21a56bcc60 100644 --- a/boards/msba2/Makefile +++ b/boards/msba2/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = msba2_base.a @@ -31,7 +30,7 @@ clean: $(MAKE) -C ../msba2-common clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi diff --git a/boards/native/Makefile b/boards/native/Makefile index ded96b6cf2..f79d5c40fd 100644 --- a/boards/native/Makefile +++ b/boards/native/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) export ARCH = native_base.a @@ -27,5 +26,5 @@ $(BINDIR)%.o: %.c clean: ${MAKE} -C drivers clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) - -rmdir -p $(BINDIR) + -rm -rf -p $(BINDIR) diff --git a/boards/native/drivers/Makefile b/boards/native/drivers/Makefile index 6e2c0a70b3..b4901278c8 100644 --- a/boards/native/drivers/Makefile +++ b/boards/native/drivers/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(BINDIR)native-led.o ifneq (,$(findstring ltc4150,$(USEMODULE))) OBJ += $(BINDIR)native-ltc4150.o diff --git a/boards/redbee-econotag/Makefile b/boards/redbee-econotag/Makefile index 295ea7255f..afd3c0b5ff 100644 --- a/boards/redbee-econotag/Makefile +++ b/boards/redbee-econotag/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) export ARCH = $(BOARD)_base.a @@ -32,6 +31,6 @@ clean: "$(MAKE)" -C drivers clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi diff --git a/boards/redbee-econotag/drivers/Makefile b/boards/redbee-econotag/drivers/Makefile index cec1080b64..7f566470c0 100644 --- a/boards/redbee-econotag/drivers/Makefile +++ b/boards/redbee-econotag/drivers/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o) DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/telosb/Makefile b/boards/telosb/Makefile index c5eb97b3bc..df209398c6 100644 --- a/boards/telosb/Makefile +++ b/boards/telosb/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = telosb_base.a @@ -30,5 +29,5 @@ $(BINDIR)%.o: %.c clean: rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi diff --git a/boards/telosb/Makefile.include b/boards/telosb/Makefile.include index 1f16d2e7b7..80395b44fd 100644 --- a/boards/telosb/Makefile.include +++ b/boards/telosb/Makefile.include @@ -13,7 +13,7 @@ export AS = $(PREFIX)as export LINK = $(PREFIX)gcc export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy -export LINKFLAGS = -mmcu=$(MCU) -lgcc $(RIOTBASE)/bin/startup.o +export LINKFLAGS = -mmcu=$(MCU) -lgcc $(BINDIR)/startup.o export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm.py export FLASHER = goodfet.bsl ifeq ($(strip $(PORT)),) diff --git a/boards/wsn430-common/Makefile b/boards/wsn430-common/Makefile index 8f8f23add9..be23b266c1 100644 --- a/boards/wsn430-common/Makefile +++ b/boards/wsn430-common/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) diff --git a/boards/wsn430-common/Makefile.include b/boards/wsn430-common/Makefile.include index 346044a309..a11626dbc5 100644 --- a/boards/wsn430-common/Makefile.include +++ b/boards/wsn430-common/Makefile.include @@ -12,7 +12,7 @@ export AS = $(PREFIX)as export LINK = $(PREFIX)gcc export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy -export LINKFLAGS = -mmcu=$(MCU) -lgcc $(RIOTBASE)/bin/startup.o +export LINKFLAGS = -mmcu=$(MCU) -lgcc $(BINDIR)/startup.o export FLASHER = mspdebug ifeq ($(strip $(PORT)),) export PORT = /dev/ttyUSB0 diff --git a/boards/wsn430-v1_3b/Makefile b/boards/wsn430-v1_3b/Makefile index e19884c6b1..9bdfb6b0e7 100644 --- a/boards/wsn430-v1_3b/Makefile +++ b/boards/wsn430-v1_3b/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = wsn430-v1_3b_base.a @@ -32,5 +31,5 @@ clean: $(MAKE) -C ../wsn430-common clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ - fi \ No newline at end of file + then rm -rf $(BINDIR) ; \ + fi diff --git a/boards/wsn430-v1_4/Makefile b/boards/wsn430-v1_4/Makefile index 5e426ffbd9..2df440028e 100644 --- a/boards/wsn430-v1_4/Makefile +++ b/boards/wsn430-v1_4/Makefile @@ -1,5 +1,4 @@ SRC = $(wildcard *.c) -BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines export ARCH = wsn430-v1_4_base.a @@ -31,5 +30,5 @@ clean: $(MAKE) -C ../wsn430-common clean rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) @if [ -d $(BINDIR) ] ; \ - then rmdir $(BINDIR) ; \ + then rm -rf $(BINDIR) ; \ fi