blob: aa144100bae46e8ae0094efb37311dd98e500c9b [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)
borenet@google.comefb1d772012-10-10 19:45:51 +000032ALL_TARGETS := skia_base_libs \
33 bench \
34 gm \
35 SampleApp \
36 tests \
37 tools
epoger@google.comc9493a42011-07-27 14:06:25 +000038
borenet@google.comdd3d08e2012-06-27 19:04:39 +000039ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
borenet@google.com7ef39292012-07-18 14:59:54 +000040ifeq (,$(findstring android_make_apk=0, $(GYP_DEFINES)))
borenet@google.comdd3d08e2012-06-27 19:04:39 +000041 ALL_TARGETS += SkiaAndroidApp
42endif
borenet@google.com7ef39292012-07-18 14:59:54 +000043endif
borenet@google.comdd3d08e2012-06-27 19:04:39 +000044
epoger@google.comc9493a42011-07-27 14:06:25 +000045# Default target. This must be listed before all other targets.
46.PHONY: default
djsollen@google.com686989b2012-06-29 18:51:29 +000047default: $(ALL_TARGETS)
epoger@google.comc9493a42011-07-27 14:06:25 +000048
49# As noted in http://code.google.com/p/skia/issues/detail?id=330 , building
50# multiple targets in parallel was failing. The special .NOTPARALLEL target
51# tells gnu make not to run targets within _this_ Makefile in parallel, but the
52# recursively invoked Makefile within out/ _is_ allowed to run in parallel
53# (so you can still get some speedup that way).
54.NOTPARALLEL:
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000055
56uname := $(shell uname)
57ifneq (,$(findstring CYGWIN, $(uname)))
58 $(error Cannot build using Make on Windows. See http://code.google.com/p/skia/wiki/GettingStartedOnWindows)
59endif
60
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000061.PHONY: all
epoger@google.comc9493a42011-07-27 14:06:25 +000062all: $(ALL_TARGETS)
epoger@google.com5d2e4cc2011-06-22 19:17:28 +000063
64.PHONY: clean
65clean:
66 rm -rf out xcodebuild
67
djsollen@google.com686989b2012-06-29 18:51:29 +000068# Add the debugger to the target list after the 'all' target is defined so that the
69# debugger is only executed with 'make debugger' and not 'make all' as well. The reason
70# for this is unless the user has Qt installed the debugger target will fail.
71ALL_TARGETS += debugger
72
epoger@google.comc9493a42011-07-27 14:06:25 +000073# Run gyp no matter what.
74.PHONY: gyp
75gyp:
76 $(CWD)/gyp_skia
77
78# Run gyp if necessary.
79#
80# On Linux, only run gyp if we haven't already generated the platform-specific
81# Makefiles. If the underlying gyp configuration has changed since these
82# Makefiles were generated, they will rerun gyp on their own.
83#
84# This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac.
85# TODO(epoger): Figure out a better solution for Mac... maybe compare the
86# gypfile timestamps to the xcodebuild project timestamps?
87.PHONY: gyp_if_needed
88gyp_if_needed:
89ifneq (,$(findstring Linux, $(uname)))
90 $(MAKE) out/Makefile
91endif
92ifneq (,$(findstring Darwin, $(uname)))
93 $(CWD)/gyp_skia
94endif
95
96out/Makefile:
97 $(CWD)/gyp_skia
98
99# For all specific targets: run gyp if necessary, and then pass control to
100# the gyp-generated buildfiles.
epoger@google.com5d2e4cc2011-06-22 19:17:28 +0000101#
102# For the Mac, we create a convenience symlink to the generated binary.
epoger@google.comc9493a42011-07-27 14:06:25 +0000103.PHONY: $(ALL_TARGETS)
104$(ALL_TARGETS):: gyp_if_needed
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000105ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
epoger@google.comeaacf472011-06-28 16:48:56 +0000106 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000107else ifneq (,$(findstring Linux, $(uname)))
108 $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
109else ifneq (,$(findstring Darwin, $(uname)))
epoger@google.comab9b6582011-08-15 19:22:39 +0000110 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 +0000111 xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
epoger@google.comab9b6582011-08-15 19:22:39 +0000112 ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE)
borenet@google.comb52cf3d2012-06-05 17:57:48 +0000113else
114 echo "unknown platform $(uname)"
115 exit 1
chudy@google.comb6789112012-06-29 14:34:58 +0000116endif