-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.windows
46 lines (36 loc) · 1.78 KB
/
Makefile.windows
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
38
39
40
41
42
43
44
45
46
# assume llvm_headers.zip has been extracted
CFLAGS += -I.
# .a files generated in windows_setup.sh
LDFLAGS += $(wildcard libs/lib*.a)
ifeq ($(CC),cc)
# default c compiler --> use clang
CC := mingw64/bin/clang.exe
endif
# clang version in mingw doesn't seem as mature as what I have on linux...
# it shows a lot of unnecssary/dumb warnings by default
CFLAGS += -Wno-return-type -Wno-uninitialized -Wno-implicit-fallthrough
all: compile_flags.txt jou.exe
# point clangd to the right include folder so i don't get red squiggles in my editor
compile_flags.txt:
echo "-I$(CURDIR)" > compile_flags.txt
config.jou:
echo "# auto-generated by Makefile" > config.jou
echo "def get_jou_clang_path() -> byte*:" >> config.jou
echo " return NULL" >> config.jou
# Stage 1 of bootstrapping: Compile the bootstrap compiler with a C compiler.
BSRC := $(wildcard bootstrap_compiler/*.c)
obj/%.o: bootstrap_compiler/%.c $(wildcard bootstrap_compiler/*.h)
mkdir -p obj && $(CC) -c $(CFLAGS) $< -o $@
jou_stage1.exe: $(BSRC:bootstrap_compiler/%.c=obj/%.o)
$(CC) $(CFLAGS) $^ -o jou_stage1.exe $(LDFLAGS)
# Stage 2 of bootstrapping: Compile the Jou compiler with the bootstrap compiler.
# Don't depend on Jou files, so that only stage 3 recompiles if they're changed.
jou_stage2.exe: jou_stage1.exe config.jou
rm -rf compiler/jou_compiled && ./jou_stage1.exe -o jou_stage2.exe --linker-flags "$(LDFLAGS)" compiler/main.jou
# Stage 3 of bootstrapping: Compile the Jou compiler with the Jou compiler.
jou.exe: jou_stage2.exe config.jou $(wildcard compiler/*.jou compiler/*/*.jou)
rm -rf compiler/jou_compiled && ./jou_stage2.exe -o jou.exe --linker-flags "$(LDFLAGS)" compiler/main.jou
.PHONY: clean
clean:
rm -rvf obj jou.exe jou_stage*.exe tmp compile_flags.txt config.jou
find -name jou_compiled -print -exec rm -rf '{}' +