Skip to content
This repository was archived by the owner on Apr 15, 2022. It is now read-only.

Commit 894e752

Browse files
committed
Adds the Makefile-based build system, based on the instructions I originally gathered up in build.py.
Still needs work but is basically working.
1 parent 52dc26c commit 894e752

11 files changed

+231
-343
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
dist
66
download
77
envs
8+
.stamps

Makefile

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
TARGETS=env-build env-runtime cygwin-build cygwin-runtime sage-build \
2+
sage-runtime cygwin-extras-runtime
3+
.PHONY: all $(TARGETS)
4+
5+
############################ Configurable Variables ###########################
6+
7+
# Can be x86 or x86_64
8+
ARCH?=x86_64
9+
10+
SAGE_VERSION?=7.4
11+
SAGE_BRANCH?=$(SAGE_VERSION)
12+
13+
# Output paths
14+
DIST?=dist
15+
DOWNLOAD?=download
16+
ENVS?=envs
17+
STAMPS?=.stamps
18+
19+
# Path to the Inno Setup executable
20+
ISCC?="/cygdrive/c/Program Files (x86)/Inno Setup 5/ISCC.exe"
21+
22+
################################################################################
23+
24+
# Actual targets for the main build stages (the stamp files)
25+
env-build=$(STAMPS)/env-build-$(ARCH)
26+
env-runtime=$(STAMPS)/env-runtime-$(SAGE_VERSION)-$(ARCH)
27+
cygwin-build=$(STAMPS)/cygwin-build-$(ARCH)
28+
cygwin-runtime=$(STAMPS)/cygwin-runtime-$(SAGE_VERSION)-$(ARCH)
29+
sage-build=$(STAMPS)/sage-build-$(SAGE_VERSION)-$(ARCH)
30+
sage-runtime=$(STAMPS)/sage-runtime-$(SAGE_VERSION)-$(ARCH)
31+
cygwin-runtime-extras=$(STAMPS)/cygwin-runtime-extras-$(SAGE_VERSION)-$(ARCH)
32+
33+
###############################################################################
34+
35+
# Resource paths
36+
CYGWIN_EXTRAS=cygwin_extras
37+
RESOURCES=resources
38+
DOT_SAGE=dot_sage
39+
ICONS:=$(wildcard $(RESOURCES)/*.bmp) $(wildcard $(RESOURCES)/*.ico)
40+
41+
ENV_BUILD_DIR=$(ENVS)/build-$(ARCH)
42+
ENV_RUNIME_DIR=$(ENVS)/runtime-$(SAGE_VERSION)-$(ARCH)
43+
44+
SAGE_GIT=git://git.sagemath.org/sage.git
45+
SAGE_ROOT=/opt/sagemath-$(SAGE_VERSION)
46+
SAGE_ROOT_BUILD=$(ENV_BUILD_DIR)$(SAGE_ROOT)
47+
SAGE_ROOT_RUNTIME=$(ENV_RUNTIME_DIR)$(SAGE_ROOT)
48+
49+
# Outputs representing success in the Sage build process
50+
SAGE_CONFIGURE=$(SAGE_ROOT_BUILD)/configure
51+
SAGE_MAKEFILE=$(SAGE_ROOT_BUILD)/build/make/Makefile
52+
SAGE_STARTED=$(SAGE_ROOT_BUILD)/local/etc/sage-started.txt
53+
54+
# Files used as input to ISCC
55+
SAGEMATH_ISS=SageMath.iss
56+
SOURCES:=$(SAGEMATH_ISS) $(DOT_SAGE) $(ICONS)
57+
58+
# URL to download the Cygwin setup.exe
59+
CYGWIN_SETUP_NAME=setup-$(ARCH).exe
60+
CYGWIN_SETUP=$(DOWNLOAD)/$(CYGWIN_SETUP_NAME)
61+
CYGWIN_SETUP_URL=https://cygwin.com/$(CYGWIN_SETUP_NAME)
62+
CYGWIN_MIRROR=ftp://mirrors.kernel.org/sourceware/cygwin/
63+
64+
SAGE_INSTALLER=$(DIST)/SageMath-$(SAGE_VERSION).exe
65+
66+
TOOLS=tools
67+
SUBCYG=$(TOOLS)/subcyg
68+
69+
DIRS=$(DIST) $(DOWNLOAD) $(ENVS) $(STAMPS)
70+
71+
72+
################################################################################
73+
74+
all: $(SAGE_INSTALLER)
75+
76+
$(SAGE_INSTALLER): $(ISCC) $(SOURCES) $(env-runtime) | $(DIST)
77+
cd $(CUDIR)
78+
"$(ISCC)" /DSageVersion=$(SAGE_VERSION) /DEnvsDir="$(ENVS)" \
79+
/DOutputDir="$(DIST)" $(SAGEMATH_ISS)
80+
81+
82+
$(foreach target,$(TARGETS),$(eval $(target): $$($(target))))
83+
84+
85+
$(env-runtime): $(cygwin-runtime) $(sage-runtime) $(cygwin-runtime-extras)
86+
(cd $(ENV_RUNTIME_DIR) && find . -type l) > $(ENV_RUNTIME_DIR)/etc/symlinks.lst
87+
@touch $@
88+
89+
90+
$(sage-runtime): $(SAGE_ROOT_RUNTIME)
91+
92+
$(SAGE_ROOT_RUNTIME): $(cygwin-runtime) $(sage-build)
93+
[ -d $(dir $@) ] || mkdir $(dir $@)
94+
cp -r $(SAGE_ROOT_BUILD) $(dir $@)
95+
(cd $@ && rm -rf bootstrap config* logs m4 Makefile \
96+
upstream local/var/tmp/sage/build/* local/var/lock/* \
97+
src/build local/share/doc/sage/doctrees .git*)
98+
@touch $@
99+
100+
101+
$(env-build): $(cygwin-build) $(sage-build)
102+
@touch $@
103+
104+
105+
# TODO: This doesn't build the documentation yet
106+
$(sage-build): $(cygwin-build) $(SAGE_STARTED)
107+
@touch $@
108+
109+
110+
$(cygwin-runtime-extras): $(cygwin-runtime)
111+
cp -r $(CYGWIN_EXTRAS)/* $(ENV_RUNTIME_DIR)
112+
echo "SAGE_VERSION=$(SAGE_VERSION)" > $(ENV_RUNTIME_DIR)/etc/sage-version
113+
echo 'none /tmp usertemp binary,posix=0 0 0' >> $(ENV_RUNTIME_DIR)/etc/fstab
114+
echo 'C:\Users /home ntfs binary,posix=1,acl 0 0' >> $(ENV_RUNTIME_DIR)/etc/fstab
115+
@touch $@
116+
117+
118+
$(STAMPS)/cygwin-%: $(ENVS)/% | $(STAMPS)
119+
@touch $@
120+
121+
122+
$(ENVS)/%: cygwin-sage-%.list $(CYGWIN_SETUP)
123+
"$(CYGWIN_SETUP)" --site $(CYGWIN_MIRROR) \
124+
--local-package-dir "$$(cygpath -w -a $(DOWNLOAD))" \
125+
--root "$$(cygpath -w -a $@)" \
126+
--arch $(ARCH) --no-admin --no-shortcuts --quiet-mode \
127+
--packages $$($(TOOLS)/setup-package-list $<)
128+
# Install symlinks for CCACHE
129+
if [ -x $@/usr/bin/ccache ]; then \
130+
ln -s /usr/bin/ccache $@/usr/local/bin/gcc; \
131+
ln -s /usr/bin/ccache $@/usr/local/bin/g++; \
132+
fi
133+
# A bit of cleanup
134+
rm -f $@/Cygwin*.{bat,ico}
135+
136+
137+
$(SAGE_STARTED): $(SAGE_MAKEFILE)
138+
$(SUBCYG) "$(ENV_BUILD_DIR)" "(cd $(SAGE_ROOT) && \
139+
(SAGE_NUM_THREADS=1 SAGE_INSTALL_CCACHE=yes CCACHE="$$HOME/.ccache" \
140+
SAGE_FAT_BINARY=yes SAGE_ATLAS_LIB=/lib \
141+
make start))"
142+
143+
144+
$(SAGE_MAKEFILE): $(SAGE_CONFIGURE)
145+
$(SUBCYG) "$(ENV_BUILD_DIR)" "(cd $(SAGE_ROOT) && ./configure --with-blas=atlas)"
146+
147+
148+
$(SAGE_CONFIGURE): | $(SAGE_ROOT_BUILD)
149+
$(SUBCYG) "$(ENV_BUILD_DIR)" "(cd $(SAGE_ROOT) && make configure)"
150+
151+
152+
$(SAGE_ROOT_BUILD): $(cygwin-build)
153+
[ -d $(dir $(SAGE_ROOT_BUILD)) ] || mkdir $(dir $(SAGE_ROOT_BUILD))
154+
$(SUBCYG) "$(ENV_BUILD_DIR)" "(cd /opt && git clone --single-branch --branch $(SAGE_BRANCH) $(SAGE_GIT) $(SAGE_ROOT))"
155+
156+
157+
$(CYGWIN_SETUP): | $(DOWNLOAD)
158+
(cd $(DOWNLOAD) && wget "$(CYGWIN_SETUP_URL)")
159+
chmod +x $(CYGWIN_SETUP)
160+
161+
162+
$(DIRS):
163+
mkdir "$@"

build.py

-89
This file was deleted.

cygwin-sage-build-x86.list

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cygwin-sage-build.list

cygwin-sage-build-x86_64.list

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cygwin-sage-build.list

0 commit comments

Comments
 (0)