2013-04-01 00:18:07 +02:00
|
|
|
# set undefined variables
|
2013-03-23 18:38:12 +01:00
|
|
|
ifeq ($(strip $(RIOTCPU)),)
|
|
|
|
export RIOTCPU =$(RIOTBASE)/cpu
|
|
|
|
endif
|
|
|
|
|
2013-03-31 22:14:06 +02:00
|
|
|
ifeq ($(strip $(MCU)),)
|
|
|
|
MCU = $(CPU)
|
|
|
|
endif
|
2013-03-23 18:38:12 +01:00
|
|
|
|
2013-03-10 16:51:40 +01:00
|
|
|
# if you want to publish the board into the sources as an uppercase #define
|
|
|
|
BB = $(shell echo $(BOARD)|tr 'a-z' 'A-Z')
|
|
|
|
CFLAGS += -DBOARD=$(BB)
|
|
|
|
export CFLAGS
|
|
|
|
|
2013-04-01 00:18:07 +02:00
|
|
|
# mandatory includes!
|
2013-03-10 16:51:40 +01:00
|
|
|
include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
2013-04-01 00:18:07 +02:00
|
|
|
include $(RIOTCPU)/Makefile.include
|
2013-03-13 16:49:23 +01:00
|
|
|
include $(RIOTBASE)/Makefile.modules
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
# your binaries to link
|
|
|
|
BASELIBS += $(RIOTBOARD)/$(BOARD)/bin/$(BOARD)_base.a
|
2013-04-22 00:55:11 +02:00
|
|
|
BASELIBS += $(PROJBINDIR)/${PROJECT}.a
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
PROJBINDIR =$(CURDIR)/bin
|
|
|
|
|
2013-05-15 17:45:43 +02:00
|
|
|
# clumsy way to enable building native on osx:
|
|
|
|
BUILDOSXNATIVE = 0
|
|
|
|
ifeq ($(CPU),native)
|
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
BUILDOSXNATIVE = 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-06-03 12:08:08 +02:00
|
|
|
# backward compatability with glibc <= 2.17 for native
|
|
|
|
ifeq ($(CPU),native)
|
|
|
|
ifeq ($(shell uname -s),Linux)
|
|
|
|
ifeq ($(shell ldd --version | awk '/^ldd/{if ($$NF < 2.17) {print "yes"} else {print "no"} }'),yes)
|
|
|
|
LINKFLAGS += -lrt
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-03-10 16:51:40 +01:00
|
|
|
## make script for your project. Build RIOT-base here!
|
|
|
|
all: $(PROJBINDIR)/$(PROJECT).a
|
2013-03-30 21:44:16 +01:00
|
|
|
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)."
|
2013-03-10 16:51:40 +01:00
|
|
|
$(MAKE) -C $(RIOTBOARD)
|
|
|
|
$(MAKE) -C $(RIOTBASE)
|
2013-07-23 18:50:26 +02:00
|
|
|
@for i in $(EXTERNAL_MODULES) ; do $(MAKE) -C $$i ; done ;
|
2013-05-15 17:45:43 +02:00
|
|
|
ifeq ($(BUILDOSXNATIVE),1)
|
|
|
|
@$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
|
|
|
|
else
|
2013-03-23 18:38:12 +01:00
|
|
|
@$(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) -O ihex $(PROJBINDIR)/$(PROJECT).elf $(PROJBINDIR)/$(PROJECT).hex
|
2013-05-15 17:45:43 +02:00
|
|
|
endif
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
## your make rules
|
|
|
|
## Only basic example - modify it for larger projects!!
|
2013-04-22 00:55:11 +02:00
|
|
|
#$(PROJBINDIR)/$(PROJECT).a: $(PROJBINDIR)/$(PROJECT).o
|
|
|
|
# $(AR) -rc $(PROJBINDIR)/project.a $(PROJBINDIR)/$(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)
|
|
|
|
|
|
|
|
${PROJBINDIR}/$(PROJECT).a: $(OBJ)
|
|
|
|
$(AR) -rc bin/$(PROJECT).a $(OBJ)
|
|
|
|
|
|
|
|
# pull in dependency info for *existing* .o files
|
|
|
|
-include $(OBJ:.o=.d)
|
|
|
|
|
|
|
|
${PROJBINDIR}/%.o: %.c
|
|
|
|
@echo; echo "Compiling.... $*.c"; echo
|
2013-07-31 17:16:05 +02:00
|
|
|
@test -d $(PROJBINDIR) || mkdir -p $(PROJBINDIR)
|
2013-06-13 21:31:08 +02:00
|
|
|
$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o bin/$*.o
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(MAKE) -C $(RIOTBOARD) clean
|
|
|
|
$(MAKE) -C $(RIOTBASE) clean
|
2013-07-23 18:50:26 +02:00
|
|
|
@for i in $(EXTERNAL_MODULES) ; do $(MAKE) -C $$i clean ; done ;
|
2013-07-31 15:19:59 +02:00
|
|
|
rm -rf $(PROJBINDIR)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
flash: all
|
2013-04-09 11:26:33 +02:00
|
|
|
$(FLASHER) $(FFLAGS)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
term:
|
|
|
|
$(TERM) $(PORT)
|
|
|
|
|
|
|
|
doc:
|
|
|
|
make -BC $(RIOTBASE) doc
|