-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (32 loc) · 786 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
INC_DIR = include
OBJ_DIR := obj
SRC_DIR := src
BIN_DIR := bin
LDFLAGS = -L.
FAT_BIN = $(BIN_DIR)/fat_test
CC = gcc -Wall
LD = ld
all: cscope_create fat_test
SRC_FILES := $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*.c))
OBJ_FILES := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
CFLAGS = -g -I$(INC_DIR)
fat_test: $(OBJ_DIR) $(BIN_DIR) $(OBJ_FILES) $(FAT_BIN)
$(FAT_BIN): $(OBJ_FILES)
$(CC) -Wall -o $(FAT_BIN) $(OBJ_FILES) $(LDFLAGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) -c $(CFLAGS) $< -o $@
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(BIN_DIR):
mkdir -p $(BIN_DIR)
cscope_create:
cscope -R -q -b
cleanall: clean cleandir cscope_clean
clean:
rm -fv $(BIN_DIR)/*
rm -fv $(OBJ_DIR)/*
cleandir:
rm -df $(BIN_DIR)
rm -df $(OBJ_DIR)
cscope_clean:
rm -fv *.out