-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
209 lines (163 loc) · 3.63 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# FIXME use cmake
# NOTE: This one Makefile works with Microsoft nmake and GNU make.
# They use different conditional syntax, but each can be nested and inverted within the other.
all: check
ifdef MAKEDIR:
!ifdef MAKEDIR
#
# Microsoft nmake on Windows with desktop CLR, Visual C++.
#
CFLAGS=-MD -Gy -Z7 -GX
CPPFLAGS=-MD -Gy -Z7 -GX
RM_F = del 2>nul /f
#ILDASM = ildasm /nobar /out:$@
#ILASM = ilasm /quiet
#RUN_EACH=for %%a in (
#RUN_EACH_END=) do @$Q$(MONO)$Q %%a
O=obj
!else
else
#
# GNU/Posix make on Unix with mono, gcc, clang, etc.
#
RM_F = rm -f
#ILDASM = ikdasm >$@
#ILASM = ilasm
#MONO ?= mono
#RUN_EACH=for a in
#RUN_EACH_END=;do $(MONO) $${a}; done
O=o
endif
!endif :
check:
clean:
exe:
ifdef MAKEDIR:
!ifdef MAKEDIR
!if !exist (./config.mk)
!if [.\config.cmd]
!endif
!endif
!if exist (./config.mk)
!include ./config.mk
!endif
#!message AMD64=$(AMD64)
#!message 386=$(386)
!if !defined (AMD64) && !defined (386) && !defined (ARM)
AMD64=1
386=0
ARM=0
!endif
!if $(AMD64)
win=winamd64.exe
386=0
ARM=0
!elseif $(386)
win=winx86.exe
AMD64=0
ARM=0
!elseif $(ARM)
win=winarm.exe
AMD64=0
386=0
!endif
!ifndef win
win=win.exe
!endif
all: $(win)
config:
.\config.cmd
check:
run: $(win)
.\$(win) hello.wasm
debug: $(win)
!if $(AMD64)
\bin\amd64\cdb .\$(win) hello.wasm
!elseif $(386)
\bin\x86\cdb .\$(win) hello.wasm
!endif
clean:
$(RM_F) $(win) w3rt.o w3rt.obj w3.obj *.ilk win32 win32.exe win64 win64.exe win win.exe winarm.exe winx86.exe winamd64.exe *.pdb lin *.i
# TODO clang cross
#
#mac: w3.cpp
# g++ -g w3.cpp -o $@
#
# TODO /Qspectre
OBJS= w3Fd.$O \
w3Handle.$O \
w3InstructionEncoding.$O \
w3InstructionNames.$O \
w3Int.$O \
w3MemoryMappedFile.$O \
w3Module.$O \
w3rt.$O \
w3Unpack.$O \
isinf.$O \
isnan.$O \
s_floor.$O \
s_floorf.$O \
s_round.$O \
s_roundf.$O \
s_trunc.$O \
s_truncf.$O \
$(win): w3.cpp $(OBJS)
@-del $(@R).pdb $(@R).ilk
@rem TODO /GX on old, /EHsc on new
rem cl -MD -Gy -Z7 /O2s $(Wall) $(Qspectre) -W4 -GX $** /link /out:$@ /incremental:no /opt:ref,icf
cl -MD -Gy -Z7 $(Wall) $(Qspectre) -W4 /GX $** /link /out:$@ /incremental:no /opt:ref /pdb:$(@B).pdb
!else
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S), Cygwin)
Cygwin=1
NativeTarget=cyg
else
Cygwin=0
Linux=0
endif
ifeq ($(UNAME_S), Linux)
Linux=1
NativeTarget=lin
else
Cygwin=0
endif
# TODO Darwin, Linux, etc.
# FIXME winarm64 etc.
all: $(NativeTarget) win32.exe win64.exe
run: $(NativeTarget)
./$(NativeTarget) /s/mono/mcs/class/lib/build-macos/mscorlib.dll
debug: mac
lldb -- ./$(NativeTarget) /s/mono/mcs/class/lib/build-macos/mscorlib.dll
clean:
$(RM_F) w3rt.o w3rt.obj mac win32 win32.exe win64 win64.exe win win.exe cyg cyg.exe *.ilk lin win.exe winarm.exe winx86.exe winamd64.exe
OBJS= w3Fd.$O \
w3Handle.$O \
w3InstructionEncoding.$O \
w3InstructionNames.$O \
w3Int.$O \
w3MemoryMappedFile.$O \
w3Module.$O \
w3rt.$O \
w3Unpack.$O \
isinf.$O \
isnan.$O \
s_floor.$O \
s_floorf.$O \
s_round.$O \
s_roundf.$O \
s_trunc.$O \
s_truncf.$O \
mac: w3.cpp $(OBJS)
g++ -g w3.cpp $(OBJS) -o $@ -Bsymbolic -bind_at_load
cyg: w3.cpp $(OBJS)
g++ -g w3.cpp $(OBJS) -o $@ -Bsymbolic -znow -zrelro
lin: w3.cpp $(OBJS)
g++ -Wall -g w3.cpp $(OBJS) -o $@ -Bsymbolic -znow -zrelro
win32.exe: w3.cpp $(OBJS)
i686-w64-mingw32-g++ -g w3.cpp $(OBJS) -o $@ -Bsymbolic
win64.exe: w3.cpp $(OBJS)
x86_64-w64-mingw32-g++ -g w3.cpp $(OBJS) -o $@ -Bsymbolic
test:
endif
!endif :