-
Notifications
You must be signed in to change notification settings - Fork 276
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (133 loc) · 5.81 KB
/
Makefile
File metadata and controls
156 lines (133 loc) · 5.81 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
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
# Makefile for building MechJeb
ifeq ($(OS),Windows_NT)
# do 'Doze stuff
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
ifndef XDG_DATA_HOME
XDG_DATA_HOME := ${HOME}/.local/share
endif
ifndef KSPDIR
KSPDIR := ${XDG_DATA_HOME}/Steam/SteamApps/common/Kerbal Space Program
endif
MANAGED := ${KSPDIR}/KSP_Data/Managed/
endif
ifeq ($(UNAME_S),Darwin)
ifndef KSPDIR
KSPDIR := ${HOME}/Library/Application Support/Steam/steamapps/common/Kerbal Space Program
endif
ifndef MANAGED
MANAGED := ${KSPDIR}/KSP.app/Contents/Resources/Data/Managed/
endif
endif
endif
MECHJEBFILES := $(shell find MechJeb2 -name "*.cs")
MECHJABLIBFILES := $(shell find MechJebLib -name "*.cs")
MECHJABLIBIBINDINGSFILES := $(shell find MechJebLibBindings -name "*.cs")
ALGLIBFILES := $(shell find alglib -name "*.cs")
RESGEN2 := resgen2
CSC := csc
GIT := git
TAR := tar
ZIP := zip
VERSION := $(shell ${GIT} describe --tags --always)
all: build
info:
@echo "== MechJeb2 Build Information =="
@echo " resgen2: ${RESGEN2}"
@echo " csc: ${CSC}"
@echo " git: ${GIT}"
@echo " tar: ${TAR}"
@echo " zip: ${ZIP}"
@echo " KSP Data: ${KSPDIR}"
@echo "================================"
build: build/MechJeb2.dll build/MechJebLib.dll build/MechJebLibBindings.dll build/alglib.dll
# Build alglib first (no dependencies beyond system)
build/alglib.dll: ${ALGLIBFILES}
mkdir -p build
${CSC} /noconfig /target:library /checked- /nowarn:1701,1702,2008 /langversion:9.0 /nostdlib+ /platform:AnyCPU /warn:4 /errorendlocation /highentropyva- /optimize+ /debug- /filealign:512 \
/reference:"${MANAGED}/mscorlib.dll" \
/reference:"${MANAGED}/System.Core.dll" \
/reference:"${MANAGED}/System.dll" \
/reference:"${MANAGED}/System.Xml.dll" \
/recurse:"alglib/*.cs" \
-out:$@
# Build MechJebLib (depends on alglib and JetBrains.Annotations)
build/MechJebLib.dll: ${MECHJABLIBFILES} build/alglib.dll
mkdir -p build
${CSC} /noconfig /target:library /checked- /nowarn:1701,1702,2008 /langversion:9.0 /nostdlib+ /platform:AnyCPU /warn:4 /errorendlocation /highentropyva- /optimize+ /debug- /filealign:512 \
/reference:"${MANAGED}/mscorlib.dll" \
/reference:"${MANAGED}/System.Core.dll" \
/reference:"${MANAGED}/System.dll" \
/reference:"build/alglib.dll" \
/reference:"packages/JetBrains.Annotations.2023.3.0/lib/net20/JetBrains.Annotations.dll" \
/recurse:"MechJebLib/*.cs" \
-out:$@
# Build MechJebLibBindings (depends on MechJebLib and KSP assemblies)
build/MechJebLibBindings.dll: ${MECHJABLIBIBINDINGSFILES} build/MechJebLib.dll
mkdir -p build
${CSC} /noconfig /target:library /checked- /nowarn:1701,1702,2008 /langversion:9.0 /nostdlib+ /platform:AnyCPU /warn:4 /errorendlocation /highentropyva- /optimize+ /debug- /filealign:512 \
/reference:"${MANAGED}/Assembly-CSharp.dll" \
/reference:"${MANAGED}/Assembly-CSharp-firstpass.dll" \
/reference:"${MANAGED}/mscorlib.dll" \
/reference:"${MANAGED}/System.Core.dll" \
/reference:"${MANAGED}/System.dll" \
/reference:"${MANAGED}/UnityEngine.CoreModule.dll" \
/reference:"build/MechJebLib.dll" \
/recurse:"MechJebLibBindings/*.cs" \
-out:$@
# Build main MechJeb2 assembly (depends on everything)
build/MechJeb2.dll: ${MECHJEBFILES} build/MechJebLib.dll build/MechJebLibBindings.dll build/alglib.dll
mkdir -p build
${RESGEN2} -usesourcepath MechJeb2/Properties/Resources.resx build/Resources.resources
${CSC} /noconfig /target:library /checked- /nowarn:1701,1702,2008 /langversion:9.0 /nostdlib+ /platform:AnyCPU /warn:4 /errorendlocation /highentropyva- /optimize+ /debug- /filealign:512 \
/reference:"${MANAGED}/Assembly-CSharp.dll" \
/reference:"${MANAGED}/Assembly-CSharp-firstpass.dll" \
/reference:"${MANAGED}/mscorlib.dll" \
/reference:"${MANAGED}/System.Core.dll" \
/reference:"${MANAGED}/System.dll" \
/reference:"${MANAGED}/UnityEngine.AnimationModule.dll" \
/reference:"${MANAGED}/UnityEngine.AssetBundleModule.dll" \
/reference:"${MANAGED}/UnityEngine.CoreModule.dll" \
/reference:"${MANAGED}/UnityEngine.IMGUIModule.dll" \
/reference:"${MANAGED}/UnityEngine.InputLegacyModule.dll" \
/reference:"${MANAGED}/UnityEngine.PhysicsModule.dll" \
/reference:"${MANAGED}/UnityEngine.TextRenderingModule.dll" \
/reference:"${MANAGED}/UnityEngine.UI.dll" \
/reference:"${MANAGED}/UnityEngine.VehiclesModule.dll" \
/reference:"build/MechJebLib.dll" \
/reference:"build/MechJebLibBindings.dll" \
/reference:"build/alglib.dll" \
/reference:JetBrainsAnnotations="packages/JetBrains.Annotations.2023.3.0/lib/net20/JetBrains.Annotations.dll" \
/recurse:"MechJeb2/*.cs" \
-out:$@ \
-resource:build/Resources.resources,MuMech.Properties.Resources.resources
package: build ${MECHJEBFILES}
mkdir -p package/MechJeb2/Plugins
cp -r Parts package/MechJeb2/
cp -r Icons package/MechJeb2/
cp -r Bundles package/MechJeb2/
cp -r Localization package/MechJeb2/
cp build/MechJeb2.dll build/MechJebLib.dll build/MechJebLibBindings.dll build/alglib.dll package/MechJeb2/Plugins/
cp LICENSE.md README.md package/MechJeb2/
%.tar.gz:
${TAR} zcf $@ package/MechJeb2
tar.gz: package MechJeb-${VERSION}.tar.gz
%.zip:
${ZIP} -9 -r $@ package/MechJeb2
zip: package MechJeb-${VERSION}.zip
clean:
@echo "Cleaning up build and package directories..."
rm -rf build/ package/
install: build
mkdir -p "${KSPDIR}"/GameData/MechJeb2/Plugins
cp -r Parts "${KSPDIR}"/GameData/MechJeb2/
cp -r Icons "${KSPDIR}"/GameData/MechJeb2/
cp -r Bundles "${KSPDIR}"/GameData/MechJeb2/
cp -r Localization "${KSPDIR}"/GameData/MechJeb2/
cp build/MechJeb2.dll build/MechJebLib.dll build/MechJebLibBindings.dll build/alglib.dll "${KSPDIR}"/GameData/MechJeb2/Plugins/
uninstall: info
rm -rf "${KSPDIR}"/GameData/MechJeb2/Plugins
rm -rf "${KSPDIR}"/GameData/MechJeb2/Parts
rm -rf "${KSPDIR}"/GameData/MechJeb2/Icons
.PHONY : all info build package tar.gz zip clean install uninstall