-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
124 lines (85 loc) · 2.35 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
#
# Mike Glover
#
# Makefile for quotatool
#
#
#
# BEGIN setting variables
#
# local configuration options
-include ./local.mk
# keep track of our current location
dir := $(srcdir)
# these get built by the included dir.mk's
dirs := .
srcs :=
libs :=
inc :=
auto := $(wildcard $(dir)/*.in)
objs = $(srcs:.c=.o)
# look for a dir.mk in these subdirectories
subdirs := src
#
# END setting variables
# BEGIN including subfiles
#
# include the fragment from each directory
-include $(foreach sdir,$(subdirs),$(dir)/$(sdir)/dir.mk)
#
# END including subfiles
# BEGIN rules
#
# clear out the suffix list and rewrite
.SUFFIXES:
.SUFFIXES: .c .o
.INTERMEDIATE: .d
.PHONY: all clean distclean dist install uninstall
# compile the program (and the objects)
all: $(prog)
$(prog): $(objs)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(prog) $(objs) $(libs)
men := $(wildcard $(srcdir)/man/*)
install: $(prog)
$(NORMAL_INSTALL)
$(INSTALL_PROGRAM) -D $(srcdir)/$(prog) $(DESTDIR)$(sbindir)/$(prog)
$(foreach man,$(men),$(INSTALL_DATA) -D $(man) $(DESTDIR)$(mandir)/man$(subst .,,$(suffix $(man)))/$(notdir $(man)))
uninstall:
$(NORMAL_UNINSTALL)
rm -f $(bindir)/$(prog)
rm -f $(foreach man,$(notdir $(men)), $(mandir)/$(man))
distdir := $(package)-$(version)
dist: distclean
mkdir ./.$(distdir)
cp -fR $(srcdir)/* ./.$(distdir) || true
rm -rf ./.$(distdir)/*johan*
rm -rf ./.$(distdir)/FILESYSTEMS
mv ./.$(distdir) ./$(distdir)
tar -zcvf ./$(distdir).tar.gz $(distdir)
rm -rf ./$(distdir)
cfixes := ~ .o
clean:
rm -f $(foreach sfix,$(cfixes),$(addsuffix /*$(sfix),$(dirs)))
rm -f $(addsuffix /core,$(dirs))
rm -f $(prog)
rm -f $(foreach sfix,$(cfixes),$(addsuffix /*$(sfix),$(DESTDIR)$(srcdir)/man))
rm -f $(foreach sfix,$(cfixes),$(addsuffix /*$(sfix),$(DESTDIR)$(srcdir)/tools))
dcfixes := .d
distclean: clean
rm -f $(foreach sfix,$(dcfixes),$(addsuffix /*$(sfix),$(dirs)))
rm -f $(filter-out %/configure,$(auto:.in=))
rm -f $(srcdir)/config.*
rm -rf ./$(distdir) ./*.tar.gz
# include object dependencies
-include $(objs:.o=.d)
#
# END rules
# BEGIN pattern rules
#
# create dependencies automatically from .c files
%.d: %.c
$(srcdir)/tools/depend.sh $(CPPFLAGS) $< > $@
# create shared library from a collection of object
%.so:
$(CC) -shared -Xlinker -x -o $@ $^ $(libs)