$NetBSD: patch-build_make_Makefile,v 1.3 2024/01/22 13:09:26 ryoon Exp $ --- build/make/Makefile.orig 2024-01-09 21:12:22.000000000 +0000 +++ build/make/Makefile @@ -173,7 +173,7 @@ $(BUILD_PFX)%.c.d: %.c $(BUILD_PFX)%.c.o: %.c $(if $(quiet),@echo " [CC] $@") $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@)) - $(qexec)$(CC) $(INTERNAL_CFLAGS) $(CFLAGS) -c -o $@ $< + $(qexec)${LIBTOOL} --mode=compile $(CC) $(INTERNAL_CFLAGS) $(CFLAGS) -c -o $@ $< $(BUILD_PFX)%.cc.d: %.cc $(if $(quiet),@echo " [DEP] $@") @@ -183,7 +183,7 @@ $(BUILD_PFX)%.cc.d: %.cc $(BUILD_PFX)%.cc.o: %.cc $(if $(quiet),@echo " [CXX] $@") $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@)) - $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $< + $(qexec)${LIBTOOL} --mode=compile $(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $< $(BUILD_PFX)%.cpp.d: %.cpp $(if $(quiet),@echo " [DEP] $@") @@ -193,7 +193,7 @@ $(BUILD_PFX)%.cpp.d: %.cpp $(BUILD_PFX)%.cpp.o: %.cpp $(if $(quiet),@echo " [CXX] $@") $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@)) - $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $< + $(qexec)${LIBTOOL} --mode=compile $(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $< $(BUILD_PFX)%.asm.d: %.asm $(if $(quiet),@echo " [DEP] $@") @@ -204,7 +204,8 @@ $(BUILD_PFX)%.asm.d: %.asm $(BUILD_PFX)%.asm.o: %.asm $(if $(quiet),@echo " [AS] $@") $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@)) - $(qexec)$(AS) $(ASFLAGS) -o $@ $< + $(qexec)${LIBTOOL} --mode=compile --tag=CC sh strip_fPIC.sh \ + $(AS) $(ASFLAGS) -o $@ $< $(BUILD_PFX)%.S.d: %.S $(if $(quiet),@echo " [DEP] $@") @@ -215,7 +216,8 @@ $(BUILD_PFX)%.S.d: %.S $(BUILD_PFX)%.S.o: %.S $(if $(quiet),@echo " [AS] $@") $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@)) - $(qexec)$(AS) $(ASFLAGS) -o $@ $< + $(qexec)${LIBTOOL} --mode=compile --tag=CC sh strip_fPIC.sh \ + $(AS) $(ASFLAGS) -o $@ $< .PRECIOUS: %.c.S %.c.S: CFLAGS += -DINLINE_ASM @@ -280,13 +282,15 @@ define linker_template $(1): $(filter-out -%,$(2)) $(1): $(if $(quiet),@echo " [LD] $$@") - $(qexec)$$(LD) $$(strip $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs)) + $(qexec)${LIBTOOL} --mode=link $(CXX) $(LDFLAGS) -o $$@ \ + $$(filter-out -lvpx,$(2)) libvpx.la $$(extralibs) endef define linkerxx_template $(1): $(filter-out -%,$(2)) $(1): $(if $(quiet),@echo " [LD] $$@") - $(qexec)$$(CXX) $$(strip $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs)) + $(qexec)${LIBTOOL} --mode=link ${CXX} $(LDFLAGS) -o $$@ \ + $$(filter-out -lvpx,$(2)) libvpx.la $$(extralibs) endef # make-3.80 has a bug with expanding large input strings to the eval function, # which was triggered in some cases by the following component of @@ -299,8 +303,12 @@ endef define install_map_template $(DIST_DIR)/$(1): $(2) $(if $(quiet),@echo " [INSTALL] $$@") - $(qexec)mkdir -p $$(dir $$@) - $(qexec)cp -p $$< $$@ + $(qexec)${BSD_INSTALL_DATA} -d -m 755 $$(dir $$@) + $$(if $$(filter %.a,$$<), \ + ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} -c $$(patsubst %.a,%.la,$$<) $$(dir $$@), \ + $$(if $$(filter %.h %.pc,$$<), \ + ${BSD_INSTALL_DATA} -c -m 644 $$< $$(dir $$@), \ + ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} -c -s $$< $$(dir $$@))) endef define archive_template @@ -309,7 +317,9 @@ define archive_template # for creating them. $(1): $(if $(quiet),@echo " [AR] $$@") - $(qexec)$$(AR) $$(ARFLAGS) $$@ $$^ + $(qexec)${LIBTOOL} --mode=link $(CC) $(LDFLAGS) -Wl,-Bsymbolic -o $$(patsubst %.a,%.la,$$@) \ + $$(patsubst %.o,%.lo,$$?) -rpath $(PREFIX)/lib $$(extralibs) \ + -version-info $(VERSION_MAJOR):$(VERSION_MINOR) endef # Don't use -Wl,-z,defs with Clang's sanitizers. @@ -417,9 +427,9 @@ clean:: rm -f .bins .install-bins $(BINS) LIBS=$(call enabled,LIBS) -.libs: $(LIBS) +dot.libs: $(LIBS) @touch $@ -$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib)))) +$(foreach lib,$(filter %.a,$(LIBS)),$(eval $(call archive_template,$(lib)))) $(foreach lib,$(filter %so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib)))) $(foreach lib,$(filter %$(SO_VERSION_MAJOR).dylib,$(LIBS)),$(eval $(call dl_template,$(lib)))) $(foreach lib,$(filter %$(SO_VERSION_MAJOR).dll,$(LIBS)),$(eval $(call dll_template,$(lib)))) @@ -428,11 +438,11 @@ INSTALL-LIBS=$(call cond_enabled,CONFIG_ ifeq ($(MAKECMDGOALS),dist) INSTALL-LIBS+=$(call cond_enabled,CONFIG_INSTALL_LIBS,DIST-LIBS) endif -.install-libs: .libs $(addprefix $(DIST_DIR)/,$(INSTALL-LIBS)) +.install-libs: dot.libs $(addprefix $(DIST_DIR)/,$(INSTALL-LIBS)) @touch $@ clean:: - rm -f .libs .install-libs $(LIBS) + rm -f dot.libs .install-libs $(LIBS) ifeq ($(CONFIG_EXTERNAL_BUILD),yes) PROJECTS=$(call enabled,PROJECTS) @@ -482,7 +492,7 @@ ifeq ($(CONFIG_EXTERNAL_BUILD),yes) BUILD_TARGETS += .projects INSTALL_TARGETS += .install-projects endif -BUILD_TARGETS += .docs .libs .bins +BUILD_TARGETS += .docs dot.libs .bins INSTALL_TARGETS += .install-docs .install-srcs .install-libs .install-bins all: $(BUILD_TARGETS) install:: $(INSTALL_TARGETS)