Makefile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. SYS ?= $(shell gcc -dumpmachine)
  2. export SYS
  3. export DEBUG
  4. GLIBC_SRC = glibc-2.19
  5. GLIBC_CHECKSUM = 18ad6db70724699d264add80b1f813630d0141cf3a3558b4e1a7c15f6beac796
  6. SHIM_DIR = shim
  7. BUILD_DIR = glibc-build
  8. GLIBC_TARGET = $(addprefix $(BUILD_DIR)/,libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0 libm.so.6 libdl.so.2 libutil.so.1 crt1.o crti.o crtn.o liblibos.so.1 libnss_dns.so.2 libresolv.so.2)
  9. .PHONY: all
  10. all: $(GLIBC_TARGET)
  11. $(MAKE) -C $(SHIM_DIR) all
  12. .PHONY: format
  13. format:
  14. $(MAKE) -C $(SHIM_DIR) format
  15. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  16. .INTERMEDIATE: $(BUILD_DIR)/Build.success
  17. $(BUILD_DIR)/Build.success: $(BUILD_DIR)/Makefile
  18. @echo "Building glibc, may take a while to finish. Warning messages may show up. If this process terminates with failures, see \"$(BUILD_DIR)/build.log\" for more information."
  19. cd $(BUILD_DIR) && ($(MAKE) 2>&1 >> build.log)
  20. # 2>&1 | tee -a build.log)
  21. $(GLIBC_TARGET): $(BUILD_DIR)/Build.success
  22. $(BUILD_DIR)/Makefile: $(addprefix $(GLIBC_SRC)/,configure elf/Versions nptl/Versions dlfcn/Versions)
  23. ifeq ($(DEBUG),1)
  24. ./buildglibc.py --quiet --debug
  25. else
  26. ./buildglibc.py --quiet
  27. endif
  28. GLIBC_MIRRORS ?= https://ftp.gnu.org/gnu/ \
  29. https://mirrors.kernel.org/gnu/ \
  30. https://mirrors.ocf.berkeley.edu/gnu/
  31. ifeq ($(shell git ls-files $(GLIBC_SRC)/configure),)
  32. $(GLIBC_SRC)/configure: $(GLIBC_SRC).patch
  33. [ -f $(GLIBC_SRC).tar.gz ] || \
  34. for MIRROR in $(GLIBC_MIRRORS); do \
  35. wget --timeout=10 $${MIRROR}glibc/$(GLIBC_SRC).tar.gz \
  36. && break; \
  37. done
  38. [ "`sha256sum $(GLIBC_SRC).tar.gz`" = "$(GLIBC_CHECKSUM) $(GLIBC_SRC).tar.gz" ] || \
  39. (echo "*** $(GLIBC_SRC).tar.gz has a wrong checksum ***"; exit 255)
  40. tar -xzf $(GLIBC_SRC).tar.gz
  41. cd $(GLIBC_SRC) && patch -p1 < ../$(GLIBC_SRC).patch
  42. cd $(GLIBC_SRC) && patch -p1 < ../glibc-fix-warning.patch
  43. cd $(GLIBC_SRC) && patch -p1 < ../glibc-no-pie.patch
  44. endif
  45. .PHONY: clean
  46. clean:
  47. $(MAKE) -C $(SHIM_DIR) clean
  48. rm -rf $(BUILD_DIR)
  49. else
  50. .IGNORE: $(GLIBC_TARGET)
  51. $(GLIBC_TARGET):
  52. .PHONY: clean
  53. clean:
  54. rm -rf $(BUILD_DIR)
  55. endif