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

add BINDIR in Makefile #418

Open
ewwissi opened this issue Mar 23, 2018 · 3 comments
Open

add BINDIR in Makefile #418

ewwissi opened this issue Mar 23, 2018 · 3 comments

Comments

@ewwissi
Copy link

ewwissi commented Mar 23, 2018

the obj and bin files are stored under source code directory,
would like to add a BINDIR in Makefile,
to support parralle make for different target.

@bnoordhuis
Copy link
Member

BINDIR is normally used to install executables to. http-parser however doesn't produce executables, only libraries. (I'm ignoring the test runner; it isn't installed.)

Perhaps what you're really asking for is VPATH support for out-of-tree builds?

@ewwissi
Copy link
Author

ewwissi commented Mar 23, 2018

maybe BINDIR is not a good name, it is the direcotry where obj and exe files are stored during make,
it can solve problem when running parralle make with different arch,

change looks like:

BINDIR ?= $(CURDIR)

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

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

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

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

@bnoordhuis
Copy link
Member

Right, that's traditionally solved with VPATH, although your approach works too for simple projects.

What you call BINDIR is usually called BUILDDIR or sometimes just B. Pull requests welcome but note that I plan on switching to cmake sometime this year and cmake gives you out-of-tree builds for free.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants