3 # Crazy hack to do shell commands
4 # We do it in Nmakefile because that way we don't have to invoke build through build.cmd
5 # and we can just do ``nmake /f Nmakefile x86-64-vista`` or similar
6 # and we still get the git branch, id, etc
8 !IF [git describe --all > git-describe.tmp] == 0
10 !INCLUDE <git-describe.tmp>
11 !IF [del git-describe.tmp] == 0
15 !IF [git rev-parse HEAD > git-id.tmp] == 0
18 !IF [del git-id.tmp] == 0
22 !IF [git rev-parse --abbrev-ref HEAD > git-branch.tmp] == 0
24 !INCLUDE <git-branch.tmp>
25 !IF [del git-branch.tmp] == 0
29 GIT_LABEL = $(GIT_DESCRIBE)-$(GIT_ID)
33 LINK_FLAGS = /nologo shell32.lib user32.lib
34 CL_FLAGS = /nologo /O2 /WX /W3 /D_CRT_SECURE_NO_WARNINGS /DFACTOR_VERSION=$(VERSION) /DFACTOR_GIT_LABEL=$(GIT_LABEL)
35 CL_FLAGS_VISTA = /D_WIN32_WINNT=0x0600
37 !IF "$(PLATFORM)" == "x86-32"
38 LINK_FLAGS = $(LINK_FLAGS) /safeseh /largeaddressaware
39 PLAF_DLL_OBJS = vm\os-windows-x86.32.obj vm\safeseh.obj vm\cpu-x86.obj
40 SUBSYSTEM_COM_FLAGS = console,"5.01"
41 SUBSYSTEM_EXE_FLAGS = windows,"5.01"
43 !ELSEIF "$(PLATFORM)" == "x86-32-vista"
44 LINK_FLAGS = $(LINK_FLAGS) /safeseh /largeaddressaware
45 CL_FLAGS = $(CL_FLAGS) $(CL_FLAGS_VISTA)
46 PLAF_DLL_OBJS = vm\os-windows-x86.32.obj vm\safeseh.obj vm\cpu-x86.obj
47 SUBSYSTEM_COM_FLAGS = console
48 SUBSYSTEM_EXE_FLAGS = windows
50 !ELSEIF "$(PLATFORM)" == "x86-64"
51 PLAF_DLL_OBJS = vm\os-windows-x86.64.obj vm\cpu-x86.obj
52 SUBSYSTEM_COM_FLAGS = console,"5.02"
53 SUBSYSTEM_EXE_FLAGS = windows,"5.02"
56 !ELSEIF "$(PLATFORM)" == "x86-64-vista"
57 CL_FLAGS = $(CL_FLAGS) $(CL_FLAGS_VISTA)
58 PLAF_DLL_OBJS = vm\os-windows-x86.64.obj vm\cpu-x86.obj
59 SUBSYSTEM_COM_FLAGS = console
60 SUBSYSTEM_EXE_FLAGS = windows
63 CL_FLAGS = $(CL_FLAGS) $(CL_FLAGS_VISTA)
64 PLAF_DLL_OBJS = vm\os-windows-x86.64.obj vm\cpu-x86.obj
65 SUBSYSTEM_COM_FLAGS = console
66 SUBSYSTEM_EXE_FLAGS = windows
71 LINK_FLAGS = $(LINK_FLAGS) /DEBUG
72 CL_FLAGS = $(CL_FLAGS) /Zi /DFACTOR_DEBUG
75 !IF DEFINED(REPRODUCIBLE)
76 CL_FLAGS = $(CL_FLAGS) /DFACTOR_REPRODUCIBLE
79 ML_FLAGS = /nologo /safeseh
81 EXE_OBJS = vm\main-windows.obj vm\factor.res
83 DLL_OBJS = $(PLAF_DLL_OBJS) \
85 vm\aging_collector.obj \
97 vm\data_heap_checker.obj \
100 vm\entry_points.obj \
104 vm\full_collector.obj \
107 vm\inline_cache.obj \
108 vm\instruction_operands.obj \
114 vm\nursery_collector.obj \
115 vm\object_start_map.obj \
121 vm\sampling_profiler.obj \
123 vm\to_tenured_collector.obj \
131 cl /EHsc $(CL_FLAGS) /MP /Fovm/ /c $<
134 cl /EHsc $(CL_FLAGS) /MP /Fovm/ /c $<
137 ml $(ML_FLAGS) /Fo$@ /c $<
142 libfactor-ffi-test.dll: vm/ffi_test.obj
143 link $(LINK_FLAGS) /out:libfactor-ffi-test.dll /dll /def:vm\ffi_test.def vm/ffi_test.obj
145 factor.dll.lib: $(DLL_OBJS)
146 link $(LINK_FLAGS) /implib:factor.dll.lib /out:factor.dll /dll $(DLL_OBJS)
148 factor.com: $(EXE_OBJS) $(DLL_OBJS)
149 link $(LINK_FLAGS) /out:factor.com /SUBSYSTEM:$(SUBSYSTEM_COM_FLAGS) $(EXE_OBJS) $(DLL_OBJS)
151 factor.exe: $(EXE_OBJS) $(DLL_OBJS)
152 link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:$(SUBSYSTEM_EXE_FLAGS) $(EXE_OBJS) $(DLL_OBJS)
154 # If we compile factor.exe, run mt.exe, and run factor.exe,
155 # then Windows caches the manifest. Even on a recompile without applying
156 # the mt.exe tool, if the factor.exe.manifest file is present, the manifest
157 # is applied. To avoid this, we delete the .manifest file on clean
158 # and copy it from a reference file on compilation and mt.exe.
160 factor.exe.manifest: factor.exe
161 copy factor.exe.manifest.in factor.exe.manifest
162 mt -manifest factor.exe.manifest -outputresource:"factor.exe;#1"
164 all: factor.com factor.exe factor.dll.lib libfactor-ffi-test.dll
169 @echo Usage: nmake /f Nmakefile platform
170 @echo Where platform is one of:
178 nmake /nologo PLATFORM=x86-32 /f Nmakefile all
181 nmake /nologo PLATFORM=x86-64 /f Nmakefile all
184 nmake /nologo PLATFORM=x86-32-vista /f Nmakefile all
187 nmake /nologo PLATFORM=x86-64-vista /f Nmakefile all
191 if exist vm\factor.res del vm\factor.res
192 if exist factor.lib del factor.lib
193 if exist factor.com del factor.com
194 if exist factor.exe del factor.exe
195 if exist factor.exe.manifest del factor.exe.manifest
196 if exist factor.exp del factor.exp
197 if exist factor.dll del factor.dll
198 if exist factor.dll.lib del factor.dll.lib
199 if exist factor.dll.exp del factor.dll.exp
200 if exist libfactor-ffi-test.dll del libfactor-ffi-test.dll
201 if exist libfactor-ffi-test.exp del libfactor-ffi-test.exp
202 if exist libfactor-ffi-test.lib del libfactor-ffi-test.lib
204 .PHONY: all default x86-32 x86-64 x86-32-vista x86-64-vista clean factor.exe.manifest