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

Commit

Permalink
use BINDIR in Makefile
Browse files Browse the repository at this point in the history
Change-Id: I0a6a051d26f8bc82e5172c9905ef46b34fa12ed5
  • Loading branch information
ewwissi committed Mar 26, 2018
1 parent edeedb1 commit 485fa8c
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
HELPER ?=
BINEXT ?=
BINDIR ?= $(CURDIR)
SOLIBNAME = libhttp_parser
SOMAJOR = 2
SOMINOR = 8
Expand Down Expand Up @@ -72,73 +73,73 @@ else
LDFLAGS_LIB += -Wl,-soname=$(SONAME)
endif

test: test_g test_fast
$(HELPER) ./test_g$(BINEXT)
$(HELPER) ./test_fast$(BINEXT)
test: $(BINDIR)/test_g $(BINDIR)/test_fast
$(HELPER) $(BINDIR)/test_g$(BINEXT)
$(HELPER) $(BINDIR)/test_fast$(BINEXT)

test_g: http_parser_g.o test_g.o
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
$(BINDIR)/test_g: $(BINDIR)/http_parser_g.o $(BINDIR)/test_g.o
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) -o $@ $^

test_g.o: test.c http_parser.h Makefile
$(BINDIR)/test_g.o: test.c http_parser.h Makefile
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@

http_parser_g.o: http_parser.c http_parser.h Makefile
$(BINDIR)/http_parser_g.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@

test_fast: http_parser.o test.o http_parser.h
$(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@
$(BINDIR)/test_fast: $(BINDIR)/http_parser.o $(BINDIR)/test.o http_parser.h
$(CC) $(CFLAGS_FAST) $(LDFLAGS) $(BINDIR)/http_parser.o $(BINDIR)/test.o -o $@

test.o: test.c http_parser.h Makefile
$(BINDIR)/test.o: test.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@

bench: http_parser.o bench.o
$(CC) $(CFLAGS_BENCH) $(LDFLAGS) http_parser.o bench.o -o $@
$(BINDIR)/bench: $(BINDIR)/http_parser.o $(BINDIR)/bench.o
$(CC) $(CFLAGS_BENCH) $(LDFLAGS) -o $@ $<

bench.o: bench.c http_parser.h Makefile
$(BINDIR)/bench.o: bench.c http_parser.h Makefile
$(CC) $(CPPFLAGS_BENCH) $(CFLAGS_BENCH) -c bench.c -o $@

http_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
$(BINDIR)/http_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c -o $@

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

test-valgrind: test_g
valgrind ./test_g
test-valgrind: $(BINDIR)/test_g
valgrind $(BINDIR)/test_g

libhttp_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o
$(BINDIR)/libhttp_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o $@

library: libhttp_parser.o
$(CC) $(LDFLAGS_LIB) -o $(LIBNAME) $<
library: $(BINDIR)/libhttp_parser.o
$(CC) $(LDFLAGS_LIB) -o $(BINDIR)/$(LIBNAME) $<

package: http_parser.o
$(AR) rcs libhttp_parser.a http_parser.o
package: $(BINDIR)/http_parser.o
$(AR) rcs $(BINDIR)/libhttp_parser.a $(BINDIR)/http_parser.o

url_parser: http_parser.o contrib/url_parser.c
$(BINDIR)/url_parser: $(BINDIR)/http_parser.o contrib/url_parser.c
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $@

url_parser_g: http_parser_g.o contrib/url_parser.c
$(BINDIR)/url_parser_g: $(BINDIR)/http_parser_g.o contrib/url_parser.c
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@

parsertrace: http_parser.o contrib/parsertrace.c
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT)
parsertrace: $(BINDIR)/http_parser.o contrib/parsertrace.c
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $(BINDIR)/parsertrace$(BINEXT)

parsertrace_g: http_parser_g.o contrib/parsertrace.c
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT)
parsertrace_g: $(BINDIR)/http_parser_g.o contrib/parsertrace.c
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $(BINDIR)/parsertrace_g$(BINEXT)

tags: http_parser.c http_parser.h test.c
ctags $^

install: library
$(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
$(INSTALL) -D $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
$(INSTALL) -D $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)

install-strip: library
$(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
$(INSTALL) -D -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
$(INSTALL) -D -s $(BINDIR)/$(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)

Expand All @@ -149,7 +150,7 @@ uninstall:
rm $(DESTDIR)$(LIBDIR)/$(LIBNAME)

clean:
rm -f *.o *.a tags test test_fast test_g \
rm -f tags && cd $(BINDIR) && rm -f *.o *.a tags test test_fast test_g \
http_parser.tar libhttp_parser.so.* \
url_parser url_parser_g parsertrace parsertrace_g \
*.exe *.exe.so
Expand Down

0 comments on commit 485fa8c

Please sign in to comment.