[offsets-tool] Make sure to re-clone when the hash for the cpp binaries changes.
[mono.git] / tools / offsets-tool / Makefile
1 CPPSHARP_BASE_DIR = CppSharp
2
3 ifeq ($(OS),Windows_NT)
4         CPPSHARP_OS=windows
5         ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
6                 CPPSHARP_ARCH=64
7         else
8                 ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
9                         CPPSHARP_ARCH=64
10                 endif
11                 ifeq ($(PROCESSOR_ARCHITECTURE),x86)
12                         CPPSHARP_ARCH=32
13                 endif
14         endif
15 else
16         UNAME_S := $(shell uname -s)
17         ifeq ($(UNAME_S),Linux)
18                 CPPSHARP_OS=linux
19                 CPPSHARP_ARCH=64
20         endif
21         ifeq ($(UNAME_S),Darwin)
22                 CPPSHARP_OS=osx
23                 CPPSHARP_ARCH=32
24         endif
25 endif
26
27 CPPSHARP_DIR = $(CPPSHARP_BASE_DIR)/$(CPPSHARP_OS)_$(CPPSHARP_ARCH)
28
29 CPPSHARP_REFS = -r:$(CPPSHARP_DIR)/CppSharp.dll \
30         -r:$(CPPSHARP_DIR)/CppSharp.AST.dll \
31         -r:$(CPPSHARP_DIR)/CppSharp.Parser.dll \
32         -r:$(CPPSHARP_DIR)/CppSharp.Parser.CSharp.dll \
33         -r:$(CPPSHARP_DIR)/CppSharp.Generator.dll
34
35 SRC_ROOT = ../..
36
37 MONO_OPTIONS_SRC = $(SRC_ROOT)/mcs/class/Mono.Options/Mono.Options/Options.cs
38
39 HASH=60f763a9
40 .stamp-clone-$(HASH):
41         rm -Rf $(CPPSHARP_BASE_DIR)
42         git clone -b $(HASH) --depth 1 git://github.com/xamarin/CppSharpBinaries.git $(CPPSHARP_BASE_DIR) && touch $@
43
44 MonoAotOffsetsDumper.exe: .stamp-clone-$(HASH) MonoAotOffsetsDumper.cs $(MONO_OPTIONS_SRC)
45         mcs MonoAotOffsetsDumper.cs /debug /nowarn:0436 $(MONO_OPTIONS_SRC) $(CPPSHARP_REFS)
46
47 .PHONY: clean
48 clean:
49         rm MonoAotOffsetsDumper.exe
50
51 dump: MonoAotOffsetsDumper.exe 
52         MONO_PATH=$(CPPSHARP_DIR) mono MonoAotOffsetsDumper.exe
53
54 update:
55         @if [ -f object-offsets.h ]; then rm object-offsets.h; fi;
56         @for f in *.h; do \
57                 echo "Processing $$f.."; \
58                 echo "#include \"$$f\"" >> object-offsets1.h; \
59         done
60         @cp *.h ../mono/metadata
61
62 gen-proj:
63         $(CPPSHARP_DIR)/premake5 vs2012
64
65 all: MonoAotOffsetsDumper.exe