-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
44 lines (22 loc) · 780 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
43
44
CFLAGS = -g -Wall -O2 $(INCLUDE)
CFLAGS += -MD -MP
TARGET := vm
SRC_DIR := source
OBJ_DIR := build-$(shell $(CC) -dumpmachine)
INCLUDE = -Iinclude -I../include
INCLUDE += -I../../lib_dtime
VPATH = ./include:../include:../../include:../lib_dtime
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
DEPS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.d, $(SRCS))
all: $(OBJ_DIR) $(OBJ_DIR)/$(OBJS) target
target: $(OBJ_DIR)/$(TARGET)
$(OBJ_DIR):
-mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/$(TARGET) : $(OBJS)
$(CC) $(LFLAGS) $^ -o $@ $(LDFLAGS)
$(OBJS) : $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
clean:
-rm -rf $(OBJ_DIR)/*.d $(OBJ_DIR)/*.o $(OBJ_DIR)/$(TARGET) *.i *.s *.o *.d
-include $(BUILD)/*.d