-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
167 lines (147 loc) · 2.47 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
include config.mk
.SUFFIXES:
.SUFFIXES: .o .c
INC= inc
HDR=\
inc/common.h
# BIN
BIN=\
src/basename\
src/cat\
src/chgrp\
src/chmod\
src/chown\
src/cksum\
src/cmp\
src/cp\
src/digest\
src/dirname\
src/du\
src/echo\
src/env\
src/false\
src/head\
src/hostname\
src/id\
src/install\
src/link\
src/ln\
src/ls\
src/mkdir\
src/mkfifo\
src/mknod\
src/mktemp\
src/mv\
src/pathchk\
src/printenv\
src/printf\
src/pwd\
src/rm\
src/rmdir\
src/sleep\
src/tail\
src/tee\
src/true\
src/uname\
src/unlink\
src/wc\
src/whoami\
src/yes
# MAN
MAN1=\
man/basename.1\
man/cat.1\
man/chgrp.1\
man/chmod.1\
man/chown.1\
man/cksum.1\
man/cmp.1\
man/cp.1\
man/digest.1\
man/dirname.1\
man/du.1\
man/echo.1\
man/env.1\
man/false.1\
man/head.1\
man/hostname.1\
man/id.1\
man/install.1\
man/link.1\
man/ln.1\
man/ls.1\
man/mkdir.1\
man/mkfifo.1\
man/mknod.1\
man/mktemp.1\
man/mv.1\
man/pathchk.1\
man/printenv.1\
man/printf.1\
man/pwd.1\
man/rm.1\
man/rmdir.1\
man/tail.1\
man/tee.1\
man/true.1\
man/uname.1\
man/unlink.1\
man/wc.1\
man/whoami.1\
man/yes.1
# LIB SRC
LIBCOMMONSRC=\
lib/common/cp.c\
lib/common/deepsleep.c\
lib/common/estrtovl.c\
lib/common/mkpath.c\
lib/common/path.c\
lib/common/pathcat.c\
lib/common/pdb.c\
lib/common/rm.c\
lib/common/strtomode.c\
lib/common/tmpargv.c\
lib/common/yesno.c
# LIB PATH
LIBCOMMON= lib/libcommon.a
# LIB OBJS
LIBCOMMONOBJ= $(LIBCOMMONSRC:.c=.o)
# ALL
LIB= $(LIBCOMMON)
OBJ= $(BIN:=.o) $(LIBCOMMONOBJ)
SRC= $(BIN:=.c)
# VAR RULES
all: $(BIN)
$(BIN): $(LIB) $(@:=.o)
$(OBJ): $(HDR) config.mk
# SUFFIX RULES
.o:
$(CC) $(LDFLAGS) -o $@ $< $(LIB) -ltertium
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -I $(INC) -o $@ -c $<
# LIBRARIES RULES
$(LIBCOMMON): $(LIBCOMMONOBJ)
$(AR) rc $@ $(LIBCOMMONOBJ)
$(RANLIB) $@
# RULES
ecore: build/ecore.sh $(LIB) $(SRC)
build/ecore.sh $(SRC)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -I $(INC) -o $@ tmpbuild/*.c $(LIB) -ltertium
rm -Rf tmpbuild
install-man:
install -dm 755 $(DESTDIR)/$(MANDIR)/man1
install -cm 644 $(MAN1) $(DESTDIR)/$(MANDIR)/man1
install: install-man all
install -dm 755 $(DESTDIR)/$(BINDIR)
install -cm 755 $(BIN) $(DESTDIR)/$(BINDIR)
install-ecore: ecore install-man
install -dm 755 $(DESTDIR)/$(BINDIR)
install -cm 755 ecore $(DESTDIR)/$(BINDIR)
for f in $(BIN); do\
ln -s ecore $(DESTDIR)/$(BINDIR)/$$(basename $$f);\
done
clean:
rm -Rf tmpbuild
rm -f ecore $(BIN) $(OBJ) $(LIB)
.PHONY:
all ecore clean install install-ecore install-man