Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. .SECONDARY: $(BUILD_DIR)/Build.success
  17. GLIBC_ADDED_FILES = \
  18. $(GLIBC_SRC)/syscallas.S \
  19. $(GLIBC_SRC)/syscalldb.c \
  20. $(GLIBC_SRC)/syscalldb.h \
  21. $(GLIBC_SRC)/libos/Makefile \
  22. $(GLIBC_SRC)/libos/Versions \
  23. $(GLIBC_SRC)/libos/benchmark.c \
  24. $(GLIBC_SRC)/libos/checkpoint.c \
  25. $(GLIBC_SRC)/libos/msgpersist.c \
  26. $(GLIBC_SRC)/libos/sandbox.c \
  27. $(GLIBC_SRC)/elf/syscalldb.c \
  28. $(GLIBC_SRC)/elf/syscallas.S \
  29. $(GLIBC_SRC)/sysdeps/unix/sysv/linux/x86_64/syscalldb.h
  30. $(BUILD_DIR)/Build.success: $(BUILD_DIR)/Makefile $(GLIBC_ADDED_FILES)
  31. @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."
  32. ($(MAKE) -C $(BUILD_DIR) 2>&1 >> build.log) && touch $@
  33. # 2>&1 | tee -a build.log)
  34. $(GLIBC_TARGET): $(BUILD_DIR)/Build.success
  35. $(BUILD_DIR)/Makefile: $(addprefix $(GLIBC_SRC)/,configure elf/Versions nptl/Versions dlfcn/Versions)
  36. ifeq ($(DEBUG),1)
  37. ./buildglibc.py --quiet --debug
  38. else
  39. ./buildglibc.py --quiet
  40. endif
  41. GLIBC_MIRRORS ?= https://ftp.gnu.org/gnu/ \
  42. https://mirrors.kernel.org/gnu/ \
  43. https://mirrors.ocf.berkeley.edu/gnu/
  44. ifeq ($(shell git ls-files $(GLIBC_SRC)/configure),)
  45. GLIBC_PATCHES = \
  46. $(GLIBC_SRC).patch \
  47. glibc-fix-warning.patch \
  48. glibc-no-pie.patch
  49. $(GLIBC_SRC)/configure: $(GLIBC_PATCHES) Makefile
  50. [ -f $(GLIBC_SRC).tar.gz ] || \
  51. for MIRROR in $(GLIBC_MIRRORS); do \
  52. wget --timeout=10 $${MIRROR}glibc/$(GLIBC_SRC).tar.gz \
  53. && break; \
  54. done
  55. [ "`sha256sum $(GLIBC_SRC).tar.gz`" = "$(GLIBC_CHECKSUM) $(GLIBC_SRC).tar.gz" ] || \
  56. (echo "*** $(GLIBC_SRC).tar.gz has a wrong checksum ***"; exit 255)
  57. tar -xzf $(GLIBC_SRC).tar.gz
  58. cd $(GLIBC_SRC) && \
  59. for p in $(GLIBC_PATCHES); do \
  60. echo applying $$p; \
  61. patch -p1 < ../$$p; \
  62. done
  63. endif
  64. .PHONY: clean
  65. clean:
  66. $(MAKE) -C $(SHIM_DIR) clean
  67. rm -rf $(BUILD_DIR)
  68. else
  69. .IGNORE: $(GLIBC_TARGET)
  70. $(GLIBC_TARGET):
  71. .PHONY: clean
  72. clean:
  73. rm -rf $(BUILD_DIR)
  74. endif