-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
151 lines (125 loc) · 5.08 KB
/
Makefile
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
### CONFIGURATION
# How to run CLR programs; can be blank for Win32
RUN_CLR=mono
CSC=gmcs /debug+
RM=rm -f
CP=cp
WGET_O=wget --no-check-certificate -O
#WGET_O=curl -L -o
PREFIX=/usr/local
INSTBIN=$(PREFIX)/bin
INSTNIECZA=$(INSTBIN)/niecza
# next three will be wiped out by install!
INSTLIB=$(PREFIX)/lib/niecza/lib
INSTEXE=$(PREFIX)/lib/niecza/bin
INSTOBJ=$(PREFIX)/lib/niecza/obj
cskernel=Kernel.cs Builtins.cs Cursor.cs JSYNC.cs NieczaCLR.cs Utils.cs \
ObjModel.cs BigInteger.cs Printf.cs CodeGen.cs \
GeneratedTrigFunctions.cs Serialize.cs UCD.cs \
SpecialMathFunctions.cs CompilerBinding.cs GetLine.cs
# Tell make to regard the following targets as not being filenames
.PHONY: all aot test spectest clean realclean
.PHONY: help
libunits=CORE
srcunits=CClass CgOp Op OpHelpers Sig RxOp STD NieczaGrammar OptRxSimple \
Operator NieczaActions NieczaFrontendSTD NieczaPassSimplifier \
OptBeta NieczaPathSearch NieczaBackendDotnet NieczaCompiler GetOptLong
precompunits=CORP CORN Test Threads JSYNC
all: run/Niecza.exe run/Kernel.dll obj/CORE.dll
$(patsubst %,run/%.ser,$(srcunits)): run/%.ser: .fetch-stamp src/%.pm6 run/CORE.ser
NIECZA_KEEP_IL=1 $(RUN_CLR) boot/run/Niecza.exe --obj-dir run -I src -C $*
# hack - put VERSION info in place so the sobj/MAIN.exeetting build can embed it
obj/CORE.dll: run/Niecza.exe run/Kernel.dll lib/CORE.setting
@git describe --tags > VERSION
$(RUN_CLR) run/Niecza.exe --obj-dir obj -C CORE
run/Niecza.exe: .fetch-stamp $(patsubst %,run/%.ser,$(srcunits)) src/niecza
NIECZA_KEEP_IL=1 $(RUN_CLR) boot/run/Niecza.exe --obj-dir run -I src -c src/niecza
$(CP) run/MAIN.exe run/Niecza.exe
.fetch-stamp: FETCH_URL
-rm -rf boot/
mkdir boot
$(WGET_O) boot/niecza.zip $$(cat FETCH_URL)
cd boot && unzip niecza.zip
NIECZA_KEEP_IL=1 $(RUN_CLR) boot/run/Niecza.exe --obj-dir=run -C $(libunits)
touch .fetch-stamp
run/CORE.ser: .fetch-stamp
# undocumented. don't use
boot-from-installed:
-rm -rf boot/
mkdir boot boot/run boot/lib boot/obj
$(CP) $(INSTEXE)/* boot/run
$(CP) $(INSTLIB)/* boot/lib
NIECZA_KEEP_IL=1 $(RUN_CLR) boot/run/Niecza.exe --obj-dir=run -C $(libunits)
touch .fetch-stamp
run/Kernel.dll: $(patsubst %,lib/%,$(cskernel)) lib/unidata
$(CSC) /target:exe /out:run/Kernel.dll /lib:obj /unsafe+ \
/res:lib/unidata $(patsubst %,lib/%,$(cskernel))
.PHONY: Niecza_pm
perl5: obj/Perl5Interpreter.dll obj/p5embed.so Niecza_pm
Niecza_pm:
cd perl5/Niecza;perl Build.PL;perl Build
obj/Perl5Interpreter.dll: obj/Run.Kernel.dll lib/Perl5Interpreter.cs
$(CSC) /target:library /lib:obj /out:obj/Perl5Interpreter.dll /r:Run.Kernel.dll lib/Perl5Interpreter.cs
obj/p5embed.so: lib/p5embed.c
perl perl5/build_interop
aot: all
mono --aot run/*.dll obj/Run.CORE.dll run/Niecza.exe
test: all
$(RUN_CLR) run/Niecza.exe --obj-dir obj -c test.pl
$(CP) run/Kernel.dll obj/
prove -e "$(RUN_CLR)" obj/MAIN.exe
spectest: all
@t/run_spectests
precomp: all
$(RUN_CLR) run/Niecza.exe --obj-dir obj -C $(precompunits)
install: all precomp
-rm -rf $(INSTEXE) $(INSTLIB) $(INSTOBJ)
mkdir -p $(INSTBIN) $(INSTEXE) $(INSTLIB) $(INSTOBJ)
$(CP) run/*.dll run/*.ser run/*.exe $(INSTEXE)
$(CP) $(patsubst %,obj/%.ser,CORE $(precompunits)) $(patsubst %,obj/%.dll,CORE $(precompunits)) $(INSTOBJ)
$(CP) lib/*.pm6 lib/*.setting $(INSTLIB)
echo '#! /bin/sh' > $(INSTNIECZA)
echo 'exec $(RUN_CLR) $(INSTEXE)/MAIN.exe "$$@"' >> $(INSTNIECZA)
chmod +x $(INSTNIECZA)
clean:
@rm -f obj/*.dll obj/*.exe obj/*.ser obj/*.so obj/*.dylib
@rm -f run/*.exe run/*.dll run/*.so run/*.dylib
@rm -fr *~
# uses the current niecza to set up a build area for the next stage
mkpackage:
rm -rf package/
mkdir package/ package/run/ package/lib/
cp -a docs README.pod LICENSE package/
cp -a run/Kernel.dll package/run
$(RUN_CLR) run/Kernel.dll -regenerate run/ package/run/ Niecza
cp lib/*.pm6 lib/*.setting package/lib/
mknext: run/Niecza.exe run/Kernel.dll
rm -rf next/
mkdir -p next next/boot next/obj next/run next/boot/run next/boot/obj/
touch next/FETCH_URL next/.fetch-stamp
cp -a src lib docs README.pod LICENSE Makefile test.pl next/
cp -a run lib next/boot/
ln -s ../t next/t
NIECZA_KEEP_IL=1 $(RUN_CLR) next/boot/run/Niecza.exe --obj-dir next/run -C $(libunits)
realclean: clean
@rm .fetch-stamp
help:
@echo ''
@echo 'You can make the following targets in this Niecza Makefile:'
@echo ''
@echo 'all the main Niecza compiler and runtime files (default)'
@echo 'aot Ahead of Time compile run/Niecza.exe and run/*.dll (increases speed)'
@echo 'install Copies files to $(PREFIX) and creates a shell wrapper'
@echo 'test run/Niecza.exe test.pl'
@echo 'spectest t/run_spectests'
@echo 'clean remove all generated files'
@echo 'realclean clean and also require new download of bootstrap files'
@echo 'help this list of targets'
@echo ''
# grep -r '^use' src/*.pm6 | sed 's|src/\(.*\)\.pm6:use \(.*\);|run/\1.ser: run/\2.ser|' | grep -v MONKEY_TYPING
run/NieczaActions.ser: run/OpHelpers.ser
run/NieczaFrontendSTD.ser: run/STD.ser
run/NieczaFrontendSTD.ser: run/NieczaGrammar.ser
run/NieczaGrammar.ser: run/STD.ser
run/Operator.ser: run/OpHelpers.ser
run/OptRxSimple.ser: run/RxOp.ser