blob: aa5c136823b920dc882349c45252f5332f8202e7 [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
30BUILDTYPE ?= Debug
31CWD := $(shell pwd)
epoger@google.comc9493a42011-07-27 14:06:25 +000032
epoger@google.com6714ea42012-10-25 16:32:07 +000033# Soon we should be able to get rid of VALID_TARGETS, and just pass control
34# to the gyp-generated Makefile for *any* target name.
35# But that will be a bit complicated, so let's keep it for a future CL.
36# Tracked as https://code.google.com/p/skia/issues/detail?id=947 ('eliminate
37# need for VALID_TARGETS in toplevel Makefile')
38VALID_TARGETS := \
39 bench \
40 debugger \
41 everything \
42 gm \
43 most \
44 SampleApp \
45 SkiaAndroidApp \
46 skia_base_libs \
47 tests \
48 tools
borenet@google.comdd3d08e2012-06-27 19:04:39 +000049
epoger@google.comc9493a42011-07-27 14:06:25 +000050# Default target. This must be listed before all other targets.
51.PHONY: default
epoger@google.com9c875d32012-10-18 16:10:56 +000052default: most
epoger@google.comc9493a42011-07-27 14:06:25 +000053
54# As noted in http://code.google.com/p/skia/issues/detail?id=330 , building
55# multiple targets in parallel was failing. The special .NOTPARALLEL target
56# tells gnu make not to run targets within _this_ Makefile in parallel, but the
57# recursively invoked Makefile within out/ _is_ allowed to run in parallel
58# (so you can still get some speedup that way).
59.NOTPARALLEL:
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000060
61uname := $(shell uname)
62ifneq (,$(findstring CYGWIN, $(uname)))
epoger@google.com6714ea42012-10-25 16:32:07 +000063 $(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 +000064endif
65
epoger@google.com6714ea42012-10-25 16:32:07 +000066# If user requests "make all", chain to our explicitly-declared "everything"
67# target. See https://code.google.com/p/skia/issues/detail?id=932 ("gyp
68# automatically creates "all" target on some build flavors but not others")
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000069.PHONY: all
epoger@google.com6714ea42012-10-25 16:32:07 +000070all: everything
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000071
72.PHONY: clean
73clean:
74 rm -rf out xcodebuild
75
epoger@google.comc9493a42011-07-27 14:06:25 +000076# Run gyp no matter what.
77.PHONY: gyp
78gyp:
79 $(CWD)/gyp_skia
80
81# Run gyp if necessary.
82#
83# On Linux, only run gyp if we haven't already generated the platform-specific
84# Makefiles. If the underlying gyp configuration has changed since these
85# Makefiles were generated, they will rerun gyp on their own.
86#
87# This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac.
88# TODO(epoger): Figure out a better solution for Mac... maybe compare the
89# gypfile timestamps to the xcodebuild project timestamps?
90.PHONY: gyp_if_needed
91gyp_if_needed:
92ifneq (,$(findstring Linux, $(uname)))
93 $(MAKE) out/Makefile
94endif
95ifneq (,$(findstring Darwin, $(uname)))
96 $(CWD)/gyp_skia
97endif
98
99out/Makefile:
100 $(CWD)/gyp_skia
101
102# For all specific targets: run gyp if necessary, and then pass control to
103# the gyp-generated buildfiles.
epoger@google.com5d2e4cc2011-06-22 19:17:28 +0000104#
105# For the Mac, we create a convenience symlink to the generated binary.
epoger@google.com6714ea42012-10-25 16:32:07 +0000106.PHONY: $(VALID_TARGETS)
107$(VALID_TARGETS):: gyp_if_needed
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000108ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
epoger@google.comeaacf472011-06-28 16:48:56 +0000109 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000110else ifneq (,$(findstring Linux, $(uname)))
111 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
112else ifneq (,$(findstring Darwin, $(uname)))
epoger@google.comab9b6582011-08-15 19:22:39 +0000113 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 +0000114 xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
epoger@google.comab9b6582011-08-15 19:22:39 +0000115 ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000116else
117 echo "unknown platform $(uname)"
118 exit 1
chudy@google.comb6789112012-06-29 14:34:58 +0000119endif