-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (39 loc) · 1.61 KB
/
Copy pathMakefile
File metadata and controls
61 lines (39 loc) · 1.61 KB
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
topdir=../..
abstopdir=$(realpath ../..)
include $(topdir)/os-detect.mk
outdir=$(topdir)/out/native
absoutdir=$(abstopdir)/out/native
CFLAGS=-std=c99 -g
runtime_pack_dir_file?=$(topdir)/out/GetRuntimePack/bin/Release/$(TARGET_FRAMEWORK)/$(RUNTIME_IDENTIFIER)/runtime-pack-dir.txt
runtime_dir=$(shell cat $(runtime_pack_dir_file))/runtimes/$(RUNTIME_IDENTIFIER)/native
CSHARP_SAMPLE_PUBLISH_DIR:=$(topdir)/out/CsharpSample/bin/Release/$(TARGET_FRAMEWORK)/$(RUNTIME_IDENTIFIER)/publish
MONO_INCLUDE_DIR:=$(topdir)/vendor/mono-headers/include/mono-2.0
SOURCES:= \
main.c
CORELIB_FULL_PATH:=$(absoutdir)/System.Private.CoreLib.dll
TOUCH_COPY_LIBS:=$(outdir)/.touch-copylibs
GENERATED_DIR=$(outdir)/generated
GEN_TPA_H=$(GENERATED_DIR)/tpa.h
ifeq ($(SYSTEM),osx)
INSTALL_NAME_TOOL_CMD:=install_name_tool -add_rpath @executable_path/
PATCHELF_CMD:=-true
else ifeq ($(SYSTEM),linux)
INSTALL_NAME_TOOL_CMD:=-true
PATCHELF_CMD:=cd $(outdir) && patchelf --set-soname libcoreclr$(SOEXT) libcoreclr$(SOEXT)
endif
.PHONY: all
all: $(outdir)/main
$(outdir):
mkdir -p $@
$(outdir)/main: $(SOURCES) $(TOUCH_COPY_LIBS) $(GEN_TPA_H) | $(outdir)
$(CC) $(CFLAGS) -o $@ $(SOURCES) -DCORELIB_FULL_PATH=\"$(CORELIB_FULL_PATH)\" -L$(outdir) -lcoreclr -I$(GENERATED_DIR) -I$(MONO_INCLUDE_DIR)
$(INSTALL_NAME_TOOL_CMD) $@
$(TOUCH_COPY_LIBS): $(runtime_pack_dir_file) | $(outdir)
cp $(runtime_dir)/*$(SOEXT) $(outdir)
cp $(runtime_dir)/System.Private.CoreLib.dll $(outdir)
$(PATCHELF_CMD)
touch $@
$(GENERATED_DIR):
mkdir -p $@
$(GEN_TPA_H): $(outdir)/../.touch-CsharpSample | $(GENERATED_DIR)
./gen-managed.sh $(CSHARP_SAMPLE_PUBLISH_DIR) > $@