-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
63 lines (40 loc) · 964 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
TARGET = cracker
#
BUILD_DIR = build-$(shell $(CC) -dumpmachine)
TOP_DIR = $(PWD)
#
INCLUDE += -Iinclude
INCLUDE += -I../../../include
INCLUDE += -I../../csx-master/include
#
CFLAGS = -g -Wall -Wextra
CFLAGS += $(INCLUDE)
CFLAGS += -MD -MP
LDFLAGS += -lcapstone
#
SRC_DIR = source
OBJ_DIR = $(TOP_DIR)/$(BUILD_DIR)
all: $(OBJS) $(TARGET)
#
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
DEPS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.d, $(SRCS))
#
$(BUILD_DIR):
-mkdir -p $(TOP_DIR)/$(BUILD_DIR)
$(OBJ_DIR): $(BUILD_DIR)
-mkdir -p $(OBJ_DIR)
#
$(TARGET) : $(OBJ_DIR) $(OBJ_DIR)/$(TARGET)
ln -s -r $(OBJ_DIR)/$(TARGET) $(TOP_DIR)/$(TARGET)
$(OBJ_DIR)/$(TARGET) : $(OBJS)
$(CC) $(LFLAGS) $^ -o $@ $(LDFLAGS)
$(OBJS) : $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
#
clean:
-rm $(OBJ_DIR)/*.d
-rm $(OBJ_DIR)/*.o
-rm $(OBJ_DIR)/$(TARGET)
#
-include $(OBJ_DIR)/*.d