1
2# aliases
3all: tinygo
4
5# Default build and source directories, as created by `make llvm-build`.
6LLVM_BUILDDIR ?= llvm-build
7LLVM_PROJECTDIR ?= llvm-project
8CLANG_SRC ?= $(LLVM_PROJECTDIR)/clang
9LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
10
11# Try to autodetect LLVM build tools.
12ifneq (, $(shell command -v llvm-build/bin/clang 2> /dev/null))
13    CLANG ?= $(abspath llvm-build/bin/clang)
14else
15    CLANG ?= clang-10
16endif
17ifneq (, $(shell command -v llvm-build/bin/llvm-ar 2> /dev/null))
18    LLVM_AR ?= $(abspath llvm-build/bin/llvm-ar)
19else ifneq (, $(shell command -v llvm-ar-10 2> /dev/null))
20    LLVM_AR ?= llvm-ar-10
21else
22    LLVM_AR ?= llvm-ar
23endif
24ifneq (, $(shell command -v llvm-build/bin/llvm-nm 2> /dev/null))
25    LLVM_NM ?= $(abspath llvm-build/bin/llvm-nm)
26else ifneq (, $(shell command -v llvm-nm-10 2> /dev/null))
27    LLVM_NM ?= llvm-nm-10
28else
29    LLVM_NM ?= llvm-nm
30endif
31
32# Go binary and GOROOT to select
33GO ?= go
34export GOROOT = $(shell $(GO) env GOROOT)
35
36# md5sum binary
37MD5SUM = md5sum
38
39# tinygo binary for tests
40TINYGO ?= tinygo
41
42# Use CCACHE for LLVM if possible
43ifneq (, $(CCACHE_DIR))
44    LLVM_OPTION += '-DLLVM_CCACHE_BUILD=ON'
45endif
46
47# Allow enabling LLVM assertions
48ifeq (1, $(ASSERT))
49    LLVM_OPTION += '-DLLVM_ENABLE_ASSERTIONS=ON'
50else
51    LLVM_OPTION += '-DLLVM_ENABLE_ASSERTIONS=OFF'
52endif
53
54.PHONY: all tinygo test $(LLVM_BUILDDIR) llvm-source clean fmt gen-device gen-device-nrf gen-device-nxp gen-device-avr
55
56LLVM_COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfodwarf executionengine frontendopenmp instrumentation interpreter ipo irreader linker lto mc mcjit objcarcopts option profiledata scalaropts support target
57
58ifeq ($(OS),Windows_NT)
59    EXE = .exe
60    START_GROUP = -Wl,--start-group
61    END_GROUP = -Wl,--end-group
62
63    # LLVM compiled using MinGW on Windows appears to have problems with threads.
64    # Without this flag, linking results in errors like these:
65    #     libLLVMSupport.a(Threading.cpp.obj):Threading.cpp:(.text+0x55): undefined reference to `std::thread::hardware_concurrency()'
66    LLVM_OPTION += -DLLVM_ENABLE_THREADS=OFF
67
68    CGO_LDFLAGS += -static -static-libgcc -static-libstdc++
69    CGO_LDFLAGS_EXTRA += -lversion
70
71    # Build libclang manually because the CMake-based build system on Windows
72    # doesn't allow building libclang as a static library.
73    LIBCLANG_PATH = $(abspath build/libclang-custom.a)
74    LIBCLANG_FILES = $(abspath $(wildcard $(LLVM_BUILDDIR)/tools/clang/tools/libclang/CMakeFiles/libclang.dir/*.cpp.obj))
75
76    # Add the libclang dependency to the tinygo binary target.
77tinygo: $(LIBCLANG_PATH)
78test: $(LIBCLANG_PATH)
79    # Build libclang.
80$(LIBCLANG_PATH): $(LIBCLANG_FILES)
81	@mkdir -p build
82	ar rcs $(LIBCLANG_PATH) $^
83
84else ifeq ($(shell uname -s),Darwin)
85    MD5SUM = md5
86    LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a
87else ifeq ($(shell uname -s),FreeBSD)
88    MD5SUM = md5
89    LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a
90    START_GROUP = -Wl,--start-group
91    END_GROUP = -Wl,--end-group
92else
93    LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a
94    START_GROUP = -Wl,--start-group
95    END_GROUP = -Wl,--end-group
96endif
97
98CLANG_LIBS = $(START_GROUP) -lclangAnalysis -lclangARCMigrate -lclangAST -lclangASTMatchers -lclangBasic -lclangCodeGen -lclangCrossTU -lclangDriver -lclangDynamicASTMatchers -lclangEdit -lclangFormat -lclangFrontend -lclangFrontendTool -lclangHandleCXX -lclangHandleLLVM -lclangIndex -lclangLex -lclangParse -lclangRewrite -lclangRewriteFrontend -lclangSema -lclangSerialization -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend -lclangTooling -lclangToolingASTDiff -lclangToolingCore -lclangToolingInclusions $(END_GROUP) -lstdc++
99
100LLD_LIBS = $(START_GROUP) -llldCOFF -llldCommon -llldCore -llldDriver -llldELF -llldMachO -llldMinGW -llldReaderWriter -llldWasm -llldYAML $(END_GROUP)
101
102
103# For static linking.
104ifneq ("$(wildcard $(LLVM_BUILDDIR)/bin/llvm-config*)","")
105    CGO_CPPFLAGS=$(shell $(LLVM_BUILDDIR)/bin/llvm-config --cppflags) -I$(abspath $(LLVM_BUILDDIR))/tools/clang/include -I$(abspath $(CLANG_SRC))/include -I$(abspath $(LLD_SRC))/include
106    CGO_CXXFLAGS=-std=c++14
107    CGO_LDFLAGS+=$(LIBCLANG_PATH) -L$(abspath $(LLVM_BUILDDIR)/lib) $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA)
108endif
109
110
111clean:
112	@rm -rf build
113
114FMT_PATHS = ./*.go builder cgo compiler interp ir loader src/device/arm src/examples src/machine src/os src/reflect src/runtime src/sync src/syscall src/internal/reflectlite transform
115fmt:
116	@gofmt -l -w $(FMT_PATHS)
117fmt-check:
118	@unformatted=$$(gofmt -l $(FMT_PATHS)); [ -z "$$unformatted" ] && exit 0; echo "Unformatted:"; for fn in $$unformatted; do echo "  $$fn"; done; exit 1
119
120
121gen-device: gen-device-avr gen-device-nrf gen-device-sam gen-device-sifive gen-device-stm32 gen-device-kendryte gen-device-nxp
122
123gen-device-avr:
124	$(GO) build -mod=vendor -o ./build/gen-device-avr ./tools/gen-device-avr/
125	./build/gen-device-avr lib/avr/packs/atmega src/device/avr/
126	./build/gen-device-avr lib/avr/packs/tiny src/device/avr/
127	@GO111MODULE=off $(GO) fmt ./src/device/avr
128
129build/gen-device-svd: ./tools/gen-device-svd/*.go
130	$(GO) build -mod=vendor -o $@ ./tools/gen-device-svd/
131
132gen-device-nrf: build/gen-device-svd
133	./build/gen-device-svd -source=https://github.com/NordicSemiconductor/nrfx/tree/master/mdk lib/nrfx/mdk/ src/device/nrf/
134	GO111MODULE=off $(GO) fmt ./src/device/nrf
135
136gen-device-nxp: build/gen-device-svd
137	./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/NXP lib/cmsis-svd/data/NXP/ src/device/nxp/
138	GO111MODULE=off $(GO) fmt ./src/device/nxp
139
140gen-device-sam: build/gen-device-svd
141	./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/Atmel lib/cmsis-svd/data/Atmel/ src/device/sam/
142	GO111MODULE=off $(GO) fmt ./src/device/sam
143
144gen-device-sifive: build/gen-device-svd
145	./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/SiFive-Community -interrupts=software lib/cmsis-svd/data/SiFive-Community/ src/device/sifive/
146	GO111MODULE=off $(GO) fmt ./src/device/sifive
147
148gen-device-kendryte: build/gen-device-svd
149	./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/Kendryte-Community -interrupts=software lib/cmsis-svd/data/Kendryte-Community/ src/device/kendryte/
150	GO111MODULE=off $(GO) fmt ./src/device/kendryte
151
152gen-device-stm32: build/gen-device-svd
153	./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/STMicro lib/cmsis-svd/data/STMicro/ src/device/stm32/
154	GO111MODULE=off $(GO) fmt ./src/device/stm32
155
156
157# Get LLVM sources.
158$(LLVM_PROJECTDIR)/README.md:
159	git clone -b release/10.x --depth=1 https://github.com/llvm/llvm-project $(LLVM_PROJECTDIR)
160llvm-source: $(LLVM_PROJECTDIR)/README.md
161
162# Configure LLVM.
163TINYGO_SOURCE_DIR=$(shell pwd)
164$(LLVM_BUILDDIR)/build.ninja: llvm-source
165	mkdir -p $(LLVM_BUILDDIR); cd $(LLVM_BUILDDIR); cmake -G Ninja $(TINYGO_SOURCE_DIR)/$(LLVM_PROJECTDIR)/llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;RISCV;WebAssembly" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR" -DCMAKE_BUILD_TYPE=Release -DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF $(LLVM_OPTION)
166
167# Build LLVM.
168$(LLVM_BUILDDIR): $(LLVM_BUILDDIR)/build.ninja
169	cd $(LLVM_BUILDDIR); ninja
170
171
172# Build wasi-libc sysroot
173.PHONY: wasi-libc
174wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
175lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
176	cd lib/wasi-libc && gmake WASM_CC=$(CLANG) WASM_AR=$(LLVM_AR) WASM_NM=$(LLVM_NM)
177
178
179# Build the Go compiler.
180tinygo:
181	@if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo "  make llvm-source"; echo "  make $(LLVM_BUILDDIR)"; exit 1; fi
182	CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) build -buildmode exe -o build/tinygo$(EXE) -tags byollvm -mod=vendor .
183
184test: wasi-libc
185	CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test -v -buildmode exe -tags byollvm -mod=vendor ./cgo ./compileopts ./interp ./transform .
186
187tinygo-test:
188	cd tests/tinygotest && tinygo test
189
190.PHONY: smoketest
191smoketest:
192	$(TINYGO) version
193	# test all examples (except pwm)
194	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/blinky1
195	@$(MD5SUM) test.hex
196	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/adc
197	@$(MD5SUM) test.hex
198	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/blinkm
199	@$(MD5SUM) test.hex
200	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/blinky2
201	@$(MD5SUM) test.hex
202	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/button
203	@$(MD5SUM) test.hex
204	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/button2
205	@$(MD5SUM) test.hex
206	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/echo
207	@$(MD5SUM) test.hex
208	$(TINYGO) build -size short -o test.hex -target=circuitplay-express examples/i2s
209	@$(MD5SUM) test.hex
210	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/mcp3008
211	@$(MD5SUM) test.hex
212	$(TINYGO) build -size short -o test.hex -target=microbit            examples/microbit-blink
213	@$(MD5SUM) test.hex
214	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/pininterrupt
215	@$(MD5SUM) test.hex
216	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/serial
217	@$(MD5SUM) test.hex
218	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/systick
219	@$(MD5SUM) test.hex
220	$(TINYGO) build -size short -o test.hex -target=pca10040            examples/test
221	@$(MD5SUM) test.hex
222	# test simulated boards on play.tinygo.org
223	$(TINYGO) build             -o test.wasm -tags=arduino              examples/blinky1
224	@$(MD5SUM) test.wasm
225	$(TINYGO) build             -o test.wasm -tags=hifive1-qemu         examples/serial
226	@$(MD5SUM) test.wasm
227	$(TINYGO) build             -o test.wasm -tags=hifive1b             examples/blinky1
228	@$(MD5SUM) test.wasm
229	$(TINYGO) build             -o test.wasm -tags=reelboard            examples/blinky1
230	@$(MD5SUM) test.wasm
231	$(TINYGO) build             -o test.wasm -tags=pca10040             examples/blinky2
232	@$(MD5SUM) test.wasm
233	$(TINYGO) build             -o test.wasm -tags=pca10056             examples/blinky2
234	@$(MD5SUM) test.wasm
235	$(TINYGO) build             -o test.wasm -tags=circuitplay_express  examples/blinky1
236	@$(MD5SUM) test.wasm
237	# test all targets/boards
238	$(TINYGO) build -size short -o test.hex -target=pca10040-s132v6     examples/blinky1
239	@$(MD5SUM) test.hex
240	$(TINYGO) build -size short -o test.hex -target=microbit            examples/echo
241	@$(MD5SUM) test.hex
242	$(TINYGO) build -size short -o test.hex -target=microbit-s110v8     examples/echo
243	@$(MD5SUM) test.hex
244	$(TINYGO) build -size short -o test.hex -target=nrf52840-mdk        examples/blinky1
245	@$(MD5SUM) test.hex
246	$(TINYGO) build -size short -o test.hex -target=pca10031            examples/blinky1
247	@$(MD5SUM) test.hex
248	$(TINYGO) build -size short -o test.hex -target=bluepill            examples/blinky1
249	@$(MD5SUM) test.hex
250	$(TINYGO) build -size short -o test.hex -target=reelboard           examples/blinky1
251	@$(MD5SUM) test.hex
252	$(TINYGO) build -size short -o test.hex -target=reelboard           examples/blinky2
253	@$(MD5SUM) test.hex
254	$(TINYGO) build -size short -o test.hex -target=pca10056            examples/blinky1
255	@$(MD5SUM) test.hex
256	$(TINYGO) build -size short -o test.hex -target=pca10056            examples/blinky2
257	@$(MD5SUM) test.hex
258	$(TINYGO) build -size short -o test.hex -target=itsybitsy-m0        examples/blinky1
259	@$(MD5SUM) test.hex
260	$(TINYGO) build -size short -o test.hex -target=feather-m0          examples/blinky1
261	@$(MD5SUM) test.hex
262	$(TINYGO) build -size short -o test.hex -target=trinket-m0          examples/blinky1
263	@$(MD5SUM) test.hex
264	$(TINYGO) build -size short -o test.hex -target=circuitplay-express examples/blinky1
265	@$(MD5SUM) test.hex
266	$(TINYGO) build -size short -o test.hex -target=stm32f4disco        examples/blinky1
267	@$(MD5SUM) test.hex
268	$(TINYGO) build -size short -o test.hex -target=stm32f4disco        examples/blinky2
269	@$(MD5SUM) test.hex
270	$(TINYGO) build -size short -o test.hex -target=stm32f4disco-1       examples/blinky1
271	@$(MD5SUM) test.hex
272	$(TINYGO) build -size short -o test.hex -target=circuitplay-bluefruit examples/blinky1
273	@$(MD5SUM) test.hex
274	$(TINYGO) build -size short -o test.hex -target=circuitplay-express examples/i2s
275	@$(MD5SUM) test.hex
276	$(TINYGO) build -size short -o test.hex -target=clue_alpha          examples/blinky1
277	@$(MD5SUM) test.hex
278	$(TINYGO) build -size short -o test.gba -target=gameboy-advance     examples/gba-display
279	@$(MD5SUM) test.gba
280	$(TINYGO) build -size short -o test.hex -target=itsybitsy-m4        examples/blinky1
281	@$(MD5SUM) test.hex
282	$(TINYGO) build -size short -o test.hex -target=feather-m4          examples/blinky1
283	@$(MD5SUM) test.hex
284	$(TINYGO) build -size short -o test.hex -target=pybadge             examples/blinky1
285	@$(MD5SUM) test.hex
286	$(TINYGO) build -size short -o test.hex -target=metro-m4-airlift    examples/blinky1
287	@$(MD5SUM) test.hex
288	$(TINYGO) build -size short -o test.hex -target=pyportal            examples/blinky1
289	@$(MD5SUM) test.hex
290	$(TINYGO) build -size short -o test.hex -target=particle-argon      examples/blinky1
291	@$(MD5SUM) test.hex
292	$(TINYGO) build -size short -o test.hex -target=particle-boron      examples/blinky1
293	@$(MD5SUM) test.hex
294	$(TINYGO) build -size short -o test.hex -target=particle-xenon      examples/blinky1
295	@$(MD5SUM) test.hex
296	$(TINYGO) build -size short -o test.hex -target=nucleo-f103rb       examples/blinky1
297	@$(MD5SUM) test.hex
298	$(TINYGO) build -size short -o test.hex -target=pinetime-devkit0    examples/blinky1
299	@$(MD5SUM) test.hex
300	$(TINYGO) build -size short -o test.hex -target=x9pro               examples/blinky1
301	@$(MD5SUM) test.hex
302	$(TINYGO) build -size short -o test.hex -target=pca10056-s140v7     examples/blinky1
303	@$(MD5SUM) test.hex
304	$(TINYGO) build -size short -o test.hex -target=reelboard-s140v7    examples/blinky1
305	@$(MD5SUM) test.hex
306	$(TINYGO) build -size short -o test.hex -target=wioterminal         examples/blinky1
307	@$(MD5SUM) test.hex
308	$(TINYGO) build -size short -o test.hex -target=pygamer             examples/blinky1
309	@$(MD5SUM) test.hex
310	$(TINYGO) build -size short -o test.hex -target=xiao                examples/blinky1
311	@$(MD5SUM) test.hex
312	$(TINYGO) build -size short -o test.hex -target=circuitplay-express examples/dac
313	@$(MD5SUM) test.hex
314	$(TINYGO) build -size short -o test.hex -target=pyportal            examples/dac
315	@$(MD5SUM) test.hex
316	$(TINYGO) build -size short -o test.hex -target=feather-nrf52840  	examples/blinky1
317	@$(MD5SUM) test.hex
318ifneq ($(AVR), 0)
319	$(TINYGO) build -size short -o test.hex -target=atmega1284p         examples/serial
320	@$(MD5SUM) test.hex
321	$(TINYGO) build -size short -o test.hex -target=arduino             examples/blinky1
322	@$(MD5SUM) test.hex
323	$(TINYGO) build -size short -o test.hex -target=arduino             examples/pwm
324	@$(MD5SUM) test.hex
325	$(TINYGO) build -size short -o test.hex -target=arduino -scheduler=tasks  examples/blinky1
326	@$(MD5SUM) test.hex
327	$(TINYGO) build -size short -o test.hex -target=arduino-nano        examples/blinky1
328	@$(MD5SUM) test.hex
329	$(TINYGO) build -size short -o test.hex -target=digispark           examples/blinky1
330	@$(MD5SUM) test.hex
331	$(TINYGO) build -size short -o test.hex -target=digispark -gc=leaking examples/blinky1
332	@$(MD5SUM) test.hex
333endif
334	$(TINYGO) build -size short -o test.hex -target=hifive1b            examples/blinky1
335	@$(MD5SUM) test.hex
336	$(TINYGO) build -size short -o test.hex -target=maixbit             examples/blinky1
337	@$(MD5SUM) test.hex
338	$(TINYGO) build             -o wasm.wasm -target=wasm               examples/wasm/export
339	$(TINYGO) build             -o wasm.wasm -target=wasm               examples/wasm/main
340	# test various compiler flags
341	$(TINYGO) build -size short -o test.hex -target=pca10040 -gc=none -scheduler=none examples/blinky1
342	@$(MD5SUM) test.hex
343	$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1     examples/blinky1
344	@$(MD5SUM) test.hex
345	$(TINYGO) build             -o test.elf -target=nintendoswitch      examples/serial
346	@$(MD5SUM) test.elf
347
348wasmtest:
349	$(GO) test ./tests/wasm
350
351build/release: tinygo gen-device wasi-libc
352	@mkdir -p build/release/tinygo/bin
353	@mkdir -p build/release/tinygo/lib/clang/include
354	@mkdir -p build/release/tinygo/lib/CMSIS/CMSIS
355	@mkdir -p build/release/tinygo/lib/compiler-rt/lib
356	@mkdir -p build/release/tinygo/lib/nrfx
357	@mkdir -p build/release/tinygo/lib/picolibc/newlib/libc
358	@mkdir -p build/release/tinygo/lib/wasi-libc
359	@mkdir -p build/release/tinygo/pkg/armv6m-none-eabi
360	@mkdir -p build/release/tinygo/pkg/armv7m-none-eabi
361	@mkdir -p build/release/tinygo/pkg/armv7em-none-eabi
362	@echo copying source files
363	@cp -p  build/tinygo$(EXE)           build/release/tinygo/bin
364	@cp -p $(abspath $(CLANG_SRC))/lib/Headers/*.h build/release/tinygo/lib/clang/include
365	@cp -rp lib/CMSIS/CMSIS/Include      build/release/tinygo/lib/CMSIS/CMSIS
366	@cp -rp lib/CMSIS/README.md          build/release/tinygo/lib/CMSIS
367	@cp -rp lib/compiler-rt/lib/builtins build/release/tinygo/lib/compiler-rt/lib
368	@cp -rp lib/compiler-rt/LICENSE.TXT  build/release/tinygo/lib/compiler-rt
369	@cp -rp lib/compiler-rt/README.txt   build/release/tinygo/lib/compiler-rt
370	@cp -rp lib/nrfx/*                   build/release/tinygo/lib/nrfx
371	@cp -rp lib/picolibc/newlib/libc/ctype       build/release/tinygo/lib/picolibc/newlib/libc
372	@cp -rp lib/picolibc/newlib/libc/include     build/release/tinygo/lib/picolibc/newlib/libc
373	@cp -rp lib/picolibc/newlib/libc/locale      build/release/tinygo/lib/picolibc/newlib/libc
374	@cp -rp lib/picolibc/newlib/libc/string      build/release/tinygo/lib/picolibc/newlib/libc
375	@cp -rp lib/picolibc/newlib/libc/tinystdio   build/release/tinygo/lib/picolibc/newlib/libc
376	@cp -rp lib/picolibc-include         build/release/tinygo/lib
377	@cp -rp lib/wasi-libc/sysroot        build/release/tinygo/lib/wasi-libc/sysroot
378	@cp -rp src                          build/release/tinygo/src
379	@cp -rp targets                      build/release/tinygo/targets
380	./build/tinygo build-library -target=armv6m-none-eabi  -o build/release/tinygo/pkg/armv6m-none-eabi/compiler-rt.a compiler-rt
381	./build/tinygo build-library -target=armv7m-none-eabi  -o build/release/tinygo/pkg/armv7m-none-eabi/compiler-rt.a compiler-rt
382	./build/tinygo build-library -target=armv7em-none-eabi -o build/release/tinygo/pkg/armv7em-none-eabi/compiler-rt.a compiler-rt
383	./build/tinygo build-library -target=armv6m-none-eabi  -o build/release/tinygo/pkg/armv6m-none-eabi/picolibc.a picolibc
384	./build/tinygo build-library -target=armv7m-none-eabi  -o build/release/tinygo/pkg/armv7m-none-eabi/picolibc.a picolibc
385	./build/tinygo build-library -target=armv7em-none-eabi -o build/release/tinygo/pkg/armv7em-none-eabi/picolibc.a picolibc
386release: build/release
387	tar -czf build/release.tar.gz -C build/release tinygo
388
389deb: build/release
390	@mkdir -p build/release-deb/usr/local/bin
391	@mkdir -p build/release-deb/usr/local/lib
392	cp -ar build/release/tinygo build/release-deb/usr/local/lib/tinygo
393	ln -sf ../lib/tinygo/bin/tinygo build/release-deb/usr/local/bin/tinygo
394	fpm -f -s dir -t deb -n tinygo -v $(shell grep "const Version = " goenv/version.go | awk '{print $$NF}') -m '@tinygo-org' --description='TinyGo is a Go compiler for small places.' --license='BSD 3-Clause' --url=https://tinygo.org/ --deb-changelog CHANGELOG.md -p build/release.deb -C ./build/release-deb
395