21
21
PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
22
22
HELPER ?=
23
23
BINEXT ?=
24
+ BINDIR ?= $(CURDIR )
24
25
SOLIBNAME = libhttp_parser
25
26
SOMAJOR = 2
26
27
SOMINOR = 8
72
73
LDFLAGS_LIB += -Wl,-soname=$(SONAME )
73
74
endif
74
75
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 )
78
79
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 $@ $^
81
82
82
- test_g.o : test.c http_parser.h Makefile
83
+ $( BINDIR ) / test_g.o : test.c http_parser.h Makefile
83
84
$(CC ) $(CPPFLAGS_DEBUG ) $(CFLAGS_DEBUG ) -c test.c -o $@
84
85
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
86
87
$(CC ) $(CPPFLAGS_DEBUG ) $(CFLAGS_DEBUG ) -c http_parser.c -o $@
87
88
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 $@
90
91
91
- test.o : test.c http_parser.h Makefile
92
+ $( BINDIR ) / test.o : test.c http_parser.h Makefile
92
93
$(CC ) $(CPPFLAGS_FAST ) $(CFLAGS_FAST ) -c test.c -o $@
93
94
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 $@ $<
96
97
97
- bench.o : bench.c http_parser.h Makefile
98
+ $( BINDIR ) / bench.o : bench.c http_parser.h Makefile
98
99
$(CC ) $(CPPFLAGS_BENCH ) $(CFLAGS_BENCH ) -c bench.c -o $@
99
100
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 $@
102
103
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
105
106
106
- test-valgrind : test_g
107
- valgrind . /test_g
107
+ test-valgrind : $( BINDIR ) / test_g
108
+ valgrind $( BINDIR ) /test_g
108
109
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 $@
111
112
112
- library : libhttp_parser.o
113
- $(CC ) $(LDFLAGS_LIB ) -o $(LIBNAME ) $<
113
+ library : $( BINDIR ) / libhttp_parser.o
114
+ $(CC ) $(LDFLAGS_LIB ) -o $(BINDIR ) / $( LIBNAME ) $<
114
115
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
117
118
118
- url_parser : http_parser.o contrib/url_parser.c
119
+ $( BINDIR ) / url_parser : $( BINDIR ) / http_parser.o contrib/url_parser.c
119
120
$(CC ) $(CPPFLAGS_FAST ) $(CFLAGS_FAST ) $^ -o $@
120
121
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
122
123
$(CC ) $(CPPFLAGS_DEBUG ) $(CFLAGS_DEBUG ) $^ -o $@
123
124
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 )
126
127
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 )
129
130
130
131
tags : http_parser.c http_parser.h test.c
131
132
ctags $^
132
133
133
134
install : library
134
135
$(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 )
138
139
139
140
install-strip : library
140
141
$(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 )
144
145
145
146
uninstall :
146
147
rm $(DESTDIR )$(INCLUDEDIR ) /http_parser.h
@@ -149,7 +150,7 @@ uninstall:
149
150
rm $(DESTDIR )$(LIBDIR ) /$(LIBNAME )
150
151
151
152
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 \
153
154
http_parser.tar libhttp_parser.so.* \
154
155
url_parser url_parser_g parsertrace parsertrace_g \
155
156
* .exe * .exe.so
0 commit comments