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