forked from sideeffects/HoudiniEngineForMaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
374 lines (328 loc) · 12.3 KB
/
Makefile
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# Useful targets:
# all - build the plugin for the Maya version set by MAYA_VERSION
# clean - clean up the generated files for the Maya version set by MAYA_VERSION
# all_maya - build the plugin for all the Maya versions listed in ALL_MAYA_VERSIONS
# all_maya_clean - clean up the generated files for all the Maya versions
#
# Useful variables:
# HFS - directory to the Houdini installation
# DST_MODULE_DIR - directory for the module description file
# DST_DIR - directory for the module directories (plug-ins, scripts, etc.)
# MAKETYPE - setting this variable to "Release" will generate a release build
# MAYA_VERSION - the Maya version that we're building
# ALL_MAYA_VERSIONS - a list of all the Maya versions
# detect the OS
UNAME := $(shell uname)
ifneq ($(findstring Linux, $(UNAME)),)
OS = Linux
else ifneq ($(findstring CYGWIN, $(UNAME)),)
OS = Cygwin
else ifneq ($(findstring Darwin, $(UNAME)),)
OS = Darwin
endif
# output directories
DST_MODULE_DIR = $(HFS)/engine/maya
DST_DIR = $(DST_MODULE_DIR)/maya$(MAYA_VERSION)
DST_PLUG_INS_DIR = $(DST_DIR)/plug-ins
DST_SCRIPTS_DIR = $(DST_DIR)/scripts
LIBNAME = houdiniEngine
ifeq ($(OS), Linux)
SOSUFFIX = so
else ifeq ($(OS), Cygwin)
SOSUFFIX = mll
else ifeq ($(OS), Darwin)
SOSUFFIX = bundle
endif
SONAME = $(LIBNAME).$(SOSUFFIX)
# external directories
MAYA_VERSION = 2014
ifeq ($(OS), Linux)
MAYA_DIR = /usr/autodesk/maya$(MAYA_VERSION)-x64
else ifeq ($(OS), Cygwin)
# We have to use cygpath to here because Cygwin's make doesn't handle spaces properly
MAYA_DIR := $(shell cygpath -m -s C:/Program\ Files/Autodesk/Maya$(MAYA_VERSION) 2> /dev/null)
# each versin of Maya requires a different version of Visual C++
ifeq ($(MAYA_VERSION), 2014)
# Visual C++ 2010
MSVC_SDK := $(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/SxS/VC7/10.0" 2> /dev/null)
# Windows SDK 7.0: standalone
# Windows SDK 7.0a: included in Visual Studio 2010
WIN32_SDK := $(or \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.0/InstallationFolder" 2> /dev/null), \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.0A/InstallationFolder" 2> /dev/null), \
)
else ifeq ($(MAYA_VERSION), 2013.5)
# Visual C++ 2010
MSVC_SDK := $(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/SxS/VC7/10.0" 2> /dev/null)
# Windows SDK 7.0: standalone
# Windows SDK 7.0a: included in Visual Studio 2010
WIN32_SDK := $(or \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.0/InstallationFolder" 2> /dev/null), \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.0A/InstallationFolder" 2> /dev/null), \
)
else ifeq ($(MAYA_VERSION), 2013)
# Visual C++ 2010
MSVC_SDK := $(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/SxS/VC7/10.0" 2> /dev/null)
# Windows SDK 7.0: standalone
# Windows SDK 7.0a: included in Visual Studio 2010
WIN32_SDK := $(or \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.0/InstallationFolder" 2> /dev/null), \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.0A/InstallationFolder" 2> /dev/null), \
)
else ifeq ($(MAYA_VERSION), 2012)
# Visual C++ 2008
MSVC_SDK := $(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/SxS/VC7/9.0" 2> /dev/null)
# Windows SDK 6.0: standalone
# Windows SDK 6.0a: included in Visual Studio 2008
WIN32_SDK := $(or \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v6.0/InstallationFolder" 2> /dev/null), \
$(shell cygpath -m -s -f "/proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v6.0A/InstallationFolder" 2> /dev/null), \
)
endif
# Visual C++
MSVC_SDK_BIN = $(MSVC_SDK)/bin/amd64
MSVC_SDK_INCLUDE = $(MSVC_SDK)/include
MSVC_SDK_LIB = $(MSVC_SDK)/lib/amd64
# Windows SDK
WIN32_SDK_INCLUDE = $(WIN32_SDK)/Include
WIN32_SDK_LIB = $(WIN32_SDK)/Lib/x64
else ifeq ($(OS), Darwin)
MAYA_DIR = /Applications/Autodesk/maya$(MAYA_VERSION)/Maya.app/Contents
endif
# tools
ifeq ($(OS), Linux)
CXX ?= g++
LD = $(CXX)
else ifeq ($(OS), Cygwin)
CXX = $(MSVC_SDK_BIN)/cl
LD = $(MSVC_SDK_BIN)/link
else ifeq ($(OS), Darwin)
CXX ?= g++
LD = $(CXX)
endif
# Maya flags
CPPFLAGS += -D_BOOL -DREQUIRE_IOSTREAM
ifeq ($(OS), Linux)
CPPFLAGS += -I$(MAYA_DIR)/include
LDLIBS += -L$(MAYA_DIR)/lib -lOpenMaya -lOpenMayaFX -lFoundation
else ifeq ($(OS), Cygwin)
CPPFLAGS += -I$(MAYA_DIR)/include
LDLIBS += -LIBPATH:$(MAYA_DIR)/lib OpenMaya.lib OpenMayaFX.lib Foundation.lib
else ifeq ($(OS), Darwin)
CPPFLAGS += -I$(MAYA_DIR)/../../devkit/include
LDLIBS += -L$(MAYA_DIR)/MacOS -lOpenMaya -lOpenMayaFX -lFoundation
endif
# Houdini flags
CPPFLAGS += -I$(HFS)/custom/houdini/include
CPPFLAGS += -I$(HFS)/toolkit/include
ifeq ($(OS), Linux)
LDFLAGS += -Wl,-rpath,'$$ORIGIN/../../../../dsolib'
LDLIBS += -L$(HFS)/dsolib -lHAPI
else ifeq ($(OS), Cygwin)
LDLIBS += -LIBPATH:$(HFS)/custom/houdini/dsolib libHAPI.a
else ifeq ($(OS), Darwin)
LDLIBS += -F$(HFS)/Frameworks -framework Houdini
LDLIBS += -L$(HFS)/Frameworks/Houdini.framework/Libraries
endif
# general flags
ifeq ($(OS), Linux)
CXXFLAGS += -Wall
CXXFLAGS += -m64 -pthread -pipe -fPIC
LDFLAGS += -Wl,-Bsymbolic
else ifeq ($(OS), Cygwin)
CXXFLAGS += -nologo
LDFLAGS += -nologo
# -- ENABLED WARNINGS --
# 4101: unreferenced local variable
# 4996: Deprecation usage
WARNINGENABLE = -w14101 -w14996
# -- WARNINGS TREATED AS ERRORS --
# 4265: 'class' has virtual functions but destructor is not virtual
# 4700: uninitialized local variable used
# 4715: not all control paths return a value
# 4717: recursive on all control paths, function will cause runtime stack overflow
# 4263: member func does not override any base class virt member func
# 4266: no override for virt member func from base 'type'; func is hidden
# 4390: empty controlled statement found; is this the intent?
# 4407: cast between different pointer to member representations, compiler may generate incorrect code
WARNINGERROR = -we4265 -we4700 -we4715 -we4717 -we4263 -we4266 -we4390 \
-we4407
# -- DISABLED WARNINGS --
# 4100: unreferenced formal parameter
# 4244: conversion of floating point type possible loss of data
# 4267: conversion of integer type possible loss of data
# 4389: signed/unsigned mismatch
WARNINGDISABLE = -wd4100 -wd4244 -wd4267 -wd4389
CXXFLAGS += -W4 $(WARNINGENABLE) $(WARNINGERROR) $(WARNINGDISABLE)
CXXFLAGS += -D_CRT_SECURE_NO_WARNINGS
CPPFLAGS += -I$(MSVC_SDK_INCLUDE) -I$(WIN32_SDK_INCLUDE)
CXXFLAGS += -EHsc
LDLIBS += -LIBPATH:$(MSVC_SDK_LIB) -LIBPATH:$(WIN32_SDK_LIB) -DEFAULTLIB:USER32.lib
LDFLAGS += -export:initializePlugin -export:uninitializePlugin
else ifeq ($(OS), Darwin)
CPPFLAGS += -DOSMac_ -DOSMac_MachO_
endif
# debug/release flags
ifeq ($(OS), Linux)
ifeq ($(MAKETYPE),)
CXXFLAGS += -g
else ifeq ($(MAKETYPE),Release)
CXXFLAGS += -O3
endif
else ifeq ($(OS), Cygwin)
ifeq ($(MAKETYPE),)
CXXFLAGS += -Od -MDd
else ifeq ($(MAKETYPE),Release)
CXXFLAGS += -O2 -MD
endif
else ifeq ($(OS), Darwin)
ifeq ($(MAKETYPE),)
CXXFLAGS += -g
else ifeq ($(MAKETYPE),Release)
CXXFLAGS += -O3
endif
endif
CXXFILES = \
AssetNode.C \
AssetCommand.C \
AssetSubCommand.C \
AssetSubCommandLoadAsset.C \
AssetSubCommandSync.C \
Asset.C \
Input.C \
InputAsset.C \
InputMesh.C \
InputCurve.C \
InputParticle.C \
OutputObject.C \
util.C \
OutputGeometryObject.C \
OutputInstancerObject.C \
OutputGeometry.C \
OutputGeometryPart.C \
SyncAttribute.C \
SyncOutputObject.C \
SyncOutputGeometryPart.C \
SyncOutputInstance.C \
FluidVelocityConvert.C \
plugin.C
MELFILES = AEhoudiniAssetTemplate.mel \
hapiDebugWindow.mel \
houdiniEngineCreateUI.mel \
houdiniEngineDeleteUI.mel \
houdiniEngineAssetLibraryManager.mel \
houdiniEngineUtils.mel \
houdiniEngineAssetSync.mel
OBJ_DIR = .obj/maya$(MAYA_VERSION)
OBJFILES = $(patsubst %.C, $(OBJ_DIR)/%.o, $(CXXFILES))
DEPFILES = $(patsubst %.C, $(OBJ_DIR)/%.d, $(CXXFILES))
# This module description file uses relative path to specify the module
# directory. Relative path is only supported by Maya 2013 and newer. The file
# can also be used to set environment variables.
ifneq ($(findstring $(MAYA_VERSION), 2013 2013.5 2014),)
DST_MODULE = $(DST_MODULE_DIR)/houdiniEngine-maya$(MAYA_VERSION)
endif
# This module description file uses absolute path to specify the module
# directory. The installer modifies this path at install time, so that the file
# can be copied to one of Maya's default directory. Depending on the Maya
# version, the file can also be used to set environment variables.
DST_MODULE_ABSOLUTE = $(DST_DIR)/houdiniEngine-maya$(MAYA_VERSION)
DST_PLUG_IN = $(DST_PLUG_INS_DIR)/$(SONAME)
DST_SCRIPTS = $(patsubst %, $(DST_SCRIPTS_DIR)/%, $(MELFILES))
# check build requirement
ifeq ($(OS), Linux)
CAN_BUILD := $(and \
$(realpath $(MAYA_DIR)), \
1)
else ifeq ($(OS), Cygwin)
# On Windows, we don't want to force everyone who has Maya to also build
# this plugin for now, because building Maya plugin requires a specific
# Visual C++ version, which may not be installed.
CAN_BUILD := $(and \
$(realpath $(MAYA_DIR)), \
$(realpath $(WIN32_SDK)), \
$(realpath $(MSVC_SDK)), \
1)
else ifeq ($(OS), Darwin)
CAN_BUILD := $(and \
$(realpath $(MAYA_DIR)), \
1)
endif
.PHONY: all
all:
ifeq ($(CAN_BUILD), 1)
all: $(DST_MODULE) $(DST_MODULE_ABSOLUTE) $(DST_PLUG_IN) $(DST_SCRIPTS)
endif
$(DST_MODULE):
@mkdir -p $(dir $(@))
echo "+ MAYAVERSION:$(MAYA_VERSION) houdiniEngine 1.5 maya$(MAYA_VERSION)" > $(@)
ifeq ($(OS), Cygwin)
ifneq ($(findstring $(MAYA_VERSION), 2013 2013.5 2014),)
# The module file for Maya 2013 and newer can be used to set environment variables
# Set the PATH variable for dynamic library.
echo "PATH +:= ..\\..\\..\\bin" >> $(@)
endif
endif
$(DST_MODULE_ABSOLUTE):
@mkdir -p $(dir $(@))
ifeq ($(OS), Cygwin)
echo "+ houdiniEngine 1.5 $(shell cygpath -w $(DST_DIR))" > $(@)
ifneq ($(findstring $(MAYA_VERSION), 2013 2013.5 2014),)
# The module file for Maya 2013 and newer can be used to set environment variables
# Set the PATH variable for dynamic library.
echo "PATH += $(shell cygpath -w $(DST_DIR))\\..\\..\\..\\bin" >> $(@)
endif
else
echo "+ houdiniEngine 1.5 $(DST_DIR)" > $(@)
endif
$(DST_PLUG_IN): $(OBJFILES)
@mkdir -p $(dir $(@))
ifeq ($(OS), Linux)
$(LD) -shared $(LDFLAGS) -o $(@) $(OBJFILES) $(LDLIBS)
else ifeq ($(OS), Cygwin)
$(LD) -DLL $(LDFLAGS) -OUT:$(@) $(OBJFILES) $(LDLIBS)
else ifeq ($(OS), Darwin)
$(LD) -bundle $(LDFLAGS) -o $(@) $(OBJFILES) $(LDLIBS)
endif
$(OBJ_DIR)/%.o: %.C
@mkdir -p $(dir $(@))
ifeq ($(OS), Linux)
$(CXX) -c -MMD -MP -MT $(@) $(CPPFLAGS) $(CXXFLAGS) -o $(@) $(<)
else ifeq ($(OS), Cygwin)
$(CXX) -c -showIncludes $(CPPFLAGS) $(CXXFLAGS) -Fo$(@) -Tp$(<) > $(@).log; \
compileStatus=$$?; \
cat $(@).log | ./clShowIncludesToMake $(@); \
rm -f $(@).log; \
exit $$compileStatus
else ifeq ($(OS), Darwin)
$(CXX) -c -MD -MP -MT $(@) $(CPPFLAGS) $(CXXFLAGS) -o $(@) $(<)
endif
$(DST_SCRIPTS_DIR)/%.mel: %.mel
@mkdir -p $(dir $(@))
cp $(<) $(@)
-include $(DEPFILES)
# clean
.PHONY: clean
clean:
rm -f $(DST_MODULE) $(DST_MODULE_ABSOLUTE) $(DST_PLUG_IN) $(DST_SCRIPTS)
ifeq ($(OS), Cygwin)
rm -f $(DST_PLUG_IN:%.$(SOSUFFIX)=%.lib) $(DST_PLUG_IN:%.$(SOSUFFIX)=%.exp)
endif
rm -f $(OBJFILES)
rm -f $(DEPFILES)
# build multiple Maya versions
ALL_MAYA_VERSIONS = 2014 \
2013.5 \
2013 \
2012
.PHONY: all_maya all_maya_clean
define MAYA_VERSION_template
.PHONY: maya$(1) maya$(1)_clean
all_maya: maya$(1)
maya$(1):
$$(MAKE) MAYA_VERSION=$(1)
all_maya_clean: maya$(1)_clean
maya$(1)_clean:
$$(MAKE) MAYA_VERSION=$(1) clean
endef
$(foreach maya_version, $(ALL_MAYA_VERSIONS), $(eval $(call MAYA_VERSION_template,$(maya_version))))