1#
2#  Makefile --
3#
4#     Top-level Makefile for building Wings 3D.
5#
6#  Coepyright (c) 2001-2011 Bjorn Gustavsson
7#
8#  See the file "license.terms" for information on usage and redistribution
9#  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10#
11
12include erl.mk
13
14# Check if OpenCL package is as external dependency
15CL_PATH = $(shell $(ERL) -noshell -eval 'erlang:display(code:which(cl))' -s erlang halt)
16ifneq (,$(findstring non_existing, $(CL_PATH)))
17DEPS=cl
18endif
19
20DEPS += libigl
21SUBDIRS=c_src intl_tools src e3d plugins_src icons
22
23#
24# Normal build targets
25#
26opt debug clean:
27	$(MAKE) TYPE=$@ common
28
29common: $(SUBDIRS) deps_result
30
31.PHONY: opt debug clean $(SUBDIRS) deps_result
32
33$(SUBDIRS):
34	$(MAKE) --directory=$@ $(TYPE)
35
36#
37# Build installer for Windows.
38#
39.PHONY: win32
40win32: opt lang
41	(cd win32; $(MAKE))
42	escript tools/release
43
44#
45# Build a package for MacOS X.
46#
47.PHONY: macosx
48macosx: opt lang
49	escript tools/release
50
51#
52# Build package for Unix.
53#
54.PHONY: unix
55unix: opt lang
56	escript tools/release
57
58#
59# Generate language files
60#
61lang: intl_tools src plugins_src
62	(cd src; $(MAKE) lang)
63	(cd plugins_src; $(MAKE) lang)
64	$(ESCRIPT) tools/verify_language_files .
65
66#
67# Build the source distribution.
68#
69
70.PHONY: .FORCE-WINGS-VERSION-FILE
71vsn.mk: .FORCE-WINGS-VERSION-FILE
72	@./WINGS-VERSION-GEN
73
74-include vsn.mk
75
76WINGS_TARNAME=wings-$(WINGS_VSN)
77.PHONY: dist
78dist:
79	git archive --format=tar \
80		--prefix=$(WINGS_TARNAME)/ HEAD^{tree} > $(WINGS_TARNAME).tar
81	@mkdir -p $(WINGS_TARNAME)
82	@echo $(WINGS_VSN) > $(WINGS_TARNAME)/version
83	tar rf $(WINGS_TARNAME).tar $(WINGS_TARNAME)/version
84	@rm -r $(WINGS_TARNAME)
85	bzip2 -f -9 $(WINGS_TARNAME).tar
86
87
88
89#
90# Build helper
91#  Makes it possible to see 'OpenCL' build problems
92deps_result: $(SUBDIRS)
93	@cat _deps/build_log 2> /dev/null || true
94
95
96# Internal dependencies
97#   Some not needed, added to disable parallel builds of erlang dirs
98#   which causes performance loss if an erlang build server is used
99c_src: $(DEPS)
100src: intl_tools e3d
101plugins_src: intl_tools src
102icons: e3d plugins_src
103lang: opt
104
105#
106#  External Dependencies
107#
108
109# do not try to pull stuff during build
110# CL_REPO = https://github.com/tonyrog/cl.git
111# IGL_REPO = https://github.com/dgud/libigl.git
112# EIGEN_REPO = https://github.com/eigenteam/eigen-git-mirror.git
113
114# CL_VER=cl-1.2.4
115# IGL_VER=master
116# EIGEN_VER=3.3.7
117# see libigl/cmake/LibiglDownloadExternal.cmake for eigen version
118
119GIT_FLAGS = -c advice.detachedHead=false clone --depth 1
120
121.PHONY: cl igl eigen
122
123# use erlang-cl from ports
124# cl (erl wrapper library) not in path try to download and build it
125# cl: _deps/cl
126# 	@(cd _deps/cl; rebar3 compile > ../build_log 2>&1 && rm ../build_log) \
127# 	  || echo ***Warning*** OpenCL not useable >> _deps/build_log
128#
129# _deps/cl:
130# 	git $(GIT_FLAGS) -b $(CL_VER) $(CL_REPO) _deps/cl
131
132# libigl have many useful function
133libigl: _deps/libigl
134
135_deps/libigl:
136	git $(GIT_FLAGS) -b $(IGL_VER) $(IGL_REPO) _deps/libigl
137
138# use eigen3 from ports
139# eigen needed by libigl
140# eigen: _deps/eigen
141#
142# _deps/eigen:
143#	git $(GIT_FLAGS) -b $(EIGEN_VER) $(EIGEN_REPO) _deps/eigen
144