-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (95 loc) · 3.09 KB
/
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# GNU Makefile
build ?= release
OUT := build/$(build)
default: all
# Do not specify CFLAGS or LIBS on the make invocation line - specify
# XCFLAGS or XLIBS instead. Make ignores any lines in the makefile that
# set a variable that was set on the command line.
CFLAGS += $(XCFLAGS) -Iinclude
LIBS += $(XLIBS) -lm
LIBS += $(ZLIB_LIBS)
CFLAGS += $(ZLIB_CFLAGS)
ALL_DIR += $(OUT)/source/hdtd
ALL_DIR += $(OUT)/source/dos
ALL_DIR += $(OUT)/source/gpt
ALL_DIR += $(OUT)/source/ntfs
ALL_DIR += $(OUT)/source/ext
# --- Commands ---
ifneq "$(verbose)" "yes"
QUIET_AR = @ echo ' ' ' ' AR $@ ;
QUIET_CC = @ echo ' ' ' ' CC $@ ;
QUIET_CXX = @ echo ' ' ' ' CXX $@ ;
QUIET_GEN = @ echo ' ' ' ' GEN $@ ;
QUIET_LINK = @ echo ' ' ' ' LINK $@ ;
QUIET_MKDIR = @ echo ' ' ' ' MKDIR $@ ;
QUIET_RM = @ echo ' ' ' ' RM $@ ;
QUIET_TAGS = @ echo ' ' ' ' TAGS $@ ;
QUIET_WINDRES = @ echo ' ' ' ' WINDRES $@ ;
endif
CC_CMD = $(QUIET_CC) $(CC) $(CFLAGS) -o $@ -c $<
CXX_CMD = $(QUIET_CXX) $(CXX) $(filter-out -Wdeclaration-after-statement,$(CFLAGS)) -o $@ -c $<
AR_CMD = $(QUIET_AR) $(AR) cr $@ $^
LINK_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
MKDIR_CMD = $(QUIET_MKDIR) mkdir -p $@
RM_CMD = $(QUIET_RM) rm -f $@
TAGS_CMD = $(QUIET_TAGS) ctags $^
WINDRES_CMD = $(QUIET_WINDRES) $(WINDRES) $< $@
# --- Rules ---
$(ALL_DIR) $(OUT) :
$(MKDIR_CMD)
$(OUT)/%.a :
$(AR_CMD)
$(OUT)/%.exe: $(OUT)/%.o | $(ALL_DIR)
$(LINK_CMD)
$(OUT)/%.o : %.c | $(ALL_DIR)
$(CC_CMD)
.PRECIOUS : $(OUT)/%.o # Keep intermediates from chained rules
# --- File lists ---
HDTDHDR := include/hdtd.h $(wildcard include/hdtd/*.h)
DOS_HDR := include/dos.h $(wildcard include/dos/*.h)
GPT_HDR := include/gpt.h $(wildcard include/gpt/*.h)
NTFS_HDR := include/ntfs.h $(wildcard include/ntfs/*.h)
EXT_HDR := include/ntfs.h $(wildcard include/ext/*.h)
HDTDSRC := $(sort $(wildcard source/hdtd/*.c))
DOS_SRC := $(sort $(wildcard source/dos/*.c))
GPT_SRC := $(sort $(wildcard source/gpt/*.c))
NTFS_SRC := $(sort $(wildcard source/ntfs/*.c))
EXT_SRC := $(sort $(wildcard source/ext/*.c))
HDTDSRC_HDR := $(wildcard source/hdtd/*.h)
DOS_SRC_HDR := $(wildcard source/dos/*.h)
GPT_SRC_HDR := $(wildcard source/gpt/*.h)
NTFS_SRC_HDR := $(wildcard source/ntfs/*.h)
EXT_SRC_HDR := $(wildcard source/ext/*.h)
HDTDOBJ := $(HDTDSRC:%.c=$(OUT)/%.o)
DOS_OBJ := $(DOS_SRC:%.c=$(OUT)/%.o)
GPT_OBJ := $(GPT_SRC:%.c=$(OUT)/%.o)
NTFS_OBJ := $(NTFS_SRC:%.c=$(OUT)/%.o)
EXT_OBJ := $(EXT_SRC:%.c=$(OUT)/%.o)
$(HDTDOBJ) : $(HDTDHDR) $(HDTDSRC_HDR)
$(DOS_OBJ) : $(HDTDHDR) $(DOS_HDR) $(DOS_SRC_HDR)
$(GPT_OBJ) : $(HDTDHDR) $(GPT_HDR) $(GPT_SRC_HDR)
$(NTFS_OBJ) : $(HDTDHDR) $(NTFS_HDR) $(NTFS_SRC_HDR)
$(DOS_OBJ) : $(HDTDSRC_HDR)
$(GPT_OBJ) : $(HDTDSRC_HDR)
$(NTFS_OBJ) : $(HDTDSRC_HDR)
$(EXT_OBJ) : $(HDTDSRC_HDR)
# --- Library ---
HDDISKCLOEN_LIB = $(OUT)/libdc.a
MHDDISKCLOEN_OBJ := \
$(HDTDOBJ) \
$(DOS_OBJ) \
$(GPT_OBJ) \
$(NTFS_OBJ) \
$(EXT_OBJ) \
$(HDDISKCLOEN_LIB) : $(MHDDISKCLOEN_OBJ)
INSTALL_LIBS := $(HDDISKCLOEN_LIB)
libs: $(HDDISKCLOEN_LIB)
# --- Clean and Default ---
all: libs
clean:
rm -rf $(OUT)
release:
$(MAKE) build=release
debug:
$(MAKE) build=debug
.PHONY: all clean libs