123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- SYS ?= $(shell gcc -dumpmachine)
- export SYS
- export DEBUG
- GLIBC_SRC = glibc-2.19
- GLIBC_CHECKSUM = 18ad6db70724699d264add80b1f813630d0141cf3a3558b4e1a7c15f6beac796
- SHIM_DIR = shim
- BUILD_DIR = glibc-build
- RUNTIME_DIR = $(CURDIR)/../Runtime
- GLIBC_LIBS = \
- csu/crt1.o \
- csu/crti.o \
- csu/crtn.o \
- dlfcn/libdl.so.2 \
- elf/ld-linux-x86-64.so.2 \
- libc.so \
- libc.so.6 \
- libos/liblibos.so.1 \
- login/libutil.so.1 \
- math/libm.so.6 \
- nptl/libpthread.so.0 \
- nptl_db/libthread_db.so.1 \
- resolv/libnss_dns.so.2 \
- resolv/libresolv.so.2 \
- rt/librt.so.1
- GLIBC_TARGET = $(addprefix $(BUILD_DIR)/, $(GLIBC_LIBS))
- GLIBC_RUNTIME = $(addprefix $(RUNTIME_DIR)/, $(notdir $(GLIBC_TARGET)))
- .PHONY: all
- all: $(GLIBC_TARGET) $(GLIBC_RUNTIME)
- $(MAKE) -C $(SHIM_DIR) all
- include ../Makefile.rules
- .PHONY: format
- format:
- $(MAKE) -C $(SHIM_DIR) format
- ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
- .SECONDARY: $(BUILD_DIR)/Build.success
- GLIBC_ADDED_FILES = \
- $(GLIBC_SRC)/syscallas.S \
- $(GLIBC_SRC)/syscalldb.c \
- $(GLIBC_SRC)/syscalldb.h \
- $(GLIBC_SRC)/libos/Makefile \
- $(GLIBC_SRC)/libos/Versions \
- $(GLIBC_SRC)/libos/benchmark.c \
- $(GLIBC_SRC)/libos/checkpoint.c \
- $(GLIBC_SRC)/libos/msgpersist.c \
- $(GLIBC_SRC)/libos/sandbox.c \
- $(GLIBC_SRC)/elf/syscalldb.c \
- $(GLIBC_SRC)/elf/syscallas.S \
- $(GLIBC_SRC)/sysdeps/unix/sysv/linux/x86_64/syscalldb.h
- $(BUILD_DIR)/Build.success: $(BUILD_DIR)/Makefile $(GLIBC_ADDED_FILES)
- @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."
- ($(MAKE) -C $(BUILD_DIR) 2>&1 >> build.log) && touch $@
- # 2>&1 | tee -a build.log)
- $(GLIBC_TARGET): $(BUILD_DIR)/Build.success
- $(BUILD_DIR)/Makefile: $(addprefix $(GLIBC_SRC)/,configure elf/Versions nptl/Versions dlfcn/Versions)
- ifeq ($(DEBUG),1)
- ./buildglibc.py --quiet --debug
- else
- ./buildglibc.py --quiet
- endif
- define LN_SF_TO_RUNTIME_DIR_template =
- $(RUNTIME_DIR)/$(notdir $(1)): $(1)
- $$(call cmd,ln_sf)
- endef
- $(foreach lib,$(GLIBC_TARGET),$(eval $(call LN_SF_TO_RUNTIME_DIR_template,$(lib))))
- GLIBC_MIRRORS ?= https://ftp.gnu.org/gnu/ \
- https://mirrors.kernel.org/gnu/ \
- https://mirrors.ocf.berkeley.edu/gnu/
- ifeq ($(shell git ls-files $(GLIBC_SRC)/configure),)
- GLIBC_PATCHES = \
- $(GLIBC_SRC).patch \
- glibc-fix-warning.patch \
- glibc-no-pie.patch
- $(GLIBC_SRC)/configure: $(GLIBC_PATCHES) Makefile
- [ -f $(GLIBC_SRC).tar.gz ] || \
- for MIRROR in $(GLIBC_MIRRORS); do \
- wget --timeout=10 $${MIRROR}glibc/$(GLIBC_SRC).tar.gz \
- && break; \
- done
- [ "`sha256sum $(GLIBC_SRC).tar.gz`" = "$(GLIBC_CHECKSUM) $(GLIBC_SRC).tar.gz" ] || \
- (echo "*** $(GLIBC_SRC).tar.gz has a wrong checksum ***"; exit 255)
- tar -xzf $(GLIBC_SRC).tar.gz
- cd $(GLIBC_SRC) && \
- for p in $(GLIBC_PATCHES); do \
- echo applying $$p; \
- patch -p1 < ../$$p; \
- done
- endif
- .PHONY: clean
- clean:
- $(MAKE) -C $(SHIM_DIR) clean
- rm -rf $(BUILD_DIR)
- else
- .IGNORE: $(GLIBC_TARGET)
- $(GLIBC_TARGET):
- .PHONY: clean
- clean:
- rm -rf $(BUILD_DIR)
- endif
|