diff --git a/Makefile.uk b/Makefile.uk index 0d6e0e045e71990f3ab5bc92eba1b880fa27ddfe..8f643616b5a17f7f580e58e50bcc69fed4407bbd 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -65,15 +65,29 @@ $(eval $(call addlib_s,libmuslglue,$(CONFIG_LIBMUSL))) # Sources ################################################################################ LIBMUSL_VERSION=1.2.3 +LIBMUSL_SUBDIR=musl-$(LIBMUSL_VERSION) +LIBMUSL_TARGET=$(LIBMUSL_ORIGIN)/$(LIBMUSL_SUBDIR) LIBMUSL_URL=https://gitee.com/tenonos-mirror/fork-musl.git LIBMUSL_PATCHDIR=$(LIBMUSL_BASE)/patches + $(eval $(call clone,libmusl,$(LIBMUSL_URL),v$(LIBMUSL_VERSION))) $(eval $(call patch,libmusl,$(LIBMUSL_PATCHDIR),.)) +.adjust_path: $(LIBMUSL_BUILD)/.origin + @if [ ! -d "$(LIBMUSL_TARGET)" ]; then \ + mkdir -p "$(LIBMUSL_BUILD)/tmp"; \ + mv "$(LIBMUSL_ORIGIN)"/* "$(LIBMUSL_BUILD)/tmp" 2>/dev/null || true; \ + mkdir -p "$(LIBMUSL_TARGET)"; \ + mv "$(LIBMUSL_BUILD)/tmp"/* "$(LIBMUSL_TARGET)" 2>/dev/null || true; \ + rmdir $(LIBMUSL_BUILD)/tmp; \ + fi + +UK_PREPARE += .adjust_path + ################################################################################ # Helpers ################################################################################ -LIBMUSL=$(LIBMUSL_ORIGIN)/ +LIBMUSL=$(LIBMUSL_ORIGIN)/$(LIBMUSL_SUBDIR)/ # Additional macros for musl sub-libraries include $(LIBMUSL_BASE)/Makefile.rules @@ -104,7 +118,7 @@ CXXINCLUDES-$(CONFIG_LIBMUSL) += $(LIBMUSL_GLOBAL_INCLUDES-y) # Musl-specific Targets ################################################################################ # generate alltypes.h through musl sed script -$(LIBMUSL)/arch/$(MUSL_ARCH)/bits/alltypes.h: $(LIBMUSL_BUILD)/.patched +$(LIBMUSL)/arch/$(MUSL_ARCH)/bits/alltypes.h: .adjust_path $(call verbose_cmd,CONFIGURE,libmusl: $(notdir $@),\ sed -f $(LIBMUSL)/tools/mkalltypes.sed \ $(LIBMUSL)/arch/$(MUSL_ARCH)/bits/alltypes.h.in \ @@ -112,7 +126,7 @@ $(LIBMUSL)/arch/$(MUSL_ARCH)/bits/alltypes.h: $(LIBMUSL_BUILD)/.patched $(TOUCH) $@) # generate version.h -$(LIBMUSL)/src/internal/version.h: $(LIBMUSL_BUILD)/.origin +$(LIBMUSL)/src/internal/version.h: .adjust_path $(call verbose_cmd,CONFIGURE,libmusl: $(notdir $@),\ printf '#define VERSION "%s"\n' "$$(cd $(LIBMUSL); sh tools/version.sh)" > $@ && \ $(TOUCH) $@)