forked from rakitzis/rc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (114 loc) · 3.6 KB
/
Makefile
File metadata and controls
151 lines (114 loc) · 3.6 KB
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
# line editing library: null, edit, editline, readline, vrl, bestline
EDIT = null
srcdir = .
VPATH = $(srcdir)
VERSION = 1.7.4
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
_CFLAGS = -Wall $(CFLAGS)
_CPPFLAGS = -I. -I$(srcdir) -I$(PREFIX)/include $(CPPFLAGS)
_LDFLAGS = -L$(PREFIX)/lib $(LDFLAGS)
BINS = history mksignal mkstatval tripping
HEADERS = edit.h getgroups.h input.h jbwrap.h proto.h rc.h rlimit.h stat.h \
wait.h
GEN_HEADERS = sigmsgs.h
OBJS = addon.o builtins.o calc.o edit-$(EDIT).o except.o exec.o fn.o \
footobar.o getopt.o glob.o glom.o hash.o heredoc.o input.o lex.o \
list.o main.o match.o nalloc.o open.o parse.o print.o redir.o \
sigmsgs.o signal.o status.o system.o tree.o utils.o var.o wait.o \
walk.o which.o
all: rc
.PHONY: all check clean distclean install trip
.SUFFIXES:
.SUFFIXES: .c .o .y
$(V).SILENT:
rc: $(OBJS)
@echo "LINK $@"
[ "$(EDIT)" = "null" ] && ledit="" || ledit="-l$(EDIT)"; \
$(CC) $(_LDFLAGS) $(_CFLAGS) -o $@ $(OBJS) $$ledit $(LDLIBS)
tripping: tripping.o
@echo "LINK $@"
$(CC) $(_LDFLAGS) $(_CFLAGS) -o $@ $<
tripping.o: tripping.c
$(OBJS): Makefile $(HEADERS) $(GEN_HEADERS) config.h
builtins.o: addon.c
exec.o: execve.c
input.o: develop.c
system.o: system-bsd.c
.c.o:
@echo "CC $@"
$(CC) $(_CPPFLAGS) $(_CFLAGS) -c -o $@ $<
config.h:
@echo "GEN $@"
cp "$(srcdir)/config.def.h" $@
lex.o addon.o: parse.tab.h
parse.o: parse.c parse.tab.h
calc.o: calc.c calc.tab.h
YACC=bison -d
parse.c parse.tab.h: parse.y
@echo "GEN $@": $(YACC) parse -b parse -d $<
$(YACC) -b parse -d $<
mv parse.tab.c parse.c
# mv parse.tab.h parse.h
calc.c calc.tab.h: calc.y
@echo "GEN $@": $(YACC) -p calc -b calc -d $<
$(YACC) -b calc -p calc -d $<
mv calc.tab.c calc.c
# mv calc.tab.h calc.h
addon.o builtins.o fn.o hash.o sigmsgs.o signal.o status.o: sigmsgs.c
sigmsgs.c sigmsgs.h: mksignal
@echo "GEN $@"
./mksignal
status.o: statval.h
statval.h: mkstatval
@echo "GEN $@"
./mkstatval >$@
$(BINS): Makefile rc.h proto.h config.h
main.o: version.h
version.h: Makefile .git/index
@echo "GEN $@"
v="$$(cd $(srcdir) && git describe --always 2>/dev/null || true)"; \
echo "#ifndef VERSION" >$@
echo "#define VERSION \"$${v:-$(VERSION)}\"" >>$@
echo "#endif" >>$@
.git/index:
.c:
@echo "CC $@"
$(CC) $(_CPPFLAGS) $(_CFLAGS) -o $@ $<
check: trip testhist
trip: rc tripping
@echo run trip.rc
./rc -p <"$(srcdir)/trip.rc"
testhist: history
cd "$(srcdir)/test-history" && make
acutest.h:; wget --compression=gzip https://raw.githubusercontent.com/mity/acutest/master/include/acutest.h
test-bestline.o: test-bestline.c edit-bestline.c acutest.h
test-bestline: test-bestline.o $(filter-out main.o edit-null.o ,$(OBJS))
$(CC) $(_LDFLAGS) $(_CFLAGS) -o $@ $^ -lbestline $(LDLIBS)
run-test-bestline: test-bestline
mkdir -p /tmp/rc/fakebin
touch /tmp/rc/hello /tmp/rc/world '/tmp/rc/world wide' "/tmp/rc/it's rc"
touch /tmp/rc/fakebin/vim /tmp/rc/fakebin/emacs /tmp/rc/fakebin/ed
chmod +x /tmp/rc/fakebin/vim /tmp/rc/fakebin/emacs /tmp/rc/fakebin/ed
./test-bestline
clean:
rm -f *.o $(BINS) rc
distclean: clean
rm -f config.h sigmsgs.[ch] statval.h version.h
install: all
@echo "INSTALL bin/"
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp rc $(DESTDIR)$(PREFIX)/bin/
chmod 755 $(DESTDIR)$(PREFIX)/bin/rc
if [ -f history ]; then \
cp history $(DESTDIR)$(PREFIX)/bin/ && \
chmod 755 $(DESTDIR)$(PREFIX)/bin/history; \
fi
@echo "INSTALL rc.1"
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
cp rc.1 $(DESTDIR)$(MANPREFIX)/man1/
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/rc.1
if [ -f history ]; then \
cp history.1 $(DESTDIR)$(MANPREFIX)/man1/ && \
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/history.1; \
fi