Makefile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_PATCHES = \
  33. $(GLIBC_SRC).patch \
  34. glibc-fix-warning.patch \
  35. glibc-no-pie.patch
  36. $(GLIBC_SRC)/configure: $(GLIBC_PATCHES) Makefile
  37. [ -f $(GLIBC_SRC).tar.gz ] || \
  38. for MIRROR in $(GLIBC_MIRRORS); do \
  39. wget --timeout=10 $${MIRROR}glibc/$(GLIBC_SRC).tar.gz \
  40. && break; \
  41. done
  42. [ "`sha256sum $(GLIBC_SRC).tar.gz`" = "$(GLIBC_CHECKSUM) $(GLIBC_SRC).tar.gz" ] || \
  43. (echo "*** $(GLIBC_SRC).tar.gz has a wrong checksum ***"; exit 255)
  44. tar -xzf $(GLIBC_SRC).tar.gz
  45. cd $(GLIBC_SRC) && \
  46. for p in $(GLIBC_PATCHES); do \
  47. echo applying $$p; \
  48. patch -p1 < ../$$p; \
  49. done
  50. endif
  51. .PHONY: clean
  52. clean:
  53. $(MAKE) -C $(SHIM_DIR) clean
  54. rm -rf $(BUILD_DIR)
  55. else
  56. .IGNORE: $(GLIBC_TARGET)
  57. $(GLIBC_TARGET):
  58. .PHONY: clean
  59. clean:
  60. rm -rf $(BUILD_DIR)
  61. endif