1# Makefile that wraps the Gyp and build steps for Unix and Mac (but not Windows)
2# Uses "ninja" to build the code.
3#
4# Some usage examples (tested on both Linux and Mac):
5#
6#   # Clean everything
7#   make clean
8#
9#   # Build and run tests (in Debug mode)
10#   make tests
11#   out/Debug/tests
12#
13#   # Build and run tests (in Release mode)
14#   make tests BUILDTYPE=Release
15#   out/Release/tests
16#
17#   # Build bench and SampleApp (both in Release mode), and then run them
18#   make SampleApp bench BUILDTYPE=Release
19#   out/Release/bench -repeat 2
20#   out/Release/SampleApp
21#
22#   # Build all targets (in Debug mode)
23#   make
24#
25# If you want more fine-grained control, you can run gyp and then build the
26# gyp-generated projects yourself.
27#
28# See https://sites.google.com/site/skiadocs/ for complete documentation.
29
30SKIA_OUT ?= out
31BUILDTYPE ?= Debug
32CWD := $(shell pwd)
33
34# Soon we should be able to get rid of VALID_TARGETS, and just pass control
35# to the gyp-generated Makefile for *any* target name.
36# But that will be a bit complicated, so let's keep it for a future CL.
37# Tracked as https://code.google.com/p/skia/issues/detail?id=947 ('eliminate
38# need for VALID_TARGETS in toplevel Makefile')
39#
40# TODO(epoger): I'm not sure if the above comment is still valid in a ninja
41# world.
42VALID_TARGETS := \
43                 bench \
44                 debugger \
45                 dm \
46                 everything \
47                 gm \
48                 most \
49                 pathops_unittest \
50                 pdfviewer \
51                 SampleApp \
52                 SampleApp_APK \
53                 skhello \
54                 skia_lib \
55                 skpskgr_test \
56                 tests \
57                 tools \
58                 skpdiff
59
60# Default target.  This must be listed before all other targets.
61.PHONY: default
62default: most
63
64# As noted in http://code.google.com/p/skia/issues/detail?id=330 , building
65# multiple targets in parallel was failing.  The special .NOTPARALLEL target
66# tells gnu make not to run targets within this Makefile in parallel.
67# Targets that ninja builds at this Makefile's behest should not be affected.
68.NOTPARALLEL:
69
70uname := $(shell uname)
71ifneq (,$(findstring CYGWIN, $(uname)))
72  $(error Cannot build using Make on Windows. See https://sites.google.com/site/skiadocs/user-documentation/quick-start-guides/windows)
73endif
74
75# If user requests "make all", chain to our explicitly-declared "everything"
76# target. See https://code.google.com/p/skia/issues/detail?id=932 ("gyp
77# automatically creates "all" target on some build flavors but not others")
78.PHONY: all
79all: everything
80
81.PHONY: clean
82clean:
83	rm -rf out xcodebuild
84ifneq (out, $(SKIA_OUT))
85	rm -rf $(SKIA_OUT)
86endif
87
88# Run gyp no matter what.
89.PHONY: gyp
90gyp:
91	$(CWD)/gyp_skia
92
93# For all specific targets: run gyp if necessary, and then pass control to
94# the gyp-generated buildfiles.
95.PHONY: $(VALID_TARGETS)
96$(VALID_TARGETS):: gyp
97	ninja -C $(SKIA_OUT)/$(BUILDTYPE) $@
98