-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (58 loc) · 1.41 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
# Target programs
programs := test-fs.x
# User-level thread library
UTHREADLIB=libuthread
libuthread := $(UTHREADLIB)/$(UTHREADLIB).a
# Default rule
all: $(libuthread) $(programs)
# Assignement
README.html:
# Avoid builtin rules and variables
MAKEFLAGS += -rR
# Don't print the commands unless explicitely requested with `make V=1`
ifneq ($(V),1)
Q = @
V = 0
endif
# Current directory
CUR_PWD := $(shell pwd)
# Define compilation toolchain
CC = gcc
# General gcc options
CFLAGS := -Wall -Werror
CFLAGS += -O2
#CFLAGS += -O0
#CFLAGS += -g
CFLAGS += -pipe
CFLAGS += -lm
# Include path
INCLUDE := -I$(UTHREADLIB)
# Generate dependencies
DEPFLAGS = -MMD -MF $(@:.o=.d)
# Application objects to compile
objs := $(patsubst %.x,%.o,$(programs))
# Include dependencies
deps := $(patsubst %.o,%.d,$(objs))
-include $(deps)
# Rule for libuthread.a
$(libuthread):
@echo "MAKE $@"
$(Q)$(MAKE) V=$(V) -C $(UTHREADLIB)
# Generic rule for linking final applications
%.x: %.o $(libuthread)
@echo "LD $@"
$(Q)$(CC) $(CFLAGS) -o $@ $< -L$(UTHREADLIB) -luthread
# Generic rule for compiling objects
%.o: %.c
@echo "CC $@"
$(Q)$(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< $(DEPFLAGS)
# Generic rule for markdown
%.html: %.md
@echo "MKDN $@"
$(Q)pandoc -s --toc -o $@ $<
# Cleaning rule
clean:
@echo "CLEAN $(CUR_PWD)"
$(Q)$(MAKE) V=$(V) -C $(UTHREADLIB) clean
$(Q)rm -rf $(objs) $(deps) $(programs) README.html
.PHONY: clean $(libuthread)