Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Commit e5a1b94

Browse files
committed
use BINDIR in Makefile
Change-Id: I0a6a051d26f8bc82e5172c9905ef46b34fa12ed5
1 parent edeedb1 commit e5a1b94

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

Makefile

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
2222
HELPER ?=
2323
BINEXT ?=
24+
BINDIR ?= $(CURDIR)
2425
SOLIBNAME = libhttp_parser
2526
SOMAJOR = 2
2627
SOMINOR = 8
@@ -72,75 +73,75 @@ else
7273
LDFLAGS_LIB += -Wl,-soname=$(SONAME)
7374
endif
7475

75-
test: test_g test_fast
76-
$(HELPER) ./test_g$(BINEXT)
77-
$(HELPER) ./test_fast$(BINEXT)
76+
test: $(BINDIR)/test_g $(BINDIR)/test_fast
77+
$(HELPER) $(BINDIR)/test_g$(BINEXT)
78+
$(HELPER) $(BINDIR)/test_fast$(BINEXT)
7879

79-
test_g: http_parser_g.o test_g.o
80-
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
80+
$(BINDIR)/test_g: $(BINDIR)/http_parser_g.o $(BINDIR)/test_g.o
81+
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) -o $@ $^
8182

82-
test_g.o: test.c http_parser.h Makefile
83+
$(BINDIR)/test_g.o: test.c http_parser.h Makefile
8384
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@
8485

85-
http_parser_g.o: http_parser.c http_parser.h Makefile
86+
$(BINDIR)/http_parser_g.o: http_parser.c http_parser.h Makefile
8687
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@
8788

88-
test_fast: http_parser.o test.o http_parser.h
89-
$(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@
89+
$(BINDIR)/test_fast: $(BINDIR)/http_parser.o $(BINDIR)/test.o http_parser.h
90+
$(CC) $(CFLAGS_FAST) $(LDFLAGS) $(BINDIR)/http_parser.o $(BINDIR)/test.o -o $@
9091

91-
test.o: test.c http_parser.h Makefile
92+
$(BINDIR)/test.o: test.c http_parser.h Makefile
9293
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@
9394

94-
bench: http_parser.o bench.o
95-
$(CC) $(CFLAGS_BENCH) $(LDFLAGS) http_parser.o bench.o -o $@
95+
$(BINDIR)/bench: $(BINDIR)/http_parser.o $(BINDIR)/bench.o
96+
$(CC) $(CFLAGS_BENCH) $(LDFLAGS) -o $@ $<
9697

97-
bench.o: bench.c http_parser.h Makefile
98+
$(BINDIR)/bench.o: bench.c http_parser.h Makefile
9899
$(CC) $(CPPFLAGS_BENCH) $(CFLAGS_BENCH) -c bench.c -o $@
99100

100-
http_parser.o: http_parser.c http_parser.h Makefile
101-
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
101+
$(BINDIR)/http_parser.o: http_parser.c http_parser.h Makefile
102+
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c -o $@
102103

103-
test-run-timed: test_fast
104-
while(true) do time $(HELPER) ./test_fast$(BINEXT) > /dev/null; done
104+
test-run-timed: $(BINDIR)/test_fast
105+
while(true) do time $(HELPER) $(BINDIR)/test_fast$(BINEXT) > /dev/null; done
105106

106-
test-valgrind: test_g
107-
valgrind ./test_g
107+
test-valgrind: $(BINDIR)/test_g
108+
valgrind $(BINDIR)/test_g
108109

109-
libhttp_parser.o: http_parser.c http_parser.h Makefile
110-
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o
110+
$(BINDIR)/libhttp_parser.o: http_parser.c http_parser.h Makefile
111+
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o $@
111112

112-
library: libhttp_parser.o
113-
$(CC) $(LDFLAGS_LIB) -o $(LIBNAME) $<
113+
library: $(BINDIR)/libhttp_parser.o
114+
$(CC) $(LDFLAGS_LIB) -o $(BINDIR)/$(LIBNAME) $<
114115

115-
package: http_parser.o
116-
$(AR) rcs libhttp_parser.a http_parser.o
116+
package: $(BINDIR)/http_parser.o
117+
$(AR) rcs $(BINDIR)/libhttp_parser.a $(BINDIR)/http_parser.o
117118

118-
url_parser: http_parser.o contrib/url_parser.c
119+
$(BINDIR)/url_parser: $(BINDIR)/http_parser.o contrib/url_parser.c
119120
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $@
120121

121-
url_parser_g: http_parser_g.o contrib/url_parser.c
122+
$(BINDIR)/url_parser_g: $(BINDIR)/http_parser_g.o contrib/url_parser.c
122123
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@
123124

124-
parsertrace: http_parser.o contrib/parsertrace.c
125-
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT)
125+
parsertrace: $(BINDIR)/http_parser.o contrib/parsertrace.c
126+
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $(BINDIR)/parsertrace$(BINEXT)
126127

127-
parsertrace_g: http_parser_g.o contrib/parsertrace.c
128-
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT)
128+
parsertrace_g: $(BINDIR)/http_parser_g.o contrib/parsertrace.c
129+
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $(BINDIR)/parsertrace_g$(BINEXT)
129130

130131
tags: http_parser.c http_parser.h test.c
131132
ctags $^
132133

133134
install: library
134135
$(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
135-
$(INSTALL) -D $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
136-
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
137-
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
136+
$(INSTALL) -D $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
137+
ln -s $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
138+
ln -s $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
138139

139140
install-strip: library
140141
$(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
141-
$(INSTALL) -D -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
142-
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
143-
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
142+
$(INSTALL) -D -s $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
143+
ln -s $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
144+
ln -s $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
144145

145146
uninstall:
146147
rm $(DESTDIR)$(INCLUDEDIR)/http_parser.h
@@ -149,7 +150,7 @@ uninstall:
149150
rm $(DESTDIR)$(LIBDIR)/$(LIBNAME)
150151

151152
clean:
152-
rm -f *.o *.a tags test test_fast test_g \
153+
rm -f tags && cd $(BINDIR) && rm -f *.o *.a tags test test_fast test_g \
153154
http_parser.tar libhttp_parser.so.* \
154155
url_parser url_parser_g parsertrace parsertrace_g \
155156
*.exe *.exe.so

0 commit comments

Comments
 (0)