-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (28 loc) · 948 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
SOURCES := main.c elevator_fsm.c elevator_io.c queue.c timer.c
SOURCE_DIR := source
BUILD_DIR := build
DOX_DIR := dox
OBJ := $(patsubst %.c,$(BUILD_DIR)/%.o,$(SOURCES))
OUT := elevator
DRIVER_ARCHIVE := $(BUILD_DIR)/libdriver.a
DRIVER_SOURCE := hardware.c io.c
CC := gcc
# CFLAGS := -O0 -g3 -Wall -Werror -std=c11 -I$(SOURCE_DIR)
CFLAGS := -O0 -g3 -Wall -Wno-unused-variable -Wno-switch -std=c11 -I$(SOURCE_DIR)
LDFLAGS := -L$(BUILD_DIR) -ldriver -lcomedi
.DEFAULT_GOAL := $(OUT)
elevator : $(OBJ) | $(DRIVER_ARCHIVE)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
$(BUILD_DIR) :
mkdir -p $@/driver
$(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/driver/%.o : $(SOURCE_DIR)/driver/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(DRIVER_ARCHIVE) : $(DRIVER_SOURCE:%.c=$(BUILD_DIR)/driver/%.o)
ar rcs $@ $^
.PHONY: clean clean_dox
clean :
rm -rf $(BUILD_DIR) $(OUT)
clean_dox:
rm -rf $(DOX_DIR)