-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (37 loc) · 925 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
CC = gcc
# compiling flags here
CFLAGS = -Wall -Wextra -Wno-unused-parameter -std=c99
LINKER = gcc
# linking flags here
LFLAGS =
# change these to proper directories where each file should be
SRCDIR = src
INCDIR = module
OBJDIR = obj
BINDIR = bin
BIN_NAME = ksh_tool
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(INCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
RM = rm -rf
MKDIR_P = mkdir -p
all: out_directories module tool
.PHONY: module
module:
make -C module
.PHONY: tool
tool: out_directories $(BINDIR)/$(BIN_NAME)
$(BINDIR)/$(BIN_NAME): $(OBJECTS)
$(LINKER) $(LFLAGS) -o $@ $^
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
.PHONY: out_directories
out_directories:
$(MKDIR_P) $(OBJDIR) $(BINDIR)
.PHONY: clean
clean:
$(RM) $(OBJDIR)
make -C module clean
.PHONY: remove
remove: clean
$(RM) $(BINDIR)