-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.posix
37 lines (32 loc) · 1.55 KB
/
Makefile.posix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Linux has llvm-config-xx in PATH, where xx is version number
# On macos, brew installs LLVM to a weird place in /usr/local/
# On NetBSD, use llvm-config from libLLVM (package from pkgsrc)
LLVM_CONFIG ?= $(shell \
which llvm-config-16 \
|| which /usr/local/opt/llvm@16/bin/llvm-config \
|| which /opt/homebrew/opt/llvm@16/bin/llvm-config \
|| which llvm-config-15 \
|| which /usr/local/opt/llvm@15/bin/llvm-config \
|| which /opt/homebrew/opt/llvm@15/bin/llvm-config \
|| which llvm-config-14 \
|| which /usr/local/opt/llvm@14/bin/llvm-config \
|| which /opt/homebrew/opt/llvm@14/bin/llvm-config \
|| which /usr/pkg/libexec/libLLVM/llvm-config \
)
all: jou
config.jou:
@v=`$(LLVM_CONFIG) --version`; case "$$v" in 14.*|15.*|16.*) ;; *) echo "Error: Found unsupported LLVM version $$v. Only LLVM 14, 15 and 16 are supported."; exit 1; esac
echo "# auto-generated by Makefile" > config.jou
echo "@public" >> config.jou
echo "def get_jou_clang_path() -> byte*:" >> config.jou
echo " return \"$(shell which `$(LLVM_CONFIG) --bindir`/clang || which clang)\"" >> config.jou
jou_bootstrap: bootstrap.sh
./bootstrap.sh
jou: jou_bootstrap config.jou $(wildcard compiler/*.jou compiler/*/*.jou)
rm -rf compiler/jou_compiled && ./jou_bootstrap -o jou --linker-flags "$(shell $(LLVM_CONFIG) --ldflags --libs)" compiler/main.jou
# Does not delete tmp/bootstrap_cache because bootstrapping is slow.
.PHONY: clean
clean:
bash -O extglob -c "rm -rvf tmp/!(bootstrap_cache)"
rm -vf *.exe config.jou jou jou_bootstrap
find . -name jou_compiled -print -exec rm -rf '{}' +