Skip to content

Commit

Permalink
Fix parallel build dependency, close #65
Browse files Browse the repository at this point in the history
This commit corrects the dependency issue in the Makefile which was causing errors during parallel builds. Specifically, it addresses the following changes:

- Separate build rules for local/graftcp-local and local/mgraftcp to individually specify their dependencies and build commands.
- Ensure local/mgraftcp explicitly depends on libgraftcp.a, and build it prior to local/mgraftcp to resolve potential race conditions.
- The local/graftcp-local target does not depend on libgraftcp.a, hence a separate rule is created without this dependency.

These adjustments ensure that each binary is built correctly respecting their precise dependencies, and thus preventing errors that may occur due to incorrect builds when using the -j option for parallel execution in make.
  • Loading branch information
hmgle committed Feb 22, 2024
1 parent dfba9e6 commit 2c1a891
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ libgraftcp.a: graftcp.o util.o cidr-trie.o conf.o
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<

$(GRAFTCP_LOCAL_BIN)::
$(MAKE) -C local VERSION=$(VERSION) CC=$(CC) CXX=$(CXX) AR=$(AR)
local/graftcp-local:
$(MAKE) -C $(dir $@) VERSION=$(VERSION) CC=$(CC) CXX=$(CXX) AR=$(AR) $(notdir $@)

local/mgraftcp: libgraftcp.a
$(MAKE) -C $(dir $@) VERSION=$(VERSION) CC=$(CC) CXX=$(CXX) AR=$(AR) $(notdir $@)

install:: graftcp $(GRAFTCP_LOCAL_BIN)
$(INSTALL) $< $(DESTDIR)$(BINDIR)/$<
Expand Down

0 comments on commit 2c1a891

Please sign in to comment.