blob: aa54c1f6d13ce227c6195763b9c5f658dbe76857 [file] [log] [blame]
epoger@google.com5d2e4cc2011-06-22 19:17:28 +00001# 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#
epoger@google.com6714ea42012-10-25 16:32:07 +000028# See https://sites.google.com/site/skiadocs/ for complete documentation.
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000029
djsollen@google.comab5e9112012-11-28 14:11:41 +000030SKIA_OUT ?= out
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000031BUILDTYPE ?= Debug
32CWD := $(shell pwd)
epoger@google.comc9493a42011-07-27 14:06:25 +000033
epoger@google.com6714ea42012-10-25 16:32:07 +000034# 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')
39VALID_TARGETS := \
40 bench \
41 debugger \
42 everything \
43 gm \
44 most \
caryclark@google.com3e475dc2013-04-11 14:09:50 +000045 pathops_unittest \
edisonn@google.com01cd4d52013-06-10 20:44:45 +000046 pdfviewer \
epoger@google.com6714ea42012-10-25 16:32:07 +000047 SampleApp \
djsollen@google.comcc95b1a2013-08-12 12:30:04 +000048 SampleApp_APK \
borenet@google.combb522882013-06-17 15:39:43 +000049 skhello \
djsollen@google.com52f02972013-06-03 12:10:19 +000050 skia_lib \
epoger@google.com6714ea42012-10-25 16:32:07 +000051 tests \
commit-bot@chromium.orgbe19b9e2013-06-14 17:26:54 +000052 tools \
53 skpdiff
borenet@google.comdd3d08e2012-06-27 19:04:39 +000054
epoger@google.comc9493a42011-07-27 14:06:25 +000055# Default target. This must be listed before all other targets.
56.PHONY: default
epoger@google.com9c875d32012-10-18 16:10:56 +000057default: most
epoger@google.comc9493a42011-07-27 14:06:25 +000058
59# As noted in http://code.google.com/p/skia/issues/detail?id=330 , building
60# multiple targets in parallel was failing. The special .NOTPARALLEL target
61# tells gnu make not to run targets within _this_ Makefile in parallel, but the
62# recursively invoked Makefile within out/ _is_ allowed to run in parallel
63# (so you can still get some speedup that way).
64.NOTPARALLEL:
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000065
66uname := $(shell uname)
67ifneq (,$(findstring CYGWIN, $(uname)))
epoger@google.com6714ea42012-10-25 16:32:07 +000068 $(error Cannot build using Make on Windows. See https://sites.google.com/site/skiadocs/user-documentation/quick-start-guides/windows)
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000069endif
70
epoger@google.com6714ea42012-10-25 16:32:07 +000071# If user requests "make all", chain to our explicitly-declared "everything"
72# target. See https://code.google.com/p/skia/issues/detail?id=932 ("gyp
73# automatically creates "all" target on some build flavors but not others")
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000074.PHONY: all
epoger@google.com6714ea42012-10-25 16:32:07 +000075all: everything
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000076
77.PHONY: clean
78clean:
79 rm -rf out xcodebuild
djsollen@google.comab5e9112012-11-28 14:11:41 +000080ifneq (out, $(SKIA_OUT))
81 rm -rf $(SKIA_OUT)
82endif
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000083
epoger@google.comc9493a42011-07-27 14:06:25 +000084# Run gyp no matter what.
85.PHONY: gyp
86gyp:
87 $(CWD)/gyp_skia
88
89# Run gyp if necessary.
90#
91# On Linux, only run gyp if we haven't already generated the platform-specific
92# Makefiles. If the underlying gyp configuration has changed since these
93# Makefiles were generated, they will rerun gyp on their own.
94#
95# This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac.
96# TODO(epoger): Figure out a better solution for Mac... maybe compare the
97# gypfile timestamps to the xcodebuild project timestamps?
98.PHONY: gyp_if_needed
99gyp_if_needed:
100ifneq (,$(findstring Linux, $(uname)))
djsollen@google.comab5e9112012-11-28 14:11:41 +0000101 $(MAKE) $(SKIA_OUT)/Makefile
epoger@google.comc9493a42011-07-27 14:06:25 +0000102endif
103ifneq (,$(findstring Darwin, $(uname)))
104 $(CWD)/gyp_skia
105endif
106
djsollen@google.comab5e9112012-11-28 14:11:41 +0000107$(SKIA_OUT)/Makefile:
epoger@google.comc9493a42011-07-27 14:06:25 +0000108 $(CWD)/gyp_skia
109
110# For all specific targets: run gyp if necessary, and then pass control to
111# the gyp-generated buildfiles.
epoger@google.com5d2e4cc2011-06-22 19:17:28 +0000112#
113# For the Mac, we create a convenience symlink to the generated binary.
epoger@google.com6714ea42012-10-25 16:32:07 +0000114.PHONY: $(VALID_TARGETS)
115$(VALID_TARGETS):: gyp_if_needed
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000116ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
djsollen@google.comab5e9112012-11-28 14:11:41 +0000117 $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000118else ifneq (,$(findstring Linux, $(uname)))
djsollen@google.comab5e9112012-11-28 14:11:41 +0000119 $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE)
120else ifneq (,$(findstring make, $(GYP_GENERATORS)))
121 $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000122else ifneq (,$(findstring Darwin, $(uname)))
epoger@google.comab9b6582011-08-15 19:22:39 +0000123 rm -f out/$(BUILDTYPE) || if test -d out/$(BUILDTYPE); then echo "run 'make clean' or otherwise delete out/$(BUILDTYPE)"; exit 1; fi
epoger@google.com5d2e4cc2011-06-22 19:17:28 +0000124 xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
epoger@google.comab9b6582011-08-15 19:22:39 +0000125 ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000126else
127 echo "unknown platform $(uname)"
128 exit 1
chudy@google.comb6789112012-06-29 14:34:58 +0000129endif