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 \
103 vm\full_collector.obj \
106 vm\inline_cache.obj \
107 vm\instruction_operands.obj \
113 vm\nursery_collector.obj \
114 vm\object_start_map.obj \
120 vm\sampling_profiler.obj \
122 vm\to_tenured_collector.obj \
130 cl /EHsc $(CL_FLAGS) /MP /Fovm/ /c $<
133 cl /EHsc $(CL_FLAGS) /MP /Fovm/ /c $<
136 ml $(ML_FLAGS) /Fo$@ /c $<
141 libfactor-ffi-test.dll: vm/ffi_test.obj
142 link $(LINK_FLAGS) /out:libfactor-ffi-test.dll /dll /def:vm\ffi_test.def vm/ffi_test.obj
144 factor.dll.lib: $(DLL_OBJS)
145 link $(LINK_FLAGS) /implib:factor.dll.lib /out:factor.dll /dll $(DLL_OBJS)
147 factor.com: $(EXE_OBJS) $(DLL_OBJS)
148 link $(LINK_FLAGS) /out:factor.com /SUBSYSTEM:$(SUBSYSTEM_COM_FLAGS) $(EXE_OBJS) $(DLL_OBJS)
150 factor.exe: $(EXE_OBJS) $(DLL_OBJS)
151 link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:$(SUBSYSTEM_EXE_FLAGS) $(EXE_OBJS) $(DLL_OBJS)
153 # If we compile factor.exe, run mt.exe, and run factor.exe,
154 # then Windows caches the manifest. Even on a recompile without applying
155 # the mt.exe tool, if the factor.exe.manifest file is present, the manifest
156 # is applied. To avoid this, we delete the .manifest file on clean
157 # and copy it from a reference file on compilation and mt.exe.
159 factor.exe.manifest: factor.exe
160 copy factor.exe.manifest.in factor.exe.manifest
161 mt -manifest factor.exe.manifest -outputresource:"factor.exe;#1"
163 all: factor.com factor.exe factor.dll.lib libfactor-ffi-test.dll
168 @echo Usage: nmake /f Nmakefile platform
169 @echo Where platform is one of:
177 nmake /nologo PLATFORM=x86-32 /f Nmakefile all
180 nmake /nologo PLATFORM=x86-64 /f Nmakefile all
183 nmake /nologo PLATFORM=x86-32-vista /f Nmakefile all
186 nmake /nologo PLATFORM=x86-64-vista /f Nmakefile all
190 if exist vm\factor.res del vm\factor.res
191 if exist factor.lib del factor.lib
192 if exist factor.com del factor.com
193 if exist factor.exe del factor.exe
194 if exist factor.exe.manifest del factor.exe.manifest
195 if exist factor.exp del factor.exp
196 if exist factor.dll del factor.dll
197 if exist factor.dll.lib del factor.dll.lib
198 if exist factor.dll.exp del factor.dll.exp
199 if exist libfactor-ffi-test.dll del libfactor-ffi-test.dll
200 if exist libfactor-ffi-test.exp del libfactor-ffi-test.exp
201 if exist libfactor-ffi-test.lib del libfactor-ffi-test.lib
203 .PHONY: all default x86-32 x86-64 x86-32-vista x86-64-vista clean factor.exe.manifest