2013-02-06 13:21:36 +01:00
|
|
|
####
|
|
|
|
#### Sample Makefile for building apps with the RIOT OS
|
|
|
|
####
|
|
|
|
#### The Sample Filesystem Layout is:
|
|
|
|
#### /this makefile
|
|
|
|
#### ../RIOT
|
|
|
|
#### ../RIOT/board for board definitions (if you have one or more)
|
|
|
|
####
|
|
|
|
|
|
|
|
#### Mandatory vars!
|
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
# this has to be the absolute path of the RIOT-base dir
|
2013-02-06 13:21:36 +01:00
|
|
|
export RIOTBASE =$(CURDIR)/../RIOT
|
|
|
|
export RIOTBOARD =$(CURDIR)/../RIOT/board
|
|
|
|
|
|
|
|
# the cpu to build for
|
|
|
|
export CPU = lpc2387
|
|
|
|
|
|
|
|
# toolchain config
|
|
|
|
export PREFIX = @arm-elf-
|
|
|
|
export CC = @$(PREFIX)gcc
|
|
|
|
export AR = @$(PREFIX)ar
|
|
|
|
export CFLAGS = -std=gnu99 -O2 -Wall -Wstrict-prototypes -mcpu=arm7tdmi-s -gdwarf-2
|
|
|
|
export ASFLAGS = -gdwarf-2 -mcpu=arm7tdmi-s
|
|
|
|
export AS = $(PREFIX)as
|
|
|
|
export LINK = $(PREFIX)gcc
|
|
|
|
export SIZE = $(PREFIX)size
|
|
|
|
export OBJCOPY = $(PREFIX)objcopy
|
2013-02-08 17:37:02 +01:00
|
|
|
FLASH = lpc2k_pgm
|
|
|
|
TERM = pyterm.py
|
2013-02-06 13:21:36 +01:00
|
|
|
LINKFLAGS = -gdwarf-2 -mcpu=arm7tdmi-s -static -lgcc -nostartfiles -T$(RIOTBASE)/cpu/$(CPU)/linkerscript.x
|
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
PROJBINDIR = bin
|
|
|
|
|
|
|
|
ifeq ($(strip $(PORT)),)
|
|
|
|
PORT = /dev/ttyUSB0
|
|
|
|
endif
|
|
|
|
|
|
|
|
## Modules to include.
|
2013-02-06 13:21:36 +01:00
|
|
|
|
|
|
|
#USEMODULE += nanopan5375_proprietary
|
|
|
|
#USEMODULE += sys
|
|
|
|
#USEMODULE += cmdd
|
|
|
|
#USEMODULE += logd
|
|
|
|
#USEMODULE += mprint
|
|
|
|
#USEMODULE += mqueue
|
|
|
|
#USEMODULE += sync_read
|
|
|
|
#USEMODULE += sysmon
|
|
|
|
#USEMODULE += syslog
|
|
|
|
#USEMODULE += tracelog
|
|
|
|
#USEMODULE += shell
|
|
|
|
#USEMODULE += utimer
|
|
|
|
#USEMODULE += sht11
|
|
|
|
#USEMODULE += powermon
|
|
|
|
#USEMODULE += ltc4150
|
|
|
|
#USEMODULE += sys_config
|
|
|
|
#USEMODULE += cc110x
|
|
|
|
#USEMODULE += cmdengine
|
|
|
|
#USEMODULE += ezxml
|
|
|
|
#USEMODULE += fat
|
|
|
|
#USEMODULE += gps
|
|
|
|
#USEMODULE += geo
|
|
|
|
#USEMODULE += gps_conversion
|
|
|
|
#USEMODULE += gps_ublox
|
|
|
|
#USEMODULE += net_kernel
|
|
|
|
#USEMODULE += net_mm
|
|
|
|
|
|
|
|
#### Project Config
|
|
|
|
|
|
|
|
# name of your project
|
|
|
|
PROJECT = hello-world
|
|
|
|
|
|
|
|
# for easy switching of boards
|
|
|
|
export BOARD = msba2
|
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
# mandatory include!
|
|
|
|
include $(RIOTBASE)/makefile.modules
|
|
|
|
|
2013-02-06 13:21:36 +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
|
|
|
|
|
|
|
|
# your binaries to link
|
|
|
|
BASELIBS += $(RIOTBOARD)/$(BOARD)/bin/$(BOARD)_base.a
|
2013-02-08 17:37:02 +01:00
|
|
|
BASELIBS += $(PROJBINDIR)/project.a
|
2013-02-06 13:21:36 +01:00
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
INCLUDES = -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/cpu/$(CPU)/include -I$(RIOTBASE)/cpu/arm_common/include -I$(RIOTBASE)/sys/lib -I$(RIOTBASE)/sys/include/ -I$(RIOTBASE)/drivers/include/
|
2013-02-06 13:21:36 +01:00
|
|
|
|
|
|
|
export INCLUDES
|
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
## make script for your project. Build RIOT-base here!
|
|
|
|
all: $(PROJBINDIR)/$(PROJECT).a
|
|
|
|
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(CPU)."
|
2013-02-06 13:21:36 +01:00
|
|
|
$(MAKE) -C $(RIOTBOARD)
|
|
|
|
$(MAKE) -C $(RIOTBASE)
|
2013-02-08 17:37:02 +01:00
|
|
|
$(LINK) $(LINKFLAGS) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(PROJBINDIR)/$(PROJECT).map
|
|
|
|
$(SIZE) $(PROJBINDIR)/$(PROJECT).elf
|
|
|
|
$(OBJCOPY) -O ihex $(PROJBINDIR)/$(PROJECT).elf $(PROJBINDIR)/$(PROJECT).hex
|
2013-02-06 13:21:36 +01:00
|
|
|
|
|
|
|
## your make rules
|
|
|
|
## Only basic example - modify it for larger projects!!
|
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
$(PROJBINDIR)/$(PROJECT).a: $(PROJBINDIR)/$(PROJECT).o
|
|
|
|
$(AR) -rc $(PROJBINDIR)/project.a $(PROJBINDIR)/$(PROJECT).o
|
2013-02-06 13:21:36 +01:00
|
|
|
|
2013-02-08 17:37:02 +01:00
|
|
|
$(PROJBINDIR)/$(PROJECT).o: main.c
|
|
|
|
$(CC) $(CFLAGS) $(BOARDINCLUDE) $(INCLUDES) -c main.c -o $(PROJBINDIR)/$(PROJECT).o
|
2013-02-06 13:21:36 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(MAKE) -C $(RIOTBOARD) clean
|
|
|
|
$(MAKE) -C $(RIOTBASE) clean
|
2013-02-08 17:37:02 +01:00
|
|
|
rm -f $(PROJBINDIR)/*
|
|
|
|
|
|
|
|
flash: all
|
|
|
|
$(FLASH) $(PORT) $(PROJBINDIR)/$(PROJECT).hex
|
|
|
|
|
|
|
|
term:
|
|
|
|
$(TERM) $(PORT)
|
2013-02-08 19:34:07 +01:00
|
|
|
|
|
|
|
doc:
|
|
|
|
make -BC $(RIOTBASE) doc
|