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-11-06 19:39:25 +01:00
|
|
|
ifeq ($(strip $(RIOTBOARD)),)
|
|
|
|
export RIOTBOARD =$(RIOTBASE)/boards
|
|
|
|
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')
|
2013-12-19 15:24:31 +01:00
|
|
|
CPUDEF = $(shell echo $(CPU)|tr 'a-z' 'A-Z')
|
|
|
|
CFLAGS += -DBOARD=$(BB) -DCPU_$(CPUDEF)
|
2013-03-10 16:51:40 +01:00
|
|
|
export CFLAGS
|
|
|
|
|
2014-01-03 18:45:33 +01:00
|
|
|
export BINDIR =$(CURDIR)/bin/$(BOARD)/
|
2013-12-21 15:02:53 +01:00
|
|
|
|
2014-01-05 11:33:34 +01:00
|
|
|
ifeq ($(QUIET),1)
|
|
|
|
AD=@
|
|
|
|
else
|
|
|
|
AD=
|
|
|
|
endif
|
|
|
|
export AD
|
|
|
|
|
2014-01-08 16:46:16 +01:00
|
|
|
BOARD := $(strip $(BOARD))
|
|
|
|
|
2013-04-01 00:18:07 +02:00
|
|
|
# mandatory includes!
|
2013-12-24 14:50:26 +01:00
|
|
|
include $(RIOTBASE)/Makefile.modules
|
2013-03-10 16:51:40 +01:00
|
|
|
include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
2013-12-22 20:02:59 +01:00
|
|
|
include $(RIOTCPU)/$(CPU)/Makefile.include
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
# your binaries to link
|
2013-12-24 13:20:25 +01:00
|
|
|
BASELIBS += $(BINDIR)$(BOARD)_base.a
|
|
|
|
BASELIBS += $(BINDIR)${PROJECT}.a
|
2013-03-10 16:51:40 +01:00
|
|
|
|
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-08-08 15:44:44 +02:00
|
|
|
.PHONY: all clean flash doc term
|
|
|
|
|
2013-03-10 16:51:40 +01:00
|
|
|
## make script for your project. Build RIOT-base here!
|
2013-12-24 13:20:25 +01:00
|
|
|
all: $(BINDIR)$(PROJECT).a
|
2013-03-30 21:44:16 +01:00
|
|
|
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)."
|
2013-12-21 16:27:45 +01:00
|
|
|
"$(MAKE)" -C $(RIOTBOARD)/$(BOARD)
|
2013-08-06 18:58:24 +02:00
|
|
|
"$(MAKE)" -C $(RIOTBASE)
|
|
|
|
@for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i ; done ;
|
2013-05-15 17:45:43 +02:00
|
|
|
ifeq ($(BUILDOSXNATIVE),1)
|
2014-01-03 19:00:41 +01:00
|
|
|
$(LINK) $(UNDEF) -o $(BINDIR)$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
|
2013-05-15 17:45:43 +02:00
|
|
|
else
|
2014-01-10 15:43:17 +01:00
|
|
|
$(AD)$(LINK) $(UNDEF) -o $(BINDIR)$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(BINDIR)$(PROJECT).map $(LINKFLAGS)
|
|
|
|
$(AD)$(SIZE) $(BINDIR)$(PROJECT).elf
|
|
|
|
$(AD)$(OBJCOPY) $(OFLAGS) $(BINDIR)$(PROJECT).elf $(BINDIR)$(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-12-21 15:02:53 +01:00
|
|
|
#$(BINDIR)/$(PROJECT).a: $(BINDIR)/$(PROJECT).o
|
|
|
|
# $(AR) -rc $(BINDIR)/project.a $(BINDIR)/$(PROJECT).o
|
2013-04-22 00:55:11 +02:00
|
|
|
|
|
|
|
# string array of all names of c files in dir
|
|
|
|
SRC = $(wildcard *.c)
|
|
|
|
|
|
|
|
# string array of all names replaced .c with .o
|
2014-01-14 17:58:29 +01:00
|
|
|
OBJ = $(SRC:%.c=${BINDIR}${PROJECT}/%.o)
|
2013-04-22 00:55:11 +02:00
|
|
|
|
2013-12-24 13:20:25 +01:00
|
|
|
$(BINDIR)$(PROJECT).a: $(OBJ)
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)$(AR) -rc $(BINDIR)$(PROJECT).a $(OBJ)
|
2013-04-22 00:55:11 +02:00
|
|
|
|
|
|
|
# pull in dependency info for *existing* .o files
|
|
|
|
-include $(OBJ:.o=.d)
|
|
|
|
|
2014-01-14 17:58:29 +01:00
|
|
|
$(BINDIR)$(PROJECT)/%.o: %.c $(PROJDEPS)
|
2013-04-22 00:55:11 +02:00
|
|
|
@echo; echo "Compiling.... $*.c"; echo
|
2014-01-14 17:58:29 +01:00
|
|
|
@test -d $(BINDIR)$(PROJECT) || mkdir -p $(BINDIR)$(PROJECT)
|
|
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$(PROJECT)/$*.o
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
clean:
|
2013-12-21 16:27:45 +01:00
|
|
|
"$(MAKE)" -C $(RIOTBOARD)/$(BOARD) clean
|
2013-08-06 18:58:24 +02:00
|
|
|
"$(MAKE)" -C $(RIOTBASE) clean
|
|
|
|
@for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i clean ; done ;
|
2013-12-21 15:02:53 +01:00
|
|
|
rm -rf $(BINDIR)
|
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:
|
2013-08-09 15:57:34 +02:00
|
|
|
$(TERMPROG) $(PORT)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
doc:
|
|
|
|
make -BC $(RIOTBASE) doc
|
2013-07-12 12:31:16 +02:00
|
|
|
|
|
|
|
debug:
|
|
|
|
$(DEBUGGER) $(DEBUGGER_FLAGS)
|
2013-11-12 14:57:17 +01:00
|
|
|
|
|
|
|
buildtest:
|
2014-02-05 08:55:43 +01:00
|
|
|
@if [ -z "$${JENKINS_URL}" ] && tput colors 2>&1 > /dev/null; then \
|
|
|
|
GREEN='\033[1;32m'; RED='\033[1;31m'; RESET='\033[0m'; \
|
|
|
|
ECHO='echo -e'; \
|
|
|
|
else \
|
|
|
|
GREEN=''; RED=''; RESET=''; \
|
|
|
|
ECHO='echo'; \
|
|
|
|
fi; \
|
|
|
|
\
|
|
|
|
for BOARD in $$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); do \
|
|
|
|
$${ECHO} -n "Building for $${BOARD} .. "; \
|
2014-02-05 08:53:54 +01:00
|
|
|
env -i \
|
|
|
|
HOME=$${HOME} \
|
|
|
|
PATH=$${PATH} \
|
|
|
|
BOARD=$${BOARD} \
|
|
|
|
RIOTBASE=$${RIOTBASE} \
|
|
|
|
RIOTBOARD=$${RIOTBOARD} \
|
|
|
|
RIOTCPU=$${RIOTCPU} \
|
|
|
|
$(MAKE) -B clean all >/dev/null 2>&1 ; \
|
|
|
|
if [ "$${?}" = "0" ]; then \
|
2014-02-05 08:55:43 +01:00
|
|
|
$${ECHO} "$${GREEN}success$${RESET}"; \
|
2014-02-05 08:53:54 +01:00
|
|
|
else \
|
2014-02-05 08:55:43 +01:00
|
|
|
$${ECHO} "$${RED}failed$${RESET}"; \
|
2014-02-05 08:53:54 +01:00
|
|
|
fi; \
|
|
|
|
done; \
|