changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > infra / makefile

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