diff --git a/Makefile.include b/Makefile.include index 84c5c990b07dca843af6b39c307531ab66a465db..fe82ff7a6f2bf8d38e378c3ff8fea3bf4f579997 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 12019c1f68cc50aad4a89bf37e44c72b2ca47a3e..2cc5ff9f8858fbdd462365108a68dc67c82d631d 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 3597e18c735c0d7e314ddde169b283e9e6ba2ffa..fafe03573e23dac64d8954c1554766da18f2ea8e 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 71736befcce42345865842285e74dc3c77272574..37cb21930905b86308d6a40a8a08ad16defb5900 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 c4cf57edb54d7029d13c17ed6506dd8dbae544c3..1e22ecf21950865a7308f6e4b0002b07eec56683 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 a0f331e5c8714da989fad56d76ebfb879befe3eb..0669f85ea1f75e66e6594d1b977c59a946ac1132 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 bf355bf8e258423c5254f880a2cc9fcfc185986e..03df5e674537e161d57346373e41eb6d463d1523 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 e706445a92e56b94bf6564aee5c650e3bf197d42..e8e0c5ab5185c84e3171fe33439484de5d8187de 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 4ca6a9248b97d916f2e48882ca07b188b043988c..7bf77e33de8fed06ad5a3553a52141401cd81fa0 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 4f5bb857d37bc5dd9da19db4bf49f7ae4f223f86..d21fc1215df92e519691f0e5d0161e59b57d8774 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 d4b65dc0319c6cf99c012d9bc24c784606687598..7ee93dddd63e0d29a7e60b722375e610ef77042f 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 196aeceab75e21007408ab0929b026db802d1ce4..52bc6e8e761652c8288c9941523374105a24ac41 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 2bd0f63c26c3de6866836eaee3b3c80a3afaa034..0375b98d6ae5ad24f2601f35507b1c438c781164 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 29f64c8ecb108af9ffc9c49f57396b1f18926419..1a59172180ccb4f41b2ed13491f583edff33cfe9 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 5d3ba0fb0ddc9791fae6aec8f35e82006ab7150b..7fda39a44a574761ac5f00d253f8444f6acfda2b 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 c2ec59716242dd83228b34c436ba8672ae43b04b..2da449b98cd5c63a53a7f3e736d2975dfce5af4d 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 0aff0df0b14cb786c255ac89d8461d5718813bf2..21a56bcc606047e664785ce22cdbf0d7568fc1fe 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 ded96b6cf2f0b6228ff2daacd5866086a9d51e5e..f79d5c40fd23ff6e9ddf330be8525445ecc7a877 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 6e2c0a70b38ded97dfc4af8a8b74877d85c6485d..b4901278c889886ffd3333ec1f221c2f0a1f390b 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 295ea7255f4704ae5a721c8b5504a2cd963aaa8e..afd3c0b5ff2538250fb34d1b88e0f02c049b15a4 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 cec1080b6473e4ee8725ae44831955e40be2eeb7..7f566470c0cadd43ff632f4b1ba5cab75c9e9f47 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 c5eb97b3bc8da2ff13a6baa7ef55800281eca904..df209398c646e3bfaa42221784680eb1f5c8f0e7 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 1f16d2e7b70ad2da0e6002e5356030ed797f1918..80395b44fdb3d7c324d840310729f286d390dbfb 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 8f8f23add94f2a6676778a1adc8b103cad9ad510..be23b266c15b09bfc8495b6f2f70ed77bdd2baef 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 346044a3097ed9bd647e44d0085fac4fd4d7220b..a11626dbc5b46674462c8023187f29f3caa2756f 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 e19884c6b16a2ab122bf20516fabb2807dce44b0..9bdfb6b0e7d7fec42942c9ad23cbb7c3cf923848 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 5e426ffbd9fa12ee56ad03f9009aa5a146949d88..2df440028e1b0597129fb530e716ff70ccd05d3d 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