Makefile 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. SOURCES = sources
  2. CONFIG_SUB_REV = 3d5db9ebe860
  3. BINUTILS_VER = 2.33.1
  4. GCC_VER = 9.4.0
  5. MUSL_VER = 1.2.3
  6. GMP_VER = 6.1.2
  7. MPC_VER = 1.1.0
  8. MPFR_VER = 4.0.2
  9. LINUX_VER = headers-4.19.88-1
  10. GNU_SITE = https://ftpmirror.gnu.org/gnu
  11. GCC_SITE = $(GNU_SITE)/gcc
  12. BINUTILS_SITE = $(GNU_SITE)/binutils
  13. GMP_SITE = $(GNU_SITE)/gmp
  14. MPC_SITE = $(GNU_SITE)/mpc
  15. MPFR_SITE = $(GNU_SITE)/mpfr
  16. ISL_SITE = http://isl.gforge.inria.fr/
  17. MUSL_SITE = https://musl.libc.org/releases
  18. MUSL_REPO = git://git.musl-libc.org/musl
  19. LINUX_SITE = https://cdn.kernel.org/pub/linux/kernel
  20. LINUX_HEADERS_SITE = http://ftp.barfooze.de/pub/sabotage/tarballs/
  21. DL_CMD = wget -c -O
  22. SHA1_CMD = sha1sum -c
  23. COWPATCH = $(CURDIR)/cowpatch.sh
  24. HOST = $(if $(NATIVE),$(TARGET))
  25. BUILD_DIR = build/$(if $(HOST),$(HOST),local)/$(TARGET)
  26. OUTPUT = $(CURDIR)/output$(if $(HOST),-$(HOST))
  27. REL_TOP = ../../..
  28. -include config.mak
  29. SRC_DIRS = gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl-$(MUSL_VER) \
  30. $(if $(GMP_VER),gmp-$(GMP_VER)) \
  31. $(if $(MPC_VER),mpc-$(MPC_VER)) \
  32. $(if $(MPFR_VER),mpfr-$(MPFR_VER)) \
  33. $(if $(ISL_VER),isl-$(ISL_VER)) \
  34. $(if $(LINUX_VER),linux-$(LINUX_VER))
  35. all:
  36. clean:
  37. rm -rf gcc-* binutils-* musl-* gmp-* mpc-* mpfr-* isl-* build build-* linux-*
  38. distclean: clean
  39. rm -rf sources
  40. # Rules for downloading and verifying sources. Treat an external SOURCES path as
  41. # immutable and do not try to download anything into it.
  42. ifeq ($(SOURCES),sources)
  43. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/gmp*)): SITE = $(GMP_SITE)
  44. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/mpc*)): SITE = $(MPC_SITE)
  45. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/mpfr*)): SITE = $(MPFR_SITE)
  46. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/isl*)): SITE = $(ISL_SITE)
  47. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/binutils*)): SITE = $(BINUTILS_SITE)
  48. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/gcc*)): SITE = $(GCC_SITE)/$(basename $(basename $(notdir $@)))
  49. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/musl*)): SITE = $(MUSL_SITE)
  50. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-5*)): SITE = $(LINUX_SITE)/v5.x
  51. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-4*)): SITE = $(LINUX_SITE)/v4.x
  52. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-3*)): SITE = $(LINUX_SITE)/v3.x
  53. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-2.6*)): SITE = $(LINUX_SITE)/v2.6
  54. $(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-headers-*)): SITE = $(LINUX_HEADERS_SITE)
  55. $(SOURCES):
  56. mkdir -p $@
  57. $(SOURCES)/config.sub: | $(SOURCES)
  58. mkdir -p [email protected]
  59. cd [email protected] && $(DL_CMD) $(notdir $@) "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=$(CONFIG_SUB_REV)"
  60. cd [email protected] && touch $(notdir $@)
  61. cd [email protected] && $(SHA1_CMD) $(CURDIR)/hashes/$(notdir $@).$(CONFIG_SUB_REV).sha1
  62. mv [email protected]/$(notdir $@) $@
  63. rm -rf [email protected]
  64. $(SOURCES)/%: hashes/%.sha1 | $(SOURCES)
  65. mkdir -p [email protected]
  66. cd [email protected] && $(DL_CMD) $(notdir $@) $(SITE)/$(notdir $@)
  67. cd [email protected] && touch $(notdir $@)
  68. cd [email protected] && $(SHA1_CMD) $(CURDIR)/hashes/$(notdir $@).sha1
  69. mv [email protected]/$(notdir $@) $@
  70. rm -rf [email protected]
  71. endif
  72. # Rules for extracting and patching sources, or checking them out from git.
  73. musl-git-%:
  74. rm -rf [email protected]
  75. git clone -b $(patsubst musl-git-%,%,$@) $(MUSL_REPO) [email protected]
  76. cd [email protected] && git fsck
  77. mv [email protected] $@
  78. %.orig: $(SOURCES)/%.tar.gz
  79. case "$@" in */*) exit 1 ;; esac
  80. rm -rf [email protected]
  81. mkdir [email protected]
  82. ( cd [email protected] && tar zxvf - ) < $<
  83. rm -rf $@
  84. touch [email protected]/$(patsubst %.orig,%,$@)
  85. mv [email protected]/$(patsubst %.orig,%,$@) $@
  86. rm -rf [email protected]
  87. %.orig: $(SOURCES)/%.tar.bz2
  88. case "$@" in */*) exit 1 ;; esac
  89. rm -rf [email protected]
  90. mkdir [email protected]
  91. ( cd [email protected] && tar jxvf - ) < $<
  92. rm -rf $@
  93. touch [email protected]/$(patsubst %.orig,%,$@)
  94. mv [email protected]/$(patsubst %.orig,%,$@) $@
  95. rm -rf [email protected]
  96. %.orig: $(SOURCES)/%.tar.xz
  97. case "$@" in */*) exit 1 ;; esac
  98. rm -rf [email protected]
  99. mkdir [email protected]
  100. ( cd [email protected] && tar Jxvf - ) < $<
  101. rm -rf $@
  102. touch [email protected]/$(patsubst %.orig,%,$@)
  103. mv [email protected]/$(patsubst %.orig,%,$@) $@
  104. rm -rf [email protected]
  105. %: %.orig | $(SOURCES)/config.sub
  106. case "$@" in */*) exit 1 ;; esac
  107. rm -rf [email protected]
  108. mkdir [email protected]
  109. ( cd [email protected] && $(COWPATCH) -I ../$< )
  110. test ! -d patches/$@ || cat patches/$@/* | ( cd [email protected] && $(COWPATCH) -p1 )
  111. if test -f $</configfsf.sub ; then cs=configfsf.sub ; elif test -f $</config.sub ; then cs=config.sub ; else exit 0 ; fi ; rm -f [email protected]/$$cs && cp -f $(SOURCES)/config.sub [email protected]/$$cs && chmod +x [email protected]/$$cs
  112. rm -rf $@
  113. mv [email protected] $@
  114. # Add deps for all patched source dirs on their patchsets
  115. $(foreach dir,$(notdir $(basename $(basename $(basename $(wildcard hashes/*))))),$(eval $(dir): $$(wildcard patches/$(dir) patches/$(dir)/*)))
  116. extract_all: | $(SRC_DIRS)
  117. # Rules for building.
  118. ifeq ($(TARGET),)
  119. all:
  120. @echo TARGET must be set via config.mak or command line.
  121. @exit 1
  122. else
  123. $(BUILD_DIR):
  124. mkdir -p $@
  125. $(BUILD_DIR)/Makefile: | $(BUILD_DIR)
  126. ln -sf $(REL_TOP)/litecross/Makefile $@
  127. $(BUILD_DIR)/config.mak: | $(BUILD_DIR)
  128. printf >$@ '%s\n' \
  129. "TARGET = $(TARGET)" \
  130. "HOST = $(HOST)" \
  131. "MUSL_SRCDIR = $(REL_TOP)/musl-$(MUSL_VER)" \
  132. "GCC_SRCDIR = $(REL_TOP)/gcc-$(GCC_VER)" \
  133. "BINUTILS_SRCDIR = $(REL_TOP)/binutils-$(BINUTILS_VER)" \
  134. $(if $(GMP_VER),"GMP_SRCDIR = $(REL_TOP)/gmp-$(GMP_VER)") \
  135. $(if $(MPC_VER),"MPC_SRCDIR = $(REL_TOP)/mpc-$(MPC_VER)") \
  136. $(if $(MPFR_VER),"MPFR_SRCDIR = $(REL_TOP)/mpfr-$(MPFR_VER)") \
  137. $(if $(ISL_VER),"ISL_SRCDIR = $(REL_TOP)/isl-$(ISL_VER)") \
  138. $(if $(LINUX_VER),"LINUX_SRCDIR = $(REL_TOP)/linux-$(LINUX_VER)") \
  139. "-include $(REL_TOP)/config.mak"
  140. all: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
  141. cd $(BUILD_DIR) && $(MAKE) $@
  142. install: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
  143. cd $(BUILD_DIR) && $(MAKE) OUTPUT=$(OUTPUT) $@
  144. endif
  145. .SECONDARY: