1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/Makefile.include

116 lines
3.1 KiB
Makefile
Raw Normal View History

# set undefined variables
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
# 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)
export CFLAGS
export BINDIR =$(CURDIR)/bin/$(BOARD)/
ifeq ($(QUIET),1)
AD=@
else
AD=
endif
export AD
# mandatory includes!
2013-12-24 14:50:26 +01:00
include $(RIOTBASE)/Makefile.modules
include $(RIOTBOARD)/$(BOARD)/Makefile.include
include $(RIOTCPU)/$(CPU)/Makefile.include
# your binaries to link
2013-12-24 13:20:25 +01:00
BASELIBS += $(BINDIR)$(BOARD)_base.a
BASELIBS += $(BINDIR)${PROJECT}.a
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
# 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
## make script for your project. Build RIOT-base here!
2013-12-24 13:20:25 +01:00
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 ;
2013-05-15 17:45:43 +02:00
ifeq ($(BUILDOSXNATIVE),1)
$(LINK) $(UNDEF) -o $(BINDIR)$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
2013-05-15 17:45:43 +02:00
else
2013-12-24 13:20:25 +01:00
@$(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
2013-05-15 17:45:43 +02:00
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
2013-12-24 13:20:25 +01:00
OBJ = $(SRC:%.c=${BINDIR}%.o)
2013-12-24 13:20:25 +01:00
$(BINDIR)$(PROJECT).a: $(OBJ)
$(AD)$(AR) -rc $(BINDIR)$(PROJECT).a $(OBJ)
# pull in dependency info for *existing* .o files
-include $(OBJ:.o=.d)
2013-12-24 13:20:25 +01:00
$(BINDIR)%.o: %.c $(PROJDEPS)
@echo; echo "Compiling.... $*.c"; echo
@test -d $(BINDIR) || mkdir -p $(BINDIR)
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.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:
2013-11-15 12:14:23 +01:00
@for BOARD in $$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); do \
echo -n "Building for $${BOARD} .. "; \
2013-12-24 17:12:30 +01:00
env -i HOME=$${HOME} PATH=$${PATH} BOARD=$${BOARD} RIOTBASE=$${RIOTBASE} RIOTBOARD=$${RIOTBOARD} RIOTCPU=$${RIOTCPU} $(MAKE) -B clean all >/dev/null 2>&1 && echo -e "\033[1;32msuccess\033[0m" || echo -e "\033[1;31mfailed\033[0m" ; \
done