blob: 20dc224e33c6fcadf7dc9bf4260c0923256604fc [file] [log] [blame]
Jean-Baptiste Queru80bacfe2012-12-05 14:53:50 -08001# Makefile that wraps the Gyp and build steps for Unix and Mac (but not Windows)
2# Uses "make" to build on Unix, and "xcodebuild" to build on Mac.
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 http://code.google.com/p/skia/wiki/DocRoot for complete documentation.
29
30BUILDTYPE ?= Debug
31CWD := $(shell pwd)
32ALL_TARGETS := skia_base_libs \
33 bench \
34 gm \
35 SampleApp \
36 tests \
37 tools
38
39ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
40 ALL_TARGETS += SkiaAndroidApp
41endif
42
43# Default target. This must be listed before all other targets.
44.PHONY: default
45default: $(ALL_TARGETS)
46
47# As noted in http://code.google.com/p/skia/issues/detail?id=330 , building
48# multiple targets in parallel was failing. The special .NOTPARALLEL target
49# tells gnu make not to run targets within _this_ Makefile in parallel, but the
50# recursively invoked Makefile within out/ _is_ allowed to run in parallel
51# (so you can still get some speedup that way).
52.NOTPARALLEL:
53
54uname := $(shell uname)
55ifneq (,$(findstring CYGWIN, $(uname)))
56 $(error Cannot build using Make on Windows. See http://code.google.com/p/skia/wiki/GettingStartedOnWindows)
57endif
58
59.PHONY: all
60all: $(ALL_TARGETS)
61
62.PHONY: clean
63clean:
64 rm -rf out xcodebuild
65
66# Add the debugger to the target list after the 'all' target is defined so that the
67# debugger is only executed with 'make debugger' and not 'make all' as well. The reason
68# for this is unless the user has Qt installed the debugger target will fail.
69ALL_TARGETS += debugger
70
71# Run gyp no matter what.
72.PHONY: gyp
73gyp:
74 $(CWD)/gyp_skia
75
76# Run gyp if necessary.
77#
78# On Linux, only run gyp if we haven't already generated the platform-specific
79# Makefiles. If the underlying gyp configuration has changed since these
80# Makefiles were generated, they will rerun gyp on their own.
81#
82# This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac.
83# TODO(epoger): Figure out a better solution for Mac... maybe compare the
84# gypfile timestamps to the xcodebuild project timestamps?
85.PHONY: gyp_if_needed
86gyp_if_needed:
87ifneq (,$(findstring Linux, $(uname)))
88 $(MAKE) out/Makefile
89endif
90ifneq (,$(findstring Darwin, $(uname)))
91 $(CWD)/gyp_skia
92endif
93
94out/Makefile:
95 $(CWD)/gyp_skia
96
97# For all specific targets: run gyp if necessary, and then pass control to
98# the gyp-generated buildfiles.
99#
100# For the Mac, we create a convenience symlink to the generated binary.
101.PHONY: $(ALL_TARGETS)
102$(ALL_TARGETS):: gyp_if_needed
103ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
104 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
105else ifneq (,$(findstring Linux, $(uname)))
106 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
107else ifneq (,$(findstring Darwin, $(uname)))
108 rm -f out/$(BUILDTYPE) || if test -d out/$(BUILDTYPE); then echo "run 'make clean' or otherwise delete out/$(BUILDTYPE)"; exit 1; fi
109 xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
110 ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE)
111else
112 echo "unknown platform $(uname)"
113 exit 1
114endif