Skip to content

Commit

Permalink
workaround: Rename tool output temporarily on build
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Oct 6, 2024
1 parent e8ae9b6 commit cf44dbb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tools/Rules.make
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ TOOLS_CXX_COMPILE = $(TOOLS_CC) $(TOOLS_CXXFLAGS) $(TOOLS_INCS)
# Command for ensuring the output directory for the rule exists.
DIR_GUARD = @$(MKDIR) -p $(@D)

MAKE_CURPID := $(shell printf '%s' $$PPID)

$(TOOLS_OBJS_DIR)%.o : $(TOOLS_SRC_DIR)%.c
$(DIR_GUARD)
$(CC) $(TOOLS_CFLAGS) $(TOOLS_INCS) -c $< -o $@
Expand All @@ -60,10 +62,20 @@ $(TOOLS_OBJS_DIR)%.o : $(TOOLS_SRC_DIR)%.s
$(DIR_GUARD)
$(AS) $(TOOLS_ASFLAGS) $< -o $@

$(TOOLS_BIN) : $(TOOLS_OBJS) $(TOOLS_LIB_ARCHIVES) $(TOOLS_ADDITIONAL_DEPS)
.INTERMEDIATE:: $(TOOLS_BIN)_tmp$(MAKE_CURPID) $(TOOLS_LIB)_tmp$(MAKE_CURPID)

$(TOOLS_BIN)_tmp$(MAKE_CURPID) : $(TOOLS_OBJS) $(TOOLS_LIB_ARCHIVES) $(TOOLS_ADDITIONAL_DEPS)
$(DIR_GUARD)
$(CC) $(TOOLS_LDFLAGS) -o $@ $(TOOLS_OBJS) $(TOOLS_LIB_ARCHIVES) $(TOOLS_LIBS)

$(TOOLS_BIN): $(TOOLS_BIN)_tmp$(MAKE_CURPID)
$(DIR_GUARD)
mv $< $@

$(TOOLS_LIB)_tmp$(MAKE_CURPID) : $(TOOLS_OBJS)
$(DIR_GUARD)
$(CC) $(TOOLS_LDFLAGS) -o $(TOOLS_BIN) $(TOOLS_OBJS) $(TOOLS_LIB_ARCHIVES) $(TOOLS_LIBS)
$(AR) cru $@ $<

$(TOOLS_LIB) : $(TOOLS_OBJS)
$(TOOLS_LIB): $(TOOLS_LIB)_tmp$(MAKE_CURPID)
$(DIR_GUARD)
$(AR) cru $(TOOLS_LIB) $<
mv $< $@

0 comments on commit cf44dbb

Please sign in to comment.