FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:37:05 2017 +0000
Revision:
0:dbad57390bd1
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:dbad57390bd1 1 # Makefile for LWM2M Test Application
ram54288 0:dbad57390bd1 2 #
ram54288 0:dbad57390bd1 3 # Define compiler toolchain with PLATFORM variable
ram54288 0:dbad57390bd1 4 # Example
ram54288 0:dbad57390bd1 5 # make PLATFORM=arm-linux-gnueabi-
ram54288 0:dbad57390bd1 6 #
ram54288 0:dbad57390bd1 7
ram54288 0:dbad57390bd1 8 ROOT := ../../../..
ram54288 0:dbad57390bd1 9 LWM2M_ROOT := $(ROOT)/lwm2m
ram54288 0:dbad57390bd1 10 ROUTER_ROOT := $(ROOT)/Applications/NanoRouter
ram54288 0:dbad57390bd1 11
ram54288 0:dbad57390bd1 12 VERSION := $(shell cd $(ROOT) && git describe --tags --long --dirty --always)
ram54288 0:dbad57390bd1 13
ram54288 0:dbad57390bd1 14 # Specify list of sources to build
ram54288 0:dbad57390bd1 15 LWM2M_SRC := \
ram54288 0:dbad57390bd1 16 main.cpp \
ram54288 0:dbad57390bd1 17 cmd_commands.cpp \
ram54288 0:dbad57390bd1 18 cmd_lwm2m.cpp \
ram54288 0:dbad57390bd1 19 lwm2mtest.cpp \
ram54288 0:dbad57390bd1 20
ram54288 0:dbad57390bd1 21 CXX_SRCS += $(LWM2M_SRC)
ram54288 0:dbad57390bd1 22
ram54288 0:dbad57390bd1 23 HAL_SRCS += \
ram54288 0:dbad57390bd1 24 linux/arm_hal_interrupt.c \
ram54288 0:dbad57390bd1 25 linux/arm_hal_timer.c \
ram54288 0:dbad57390bd1 26 linux/ccm_mutex.c \
ram54288 0:dbad57390bd1 27
ram54288 0:dbad57390bd1 28 SRCS += $(addprefix $(ROOT)/Platforms/,$(HAL_SRCS))
ram54288 0:dbad57390bd1 29
ram54288 0:dbad57390bd1 30 EXE = lwm2mtestapplication
ram54288 0:dbad57390bd1 31
ram54288 0:dbad57390bd1 32 override CFLAGS += -DENDPOINT -DUSE_LINUX
ram54288 0:dbad57390bd1 33 override CFLAGS += -Wall -Wextra
ram54288 0:dbad57390bd1 34 override CFLAGS += -g
ram54288 0:dbad57390bd1 35 override CFLAGS += -pthread
ram54288 0:dbad57390bd1 36 override CFLAGS += -std=gnu99
ram54288 0:dbad57390bd1 37 override CFLAGS += -D'MEM_ALLOC=malloc' -D'MEM_FREE=free'
ram54288 0:dbad57390bd1 38
ram54288 0:dbad57390bd1 39 override CFLAGS += -DVERSION='"$(VERSION)"'
ram54288 0:dbad57390bd1 40
ram54288 0:dbad57390bd1 41 override CXXFLAGS += -I$(ROOT) -I$(NSDL_DIR)/nsdl-c -I$(LIBSERVICE_DIR)/libService -I$(ROOT)/nanostack/nanostack -I$(ROOT)/event-loop/nanostack-event-loop
ram54288 0:dbad57390bd1 42 override CXXFLAGS += -I$(LWM2M_ROOT) -I$(LWM2M_ROOT)/lwm2m-client
ram54288 0:dbad57390bd1 43 override CXXFLAGS += -DTARGET_LIKE_LINUX
ram54288 0:dbad57390bd1 44 override CXXFLAGS += -DHAVE_DEBUG
ram54288 0:dbad57390bd1 45 override CXXFLAGS += -g
ram54288 0:dbad57390bd1 46 # Generate dependency files when building
ram54288 0:dbad57390bd1 47 override CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
ram54288 0:dbad57390bd1 48
ram54288 0:dbad57390bd1 49 # Build with coverage
ram54288 0:dbad57390bd1 50 ifeq ($(COVERAGE), 1)
ram54288 0:dbad57390bd1 51 override CFLAGS += --coverage
ram54288 0:dbad57390bd1 52 override CXXFLAGS += --coverage
ram54288 0:dbad57390bd1 53 endif
ram54288 0:dbad57390bd1 54
ram54288 0:dbad57390bd1 55 #
ram54288 0:dbad57390bd1 56 # Libraries
ram54288 0:dbad57390bd1 57 #
ram54288 0:dbad57390bd1 58 NSDL_DIR := $(ROOT)/nsdl-c
ram54288 0:dbad57390bd1 59 LWM2M_DIR := $(ROOT)/lwm2m/lwm2m-client
ram54288 0:dbad57390bd1 60 MBEDTLS_DIR := $(ROOT)/mbedtls/library
ram54288 0:dbad57390bd1 61 LIBSERVICE_DIR := $(ROOT)/libService
ram54288 0:dbad57390bd1 62 override CFLAGS += -I$(ROOT) -I$(NSDL_DIR)/nsdl-c -I$(LIBSERVICE_DIR)/libService -I$(ROOT)/nanostack/nanostack -I$(ROOT)/event-loop/nanostack-event-loop
ram54288 0:dbad57390bd1 63 override CFLAGS += -I$(ROOT)/nanostack/Core/include -I$(ROOT)/Platforms/linux/include -I$(ROOT)/nanostack/HAL/common
ram54288 0:dbad57390bd1 64 override CFLAGS += -I$(ROUTER_ROOT)/include
ram54288 0:dbad57390bd1 65 override CFLAGS += -I$(ROOT)/Platforms/linux/include -I$(ROOT)/Drivers/linux -I$(ROOT)/Boards/linux
ram54288 0:dbad57390bd1 66 LDFLAGS += -D_REENTRANT
ram54288 0:dbad57390bd1 67 LDFLAGS += -L$(ROOT)/event-loop -leventOS_gcc
ram54288 0:dbad57390bd1 68 LDFLAGS += -L$(LWM2M_DIR) -lmbedclient_gcc
ram54288 0:dbad57390bd1 69 LDFLAGS += -L$(NSDL_DIR) -lnsdl_gcc
ram54288 0:dbad57390bd1 70 LDFLAGS += -L$(LIBSERVICE_DIR) -lCmdline_gcc -lservice_gcc
ram54288 0:dbad57390bd1 71 LDFLAGS += -L$(MBEDTLS_DIR) -lmbedtls -lmbedx509 -lmbedcrypto
ram54288 0:dbad57390bd1 72 LDFLAGS += -lpthread
ram54288 0:dbad57390bd1 73
ram54288 0:dbad57390bd1 74
ram54288 0:dbad57390bd1 75 # Main build goal, specify here before dependecy parsing
ram54288 0:dbad57390bd1 76 .DEFAULT_GOAL: all
ram54288 0:dbad57390bd1 77 .PHONY: all
ram54288 0:dbad57390bd1 78 all: $(EXE)
ram54288 0:dbad57390bd1 79
ram54288 0:dbad57390bd1 80 # Create a list of objects and depencies to build
ram54288 0:dbad57390bd1 81 OBJS := $(SRCS:.c=.o)
ram54288 0:dbad57390bd1 82 CXX_OBJS := $(CXX_SRCS:.cpp=.o)
ram54288 0:dbad57390bd1 83 DEPS += $$(SRCS:.c=.d) $$(CXX_SRCS:.cpp=.d)
ram54288 0:dbad57390bd1 84
ram54288 0:dbad57390bd1 85 # Include depencies
ram54288 0:dbad57390bd1 86 ifneq ($(MAKECMDGOALS),clean)
ram54288 0:dbad57390bd1 87 ifneq ($(strip $(DEPS)),)
ram54288 0:dbad57390bd1 88 -include $(DEPS)
ram54288 0:dbad57390bd1 89 endif
ram54288 0:dbad57390bd1 90 endif
ram54288 0:dbad57390bd1 91
ram54288 0:dbad57390bd1 92 # Linking
ram54288 0:dbad57390bd1 93 $(EXE): $(OBJS) $(CXX_OBJS)
ram54288 0:dbad57390bd1 94 @echo 'Building target: $@'
ram54288 0:dbad57390bd1 95 g++ $(CXXFLAGS) $(CFLAGS) -o $@ $(OBJS) $(CXX_OBJS) $(LDFLAGS)
ram54288 0:dbad57390bd1 96 @echo 'Finished building target: $@'
ram54288 0:dbad57390bd1 97 @echo ' '
ram54288 0:dbad57390bd1 98
ram54288 0:dbad57390bd1 99 .PHONY: clean
ram54288 0:dbad57390bd1 100 clean:
ram54288 0:dbad57390bd1 101 -$(RM) $(OBJS) $(CXX_OBJS) $(DEPS) $(EXE)