You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.6 KiB

# set undefined variables
ifeq ($(strip $(RIOTCPU)),)
export RIOTCPU =$(RIOTBASE)/cpu
endif
ifeq ($(strip $(RIOTBOARD)),)
export RIOTBOARD =$(RIOTBASE)/boards
endif
ifeq ($(strip $(MCU)),)
MCU = $(CPU)
endif
# if you want to publish the board into the sources as an uppercase #define
BB = $(shell echo $(BOARD)|tr 'a-z' 'A-Z')
CPUDEF = $(shell echo $(CPU)|tr 'a-z' 'A-Z')
CFLAGS += -DBOARD=$(BB) -DCPU_$(CPUDEF) -fno-delete-null-pointer-checks
export CFLAGS
export BINDIR =$(CURDIR)/bin/$(BOARD)/
ifeq ($(QUIET),1)
AD=@
else
AD=
endif
export AD
BOARD := $(strip $(BOARD))
# mandatory includes!
include $(RIOTBASE)/Makefile.modules
include $(RIOTBOARD)/$(BOARD)/Makefile.include
include $(RIOTCPU)/$(CPU)/Makefile.include
# your binaries to link
BASELIBS += $(BINDIR)$(BOARD)_base.a
BASELIBS += $(BINDIR)${PROJECT}.a
# clumsy way to enable building native on osx:
BUILDOSXNATIVE = 0
ifeq ($(CPU),native)
ifeq ($(shell uname -s),Darwin)
BUILDOSXNATIVE = 1
endif
endif
# 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
.PHONY: all clean flash doc term
## make script for your project. Build RIOT-base here!
all: $(BINDIR)$(PROJECT).a
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)."
"$(MAKE)" -C $(RIOTBOARD)/$(BOARD)
"$(MAKE)" -C $(RIOTBASE)
@for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i ; done ;
ifeq ($(BUILDOSXNATIVE),1)
$(LINK) $(UNDEF) -o $(BINDIR)$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
else
$(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
endif
## your make rules
## Only basic example - modify it for larger projects!!
#$(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=${BINDIR}${PROJECT}/%.o)
$(BINDIR)$(PROJECT).a: $(OBJ)
$(AD)$(AR) -rc $(BINDIR)$(PROJECT).a $(OBJ)
# pull in dependency info for *existing* .o files
-include $(OBJ:.o=.d)
$(BINDIR)$(PROJECT)/%.o: %.c $(PROJDEPS)
@echo; echo "Compiling.... $*.c"; echo
@test -d $(BINDIR)$(PROJECT) || mkdir -p $(BINDIR)$(PROJECT)
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$(PROJECT)/$*.o
clean:
"$(MAKE)" -C $(RIOTBOARD)/$(BOARD) clean
"$(MAKE)" -C $(RIOTBASE) clean
@for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i clean ; done ;
rm -rf $(BINDIR)
flash: all
$(FLASHER) $(FFLAGS)
term:
$(TERMPROG) $(PORT)
doc:
make -BC $(RIOTBASE) doc
debug:
$(DEBUGGER) $(DEBUGGER_FLAGS)
buildtest:
@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} .. "; \
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 \
$${ECHO} "$${GREEN}success$${RESET}"; \
else \
$${ECHO} "$${RED}failed$${RESET}"; \
BUILDTESTFAILED=1; \
fi; \
done; \
if [ "$${BUILDTESTFAILED}" = "1" ]; then \
exit 1; \
fi