-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (44 loc) · 1.08 KB
/
Copy pathMakefile
File metadata and controls
50 lines (44 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
TARGET := app
PLATFORM ?= posix
CC ?= gcc
RTOS_DEFS ?=
ifeq ($(strip $(PLATFORM)),posix)
LDFLAGS += -lrt
RTOS_DEFS += -DPORT_POSIX
endif
# path
RTOS_PATH = $(abspath ./igorsrtos)
APP_PATH = $(abspath ./)
RTOS_SOURCE_PATH = $(RTOS_PATH)/source
RTOS_PORTS_PATH = $(RTOS_PATH)/ports
RTOS_INCLUDES_PATH = $(RTOS_PATH)/include
BUILD_DIR = $(APP_PATH)/build
# app sources
APP_SRC := main.c
# rtos sources to compile with app
APP_SRC += rtos.c
APP_SRC += tasks.c
APP_SRC += thread.c
APP_SRC += mutex.c
APP_SRC += $(strip $(PLATFORM)).c
# app includes
INCFLAGS +=-I$(APP_PATH)
# rtos includes
INCFLAGS += -I$(RTOS_PATH)
INCFLAGS += -I$(RTOS_INCLUDES_PATH)
CFLAGS = -c -g -Wall
# build
COBJS = $(patsubst %.c,%.o,$(APP_SRC))
# deps rules
.PHONY: all clean
# Path to directories containing application source
vpath %.c $(APP_PATH):$(RTOS_SOURCE_PATH):$(RTOS_PORTS_PATH)
all: $(APP_SRC) $(COBJS) $(TARGET).elf
%.o: %.c $(BUILD_DIR)
$(CC) $(CFLAGS) $(RTOS_DEFS) $(INCFLAGS) -c $< -o $@
$(TARGET).elf: $(COBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(INCFLAGS)
clean:
rm -rf *.o
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)