-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (48 loc) · 1.14 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
# opfs: a simple utility for manipulating xv6 file system images
# Copyright (c) 2015-2020 Takuo Watanabe
PREFIX = ~/.local
XV6HDRS = types.h fs.h
HDRS = libfs.h $(XV6HDRS)
SRCS = opfs.c newfs.c modfs.c libfs.c
OBJS = $(SRCS:%.c=%.o)
LIBS = libfs.o
EXES = opfs newfs modfs
TAGFILES = GTAGS GRTAGS GPATH
CC = gcc
WFLAGS =
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Werror $(WFLAGS) -g
CPPFLAGS = # -DNDEBUG
LDFLAGS =
OPTFLAGS = -O3
ifeq ($(shell uname),Darwin)
CC = clang
endif
ifeq ($(shell uname),Linux)
WFLAGS = -Wno-stringop-truncation
endif
INSTALL = install
RM = rm -f
CP = cp
GTAGS = gtags
%.o: %.c $(HDRS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) -c $<
.PHONY: all install tags clean allclean
.PRECIOUS: %.o
all: $(EXES)
opfs: opfs.o $(LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OPTFLAGS) -o $@ $^
newfs: newfs.o $(LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OPTFLAGS) -o $@ $^
modfs: modfs.o $(LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OPTFLAGS) -o $@ $^
install: $(EXES)
$(INSTALL) -d $(PREFIX)/bin
$(INSTALL) $^ $(PREFIX)/bin
tags: $(HDRS) $(SRCS)
$(GTAGS) -v
clean:
$(RM) $(EXES)
$(RM) $(OBJS)
allclean: clean
$(RM) $(TAGFILES)
$(RM) a.out *.o *~ .*~