Created
March 12, 2026 11:57
-
-
Save tueda/0437675da2ca7861e4011d2d0656862f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Requires: GNU make>=3.81 | |
| CC := gcc | |
| TARGET := x86_64 | |
| GMP_VERSION := 6.3.0 | |
| MPFR_VERSION := 4.2.2 | |
| FLINT_VERSION := 3.4.0 | |
| FORM_REVISION := master | |
| CXX := $(if $(findstring /,$(CC)),$(dir $(CC)))$(patsubst gcc%,g++%,$(notdir $(CC))) | |
| GCC_VERSION := $(shell $(CC) -dumpfullversion 2>/dev/null) | |
| OS := $(shell echo '$(shell $(CC) -dumpmachine)' | sed 's/^[^-]*-//') | |
| FORM_COMMIT := $(shell \ | |
| mkdir -p downloads \ | |
| && cd downloads \ | |
| && [ -d form ] || git clone https://github.com/form-dev/form.git \ | |
| && git -C form fetch origin --tags \ | |
| && commit=$$(git -C form rev-parse --verify $(FORM_REVISION)^{commit}) \ | |
| && git -C form describe --tags --always $$commit \ | |
| ) | |
| # $(FETCH) <output-file> <src-url> | |
| FETCH := $(shell \ | |
| if command -v wget >/dev/null 2>&1; then \ | |
| echo wget -O; \ | |
| elif command -v curl >/dev/null 2>&1; then \ | |
| echo curl -fL -o; \ | |
| else \ | |
| echo wget -O; \ | |
| fi \ | |
| ) | |
| # $(call _uncompress,<source-tarball>,<extracted-dir>,<destination-dir>) | |
| _uncompress = \ | |
| mkdir tmp$$$$ \ | |
| && cd tmp$$$$ \ | |
| && tar -xf ../$1 \ | |
| && mv $2 ../$(dir $3) \ | |
| && cd .. \ | |
| && rmdir tmp$$$$ \ | |
| && touch $3 | |
| all: form-$(FORM_COMMIT)-gcc-$(GCC_VERSION)-$(TARGET)/.done | |
| clean: | |
| rm -rf gmp-*-gcc-* mpfr-*-gcc-* flint-*-gcc-* form-*-gcc-* | |
| .PHONY: all clean | |
| downloads: | |
| mkdir -p $@ | |
| downloads/gmp-$(GMP_VERSION).tar.xz: | downloads | |
| $(FETCH) $@ https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.xz | |
| downloads/mpfr-$(MPFR_VERSION).tar.xz: | downloads | |
| $(FETCH) $@ https://www.mpfr.org/mpfr-$(MPFR_VERSION)/mpfr-$(MPFR_VERSION).tar.xz | |
| downloads/flint-$(FLINT_VERSION).tar.gz: | downloads | |
| $(FETCH) $@ https://flintlib.org/download/flint-$(FLINT_VERSION).tar.gz | |
| downloads/form: | downloads | |
| cd downloads && git clone https://github.com/form-dev/form.git | |
| downloads/x86-64-level: | downloads | |
| $(FETCH) $@ https://raw.githubusercontent.com/HenrikBengtsson/x86-64-level/main/x86-64-level | |
| chmod +x $@ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-$(TARGET)/configure: downloads/gmp-$(GMP_VERSION).tar.xz | |
| $(call _uncompress,$<,gmp-$(GMP_VERSION),$@) | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-$(TARGET)/configure: downloads/mpfr-$(MPFR_VERSION).tar.xz | |
| $(call _uncompress,$<,mpfr-$(MPFR_VERSION),$@) | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-$(TARGET)/configure: downloads/flint-$(FLINT_VERSION).tar.gz | |
| $(call _uncompress,$<,flint-$(FLINT_VERSION),$@) | |
| form-$(FORM_COMMIT)-gcc-$(GCC_VERSION)-$(TARGET)/configure: | downloads/form | |
| [ -d $(@D) ] || git clone downloads/form $(@D) | |
| git -C $(@D) checkout --detach $$(git -C downloads/form rev-parse --verify $(FORM_COMMIT)^{commit}) | |
| cd $(@D) && autoreconf -if | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-$(TARGET)/configure | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| ABI=64 --host=x86_64-$(OS) CC=$(CC) | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-$(TARGET)/configure | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| ABI=64 --host=haswell-$(OS) CC=$(CC) \ | |
| CFLAGS='-O2 -pedantic -fomit-frame-pointer -m64 -march=x86-64-v3' | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64/.done \ | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64/configure | |
| gmp_path=$$(pwd)/$(dir $(word 1,$^))_install; \ | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| --with-gmp=$$gmp_path \ | |
| --host=x86_64-$(OS) CC=$(CC) | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/.done \ | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/configure | |
| gmp_path=$$(pwd)/$(dir $(word 1,$^))_install; \ | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| --with-gmp=$$gmp_path \ | |
| --host=x86_64-$(OS) CC=$(CC) \ | |
| CFLAGS='-Wall -Wmissing-prototypes -Wc++-compat -Wpointer-arith -g -O2 -march=x86-64-v3' | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-x86_64/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64/.done \ | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64/.done \ | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-x86_64/configure | |
| gmp_path=$$(pwd)/$(dir $(word 1,$^))_install; \ | |
| mpfr_path=$$(pwd)/$(dir $(word 2,$^))_install; \ | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| --enable-static \ | |
| --with-gmp=$$gmp_path \ | |
| --with-mpfr=$$mpfr_path \ | |
| --host=x86_64-$(OS) CC=$(CC) | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/.done \ | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/.done \ | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/configure | |
| gmp_path=$$(pwd)/$(dir $(word 1,$^))_install; \ | |
| mpfr_path=$$(pwd)/$(dir $(word 2,$^))_install; \ | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| --enable-static \ | |
| --with-gmp=$$gmp_path \ | |
| --with-mpfr=$$mpfr_path \ | |
| --host=x86_64-$(OS) CC=$(CC) \ | |
| CFLAGS='-Wmissing-prototypes -Wno-stringop-overflow -Wno-stringop-overread -Werror=implicit-function-declaration -Wall -std=c11 -pedantic -O3 -g -march=x86-64-v3' \ | |
| --enable-avx2 | |
| form-$(FORM_COMMIT)-gcc-$(GCC_VERSION)-x86_64/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64/.done \ | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64/.done \ | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-x86_64/.done \ | |
| form-$(FORM_COMMIT)-gcc-$(GCC_VERSION)-x86_64/configure | |
| gmp_path=$$(pwd)/$(dir $(word 1,$^))_install; \ | |
| mpfr_path=$$(pwd)/$(dir $(word 2,$^))_install; \ | |
| flint_path=$$(pwd)/$(dir $(word 3,$^))_install; \ | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| --with-gmp=$$gmp_path \ | |
| --with-mpfr=$$mpfr_path \ | |
| --with-flint=$$flint_path \ | |
| LDFLAGS="-Wl,-rpath,$$gmp_path/lib:$$mpfr_path/lib:$$flint_path/lib" \ | |
| --host=x86_64-$(OS) CC=$(CC) CXX=$(CXX) | |
| form-$(FORM_COMMIT)-gcc-$(GCC_VERSION)-x86_64_v3/Makefile: \ | |
| gmp-$(GMP_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/.done \ | |
| mpfr-$(MPFR_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/.done \ | |
| flint-$(FLINT_VERSION)-gcc-$(GCC_VERSION)-x86_64_v3/.done \ | |
| form-$(FORM_COMMIT)-gcc-$(GCC_VERSION)-x86_64_v3/configure | |
| gmp_path=$$(pwd)/$(dir $(word 1,$^))_install; \ | |
| mpfr_path=$$(pwd)/$(dir $(word 2,$^))_install; \ | |
| flint_path=$$(pwd)/$(dir $(word 3,$^))_install; \ | |
| cd $(@D) && ./configure --prefix=$$(pwd)/_install \ | |
| --with-gmp=$$gmp_path \ | |
| --with-mpfr=$$mpfr_path \ | |
| --with-flint=$$flint_path \ | |
| LDFLAGS="-Wl,-rpath,$$gmp_path/lib:$$mpfr_path/lib:$$flint_path/lib" \ | |
| --host=x86_64-$(OS) CC=$(CC) CXX=$(CXX) \ | |
| CFLAGS=-march=x86-64-v3 CXXFLAGS=-march=x86-64-v3 | |
| %/.done: %/Makefile | |
| $(MAKE) -C $(@D) -j "$$(nproc)" | |
| $(MAKE) -C $(@D) -j "$$(nproc)" check | |
| $(MAKE) -C $(@D) install | |
| touch $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment