blob: f298df87c40bab8fddde5ab03947abfa2e556f24 [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
43all: SampleApp bench gm tests
44
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)))
57 make -C out $@ BUILDTYPE=$(BUILDTYPE)
58endif
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)))
75 make -C out $@ BUILDTYPE=$(BUILDTYPE)
76endif
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