blob: e4e9a105056eb66dad6d17b4f0d8d308b07dbc21 [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#
28# See http://code.google.com/p/skia/wiki/DocRoot for complete documentation.
29
30BUILDTYPE ?= Debug
31CWD := $(shell pwd)
32
33uname := $(shell uname)
34ifneq (,$(findstring CYGWIN, $(uname)))
35 $(error Cannot build using Make on Windows. See http://code.google.com/p/skia/wiki/GettingStartedOnWindows)
36endif
37
38# Default target. This must be listed before all other targets.
39.PHONY: default
40default: all
41
42.PHONY: all
epoger@google.com02362942011-06-23 19:24:28 +000043all: SampleApp bench gm tests tools
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000044
45.PHONY: clean
46clean:
47 rm -rf out xcodebuild
48
49# Any targets not defined above...
50# Ask gyp to generate the buildfiles as appropriate for this platform,
51# and then pass control to those buildfiles.
52#
53# For the Mac, we create a convenience symlink to the generated binary.
54%:
55 ./gyp_skia
56ifneq (,$(findstring Linux, $(uname)))
epoger@google.comeaacf472011-06-28 16:48:56 +000057 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000058endif
59ifneq (,$(findstring Darwin, $(uname)))
60 xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
61 mkdir -p out/$(BUILDTYPE)
62 rm -f out/$(BUILDTYPE)/$@
63 ln -s $(CWD)/xcodebuild/$(BUILDTYPE)/$@.app/Contents/MacOS/$@ out/$(BUILDTYPE)/$@
64endif
65
66# This repetition is ugly, but necessary.
67# If there are any files/directories within the same directory as this Makefile
68# which share the same name as a target ("tests", for example), then make
69# will refuse to rebuild those targets because the file already exists.
70local_filenames := $(shell ls)
71.PHONY: $(local_filenames)
72$(local_filenames)::
73 ./gyp_skia
74ifneq (,$(findstring Linux, $(uname)))
epoger@google.comeaacf472011-06-28 16:48:56 +000075 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000076endif
77ifneq (,$(findstring Darwin, $(uname)))
78 xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
79 mkdir -p out/$(BUILDTYPE)
80 rm -f out/$(BUILDTYPE)/$@
81 ln -s $(CWD)/xcodebuild/$(BUILDTYPE)/$@.app/Contents/MacOS/$@ out/$(BUILDTYPE)/$@
82endif