changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > infra / makefile

changeset 227: 94227525d5ce
parent: ee3bce140f7e
child: 989b1b4782dc
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 24 May 2024 20:01:52 +0000
permissions: -rw-r--r--
description: move containers
1 ### infra/makefile --- The Compiler Company Infrastructure
2 
3 # this makefile is used to build all of our source code, package it,
4 # and ship it to various locations. It is for internal-use only.
5 
6 # If possible, use the packy (packy.compiler.company) to find and
7 # download a prepared bundle that suits your project needs.
8 
9 # You probably don't want to install all targets unless you have lots
10 # of time and a powerful machine, although it is possible. Instead,
11 # just run the targets for the components you are missing in your
12 # local environment (compatible compiler versions, shared libraries,
13 # etc)
14 
15 VERSION="0.1.0"
16 LINUX_VERSION:=$(shell uname -r | cut -d- -f1)
17 B:=build
18 D:=dist
19 SRC:=code
20 CONTAINERS:=containers
21 HG_COMMIT:=$(shell hg id -i)
22 DESTINATION:=/mnt/y/data/packy
23 # requires emacs-build-minimal
24 # artifacts can deploy to dist/TARGET - need target triple first
25 # init:sbcl rust emacs rocksdb code
26 # dist/linux dist/rust dist/bundle
27 archlinux:$(CONTAINERS)/Containerfile.archlinux;podman build -f $< -t archlinux
28 box:$(CONTAINERS)/Containerfile.box archlinux;podman build -f $< -t box
29 alpine:$(CONTAINERS)/Containerfile.alpine;podman build -f $< -t alpine
30 ubuntu:$(CONTAINERS)/Containerfile.ubuntu;podman build -f $< -t ubuntu
31 worker:$(CONTAINERS)/Containerfile.worker alpine;podman build -f $< -t worker
32 operator:$(CONTAINERS)/Containerfile.operator box;podman build -f $< -t operator
33 pods:archlinux alpine ubuntu box worker operator
34 quick:code
35 all:dist/code dist/lisp dist/rust dist/sbcl dist/rocksdb dist/emacs dist/pods
36 clean:;rm -rf $(B) $(D)
37 $(B):;mkdir -pv $@/src
38 $(D):;mkdir -pv $@/bin $@/lib $@/include $@/bundle $@/share
39 $(DESTINATION):$(D);cd $< && cp -rf ./* $@
40 ### Linux
41 LINUX_TARGET:=linux-$(LINUX_VERSION)
42 linux:$(LINUX_TARGET) linux-config;
43 $(LINUX_TARGET):scripts/get-linux.sh;
44  mkdir -pv build/$@
45  gpg --export autosigner@ torvalds@ gregkh@ > build/$@/keyring.gpg
46  $< $(LINUX_VERSION) build build/$@/keyring.gpg
47  cd build && unxz $@.tar.xz && tar -xvf $@.tar $(LINUX_TARGET)
48 linux-config:$(LINUX_TARGET);
49  cd build/$< && make mrproper -j && zcat /proc/config.gz > .config && yes N | make localmodconfig
50 clean-linux::;rm -rf build/$(LINUX_TARGET)
51 
52 ### Emacs
53 EMACS_TARGET:=build/src/emacs
54 EMACS_DIST:=$(D)/src/emacs
55 $(EMACS_TARGET):scripts/get-emacs.sh $(B);
56  $<
57 emacs:$(EMACS_TARGET)
58 emacs-build:scripts/build-emacs.sh $(EMACS_TARGET)
59  cd $(EMACS_TARGET) && ./autogen.sh
60  $<
61 emacs-build-mini:scripts/build-emacs-mini.sh emacs
62  cd $(EMACS_TARGET) && ./autogen.sh
63  $< $(EMACS_TARGET)
64 emacs-install:$(EMACS_TARGET);
65  cd $< && make install
66 
67 ### RocksDB
68 ROCKSDB_TARGET:=build/src/rocksdb
69 $(ROCKSDB_TARGET):scripts/get-rocksdb.sh $(B)
70  $<
71 rocksdb:$(ROCKSDB_TARGET)
72 
73 rocksdb-build-shared:$(ROCKSDB_TARGET)
74  cd $< && make shared_lib DISABLE_JEMALLOC=1
75 
76 rocksdb-build-static:$(ROCKSDB_TARGET)
77  cd $< && make static_lib DISABLE_JEMALLOC=1
78 
79 rocksdb-install:$(ROCKSDB_TARGET)
80  cd $< && make install LIB_MODE=shared && cp -r include/* /usr/local/include/
81 
82 ### Nushell
83 NUSHELL_TARGET:=build/src/nushell
84 $(NUSHELL_TARGET):scripts/get-nushell.sh;$<
85 nushell:$(NUSHELL_TARGET)
86 # build without clipboard to avoid errors at runtime in container env
87 nushell-build:$(NUSHELL_TARGET)
88  cd $< && cargo build --workspace --release --no-default-features --features=default-no-clipboard,dataframe,extra --locked
89 nushell-install:$(NUSHELL_TARGET) nushell-build
90  cd $< && ./scripts/install-all.sh
91 ### SBCL
92 SBCL_TARGET:=build/src/sbcl
93 SBCL_VERSION:=2.4.4a
94 $(SBCL_TARGET):scripts/get-sbcl.sh $(B)
95  $<
96  cd $(SBCL_TARGET) && \
97  echo '"$(SBCL_VERSION)"' > version.lisp-expr
98 sbcl:$(SBCL_TARGET)
99 #### --with-sb-fasteval --without-sb-eval < broken
100 sbcl-build:$(SBCL_TARGET)
101  cd $< && \
102  ./make.sh \
103  --without-gencgc \
104  --with-mark-region-gc \
105  --dynamic-space-size=8Gb \
106  --fancy
107 sbcl-build-shared:$(SBCL_TARGET) sbcl-build
108  cd $< && \
109  ./make-shared-library.sh
110 sbcl-build-gencgc:$(SBCL_TARGET)
111  cd $< && \
112  ./make.sh \
113  --dynamic-space-size=8Gb \
114  --fancy
115 sbcl-docs:sbcl-build;## REQUIRES TEXLIVE
116  cd $(SBCL_TARGET)/doc/manual && make
117 sbcl-install:sbcl-build;cd $(SBCL_TARGET) && INSTALL_ROOT=/usr/local sh install.sh
118 clean-sbcl:$(SBCL_TARGET);cd $(SBCL_TARGET) && ./clean.sh
119 
120 build/quicklisp.lisp:$(B);cd $< && curl -O https://beta.quicklisp.org/quicklisp.lisp
121 quicklisp-install:scripts/quicklisp-install.sh build/quicklisp.lisp;$<
122 
123 STUMPWM_TARGET:=build/src/stumpwm
124 $(STUMPWM_TARGET):scripts/get-stumpwm.sh $(B);$<
125 stumpwm:$(STUMPWM_TARGET);
126 stumpwm-build:stumpwm;
127  cd $(STUMPWM_TARGET) && ./autogen.sh && ./configure && make
128 stumpwm-install:stumpwm-build;
129  cd $(STUMPWM_TARGET) && make install
130 ### Rust
131 RUST_TARGET:=build/src/rust
132 $(RUST_TARGET):scripts/get-rust.sh $(B);$<
133 rust:$(RUST_TARGET)
134 rust-install-x:rust;
135  cargo install --path $(RUST_TARGET)/src/tools/x
136 rust-build:rust rust-install-x;
137  cd $(RUST_TARGET) && x build library
138 rust-doc:rust rust-install-x;
139  cd $(RUST_TARGET) && x doc
140 rust-build-full:rust-build;
141  cd $(RUST_TARGET) && x build --stage 2 compiler/rustc
142 rust-install:rust-build;
143  cd $(RUST_TARGET) && x install
144 rustup-install:;curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
145 cargo-tools-install:scripts/install-cargo-tools.sh
146  $<
147 ### Tree-sitter
148 TREE_SITTER_TARGET:=build/src/tree-sitter
149 $(TREE_SITTER_TARGET):scripts/get-tree-sitter.sh
150  $<
151 tree-sitter:$(TREE_SITTER_TARGET)
152 tree-sitter-build:$(TREE_SITTER_TARGET)
153 tree-sitter-install:$(TREE_SITTER_TARGET) tree-sitter-build
154 
155 ### Tree-sitter Langs
156 TREE_SITTER_LANGS_TARGET:=build/src/tree-sitter-langs
157 tree-sitter-langs-install:scripts/tree-sitter-install-langs.sh
158  $<
159 ### Etc
160 ETC_TARGET:=build/etc
161 $(ETC_TARGET):scripts/get-etc.sh
162  $<
163 etc:$(ETC_TARGET)
164 
165 ### Code
166 CODE_TARGET:=build/src/$(SRC)
167 $(CODE_TARGET):scripts/get-code.sh $(B)
168  $< $(SRC)
169 code:$(CODE_TARGET)
170 clean-code::;rm -rf $(CODE_TARGET)
171 
172 ### Dist
173 dist/bundle:scripts/bundle-code.sh $(CODE_TARGET)
174  mkdir -pv $@
175  $<
176 
177 dist/sbcl:$(D);
178  scripts/dist-sbcl-binary.sh $(SBCL_TARGET) $(D)
179  cd $(SBCL_TARGET) && sh ./clean.sh
180  scripts/dist-sbcl-source.sh $(SBCL_TARGET) $(D)
181 
182 dist/linux:linux $(D);
183 
184 dist/rocksdb:$(D) rocksdb;
185  cd build/src && \
186  tar -I 'zstd' -cf ../../$</rocksdb.tar.zst rocksdb/include/* rocksdb/librocksdb.*
187 
188 CORE_SRC?=/usr/local/src/core
189 
190 dist/rust:rust-build $(D);
191  cd $(RUST_TARGET) && x dist
192 
193 dist/rust/bin:scripts/cargo-install.sh
194  mkdir -pv $@
195  $< "$(CORE_SRC)/rust/app/cli/alik" dist/rust
196  $< "$(CORE_SRC)/rust/app/cli/krypt" dist/rust
197  $< "$(CORE_SRC)/rust/app/cli/tz" dist/rust
198  $< "$(CORE_SRC)/rust/app/cli/cc-install" dist/rust
199  $< "$(CORE_SRC)/rust/app/cli/mailman" dist/rust
200 
201 dist/emacs:emacs-build $(D);
202  cd $(EMACS_TARGET) && ./make-dist --no-info --no-changelog && \
203  mv emacs-*.*.* emacs && \
204  tar -I 'zstd' -cf ../../../dist/emacs-binary.tar.zst emacs
205 
206 dist/emacs-mini:emacs-build-mini $(D);
207  cd $(EMACS_TARGET) && ./make-dist --no-info --no-changelog && \
208  mv emacs-*.*.* emacs && \
209  tar -I 'zstd' -cf ../../../dist/emacs-mini-binary.tar.zst emacs
210 
211 dist/nushell:$(D) nushell-build
212  cd $(NUSHELL_TARGET)/target/release/ && \
213  tar -I 'zstd' -cf ../../../../../$</nushell.tar.zst \
214  nu nu_plugin_custom_values nu_plugin_formats nu_plugin_gstat \
215  nu_plugin_inc nu_plugin_query
216 
217 dist/tree-sitter:scripts/tree-sitter-install-langs.sh $(D)
218  PREFIX=$(D) $<
219 
220 # requires quicklisp loaded in .skelrc
221 dist/lisp/fasl:scripts/sbcl-save-core.sh
222  mkdir -pv $@
223  $< "$@/std.core"
224  $< "$@/prelude.core" "(mapc #'ql:quickload \
225  (list :nlp :rdb :organ :packy :skel :obj :net :parse :pod :dat :log :packy :rt :syn :xdb :doc :vc))"
226 
227 dist/lisp/bin:scripts/sbcl-make-bin.sh
228  mkdir -pv $@
229  $< bin/skel
230  mv $(CORE_SRC)/lisp/app/bin/skel $@
231  rm -f $(CORE_SRC)/lisp/app/bin/skel.fasl
232  $< bin/organ
233  cp $(CORE_SRC)/lisp/app/bin/organ $@
234  rm -f $(CORE_SRC)/lisp/app/bin/organ.fasl
235  $< bin/homer
236  cp $(CORE_SRC)/lisp/app/bin/homer $@
237  rm -f $(CORE_SRC)/lisp/app/bin/homer.fasl
238  $< bin/packy
239  cp $(CORE_SRC)/lisp/app/bin/packy $@
240  rm -f $(CORE_SRC)/lisp/app/bin/packy.fasl
241  $< bin/rdb
242  cp $(CORE_SRC)/lisp/app/bin/rdb $@
243  rm -f $(CORE_SRC)/lisp/app/bin/rdb.fasl
244 
245 dist/lisp:dist/lisp/fasl dist/lisp/bin
246 
247 core-lisp-install:dist/lisp
248  install -m 755 $</bin/* /usr/local/bin/
249  install -m 755 $</fasl/* /usr/local/lib/sbcl/
250 
251 core-rust-install:dist/rust/bin
252  install -m 755 $</* /usr/local/bin/
253 
254 core-install:core-lisp-install core-rust-install
255 
256 dist/core:dist/rust/bin dist/lisp
257  mkdir -pv $(D)/core
258  cp -rf $(D)/lisp/fasl $(D)/lisp/bin $(D)/core
259  cp -rf $< $(D)/core
260  cd $(D) && tar -I 'zstd' -cf core.tar.zst core
261 
262 ETC:=$(USER)
263 
264 dist/etc:$(ETC_TARGET)
265  cd $(ETC_TARGET) && hg up $(ETC)
266  cp -rf $(ETC_TARGET) $(D)/etc
267 
268 dist/code:code
269  mkdir -pv $@
270  cp -r $(CODE_TARGET)/{org,core,infra,demo,etc} $@
271 dist/pods:pods
272  mkdir -pv $@
273  podman image save -o $@/all.tar archlinux alpine ubuntu box worker operator
274  cd $@ && zstd --ultra -T4 --rm all.tar -o all.tar.zst
275 clean-dist:;rm -rf $(D)
276 clean-build:;rm -rf $(B)