-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
42 lines (33 loc) · 966 Bytes
/
Makefile
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
# static library
SRC_LIB := eekf.c eekf_mat.c
TARGET_LIB := libeekf.a
OBJS_LIB := ${SRC_LIB:.c=.o}
# example program
SRC_EXAMPLE := examples/eekf_example.c
TARGET_EXAMPLE := examples/eekf_example
OBJS_EXAMPLE := ${SRC_EXAMPLE:.c=.o} $(TARGET_LIB)
# build params
BUILD_DIR := ./build
SRC_DIR := ./src
INCLUDE_DIRS := ./includes
VPATH := src
include toolchain_gcc.mk
.PHONY: clean
all: $(TARGET_LIB) $(TARGET_EXAMPLE)
# eekf archive
$(TARGET_LIB): $(OBJS_LIB)
@echo "[AR] archiving $@"
@$(AR) $(BUILD_DIR)/$(TARGET_LIB) $(addprefix $(BUILD_DIR)/, $(OBJS_LIB))
# example program
$(TARGET_EXAMPLE): $(OBJS_EXAMPLE)
@echo "[LD] linking $@"
@$(CC) -o $(BUILD_DIR)/$(TARGET_EXAMPLE) $(addprefix $(BUILD_DIR)/, $(OBJS_EXAMPLE)) $(LDFLAGS)
# compile rule
%.o: %.c
@echo "[CC] compiling $@"
@mkdir -p $(BUILD_DIR)/$(dir $@)
@$(CC) $(CFLAGS) -c -o $(BUILD_DIR)/$@ $<
# clean up rule
clean:
@echo "[CLEAN] cleaning build files"
@$(RM) -r $(BUILD_DIR)