Skip to content

Commit

Permalink
[sb2] Create output dir before recipe execution
Browse files Browse the repository at this point in the history
The output directory has to exist before make creates the dependency
graph or the build may break when CWD is not $(SCRDIR).
This for example caused in case of rule_tree.o make to have to receipes for the same file one with -fPIC
and one without -fPIC breaking PIC and breaking building libsb2.so on x86_64.
  • Loading branch information
Thaodan committed Dec 18, 2020
1 parent a19b935 commit b9cd834
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions scratchbox2/llbuild/Makefile.include
Expand Up @@ -44,6 +44,7 @@ define import_dir
objects :=
objects-y :=
D := $(1)
$(shell -p mkdir $(1))
include $(1)/Makefile
dep_files := $$(wildcard $(1)/.*.d)
include $(dep_files)
Expand All @@ -59,7 +60,6 @@ $(foreach dir,$(subdirs),$(eval $(call import_dir,$(dir))))

all_objects += $(foreach t,$(extra_targets),$($(t)))

MKOUTPUTDIR = @mkdir -p $(dir $@)

ifdef V
Q =
Expand All @@ -70,42 +70,34 @@ Q = @
endif

%.dylib:
$(MKOUTPUTDIR)
$(P)DYLIB
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -dynamiclib -o $@ $^ $(LIBS)

%.so::
$(MKOUTPUTDIR)
$(P)SHLIB
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(LIBS)

%.a::
$(MKOUTPUTDIR)
$(P)ARCHIVE
$(Q)$(CC) $(LDFLAGS) -r -nostdlib -nodefaultlibs -nostartfiles -o $@ $^

built-in.o:: %.o
$(MKOUTPUTDIR)
$(P)BUILTIN
$(Q)$(CC) -r -nostdlib -nodefaultlibs -nostartfiles -o $@ $^

%.o:: %.S
$(MKOUTPUTDIR)
$(P)AS
$(Q)$(CC) $(CFLAGS) -D__ASSEMBLY__ -Wp,-MT,$@ -Wp,-MMD,$(dir $@).$(notdir $@).d -o $@ -c $<

%.o:: %.c
$(MKOUTPUTDIR)
$(P)CC
$(Q)$(CC) $(CFLAGS) -Wp,-MT,$@ -Wp,-MMD,$(dir $@).$(notdir $@).d -o $@ -c $<

%.o:: %.cc
$(MKOUTPUTDIR)
$(P)CXX
$(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) -Wp,-MT,$@ -Wp,-MMD,$(dir $@)/.$(notdir $@).d -o $@ -c $<

%.o:: %.cpp
$(MKOUTPUTDIR)
$(P)CXX
$(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) -Wp,-MT,$@ -Wp,-MMD,$(dir $@)/.$(notdir $@).d -o $@ -c $<

Expand Down

0 comments on commit b9cd834

Please sign in to comment.