Makefile 4.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# Makefile that wraps the Gyp and build steps for Unix and Mac (but not Windows)
# Uses "make" to build on Unix, and "xcodebuild" to build on Mac.
#
# Some usage examples (tested on both Linux and Mac):
#
#   # Clean everything
#   make clean
#
#   # Build and run tests (in Debug mode)
#   make tests
#   out/Debug/tests
#
#   # Build and run tests (in Release mode)
#   make tests BUILDTYPE=Release
#   out/Release/tests
#
#   # Build bench and SampleApp (both in Release mode), and then run them
#   make SampleApp bench BUILDTYPE=Release
#   out/Release/bench -repeat 2
#   out/Release/SampleApp
#
#   # Build all targets (in Debug mode)
#   make
#
# If you want more fine-grained control, you can run gyp and then build the
# gyp-generated projects yourself.
#
28
# See https://sites.google.com/site/skiadocs/ for complete documentation.
29

30
SKIA_OUT ?= out
31 32
BUILDTYPE ?= Debug
CWD := $(shell pwd)
33

34 35 36 37 38 39 40 41 42 43 44
# Soon we should be able to get rid of VALID_TARGETS, and just pass control
# to the gyp-generated Makefile for *any* target name.
# But that will be a bit complicated, so let's keep it for a future CL.
# Tracked as https://code.google.com/p/skia/issues/detail?id=947 ('eliminate
# need for VALID_TARGETS in toplevel Makefile')
VALID_TARGETS := \
                 bench \
                 debugger \
                 everything \
                 gm \
                 most \
45
                 pathops_unittest \
46
                 pdfviewer \
47
                 SampleApp \
borenet@google.com's avatar
borenet@google.com committed
48
                 skhello \
49
                 SkiaAndroidApp \
50
                 skia_lib \
51
                 tests \
52 53
                 tools \
                 skpdiff
54

55 56
# Default target.  This must be listed before all other targets.
.PHONY: default
57
default: most
58 59 60 61 62 63 64

# As noted in http://code.google.com/p/skia/issues/detail?id=330 , building
# multiple targets in parallel was failing.  The special .NOTPARALLEL target
# tells gnu make not to run targets within _this_ Makefile in parallel, but the
# recursively invoked Makefile within out/ _is_ allowed to run in parallel
# (so you can still get some speedup that way).
.NOTPARALLEL:
65 66 67

uname := $(shell uname)
ifneq (,$(findstring CYGWIN, $(uname)))
68
  $(error Cannot build using Make on Windows. See https://sites.google.com/site/skiadocs/user-documentation/quick-start-guides/windows)
69 70
endif

71 72 73
# If user requests "make all", chain to our explicitly-declared "everything"
# target. See https://code.google.com/p/skia/issues/detail?id=932 ("gyp
# automatically creates "all" target on some build flavors but not others")
74
.PHONY: all
75
all: everything
76 77 78 79

.PHONY: clean
clean:
	rm -rf out xcodebuild
80 81 82
ifneq (out, $(SKIA_OUT))
	rm -rf $(SKIA_OUT)
endif
83

84 85 86
# Run gyp no matter what.
.PHONY: gyp
gyp:
87
	$(CWD)/gyp_skia
88 89 90 91 92 93 94 95 96 97 98 99

# Run gyp if necessary.
#
# On Linux, only run gyp if we haven't already generated the platform-specific
# Makefiles.  If the underlying gyp configuration has changed since these
# Makefiles were generated, they will rerun gyp on their own.
#
# This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac.
# TODO(epoger): Figure out a better solution for Mac... maybe compare the
# gypfile timestamps to the xcodebuild project timestamps?
.PHONY: gyp_if_needed
gyp_if_needed:
100
ifneq (,$(findstring Linux, $(uname)))
101
	$(MAKE) $(SKIA_OUT)/Makefile
102 103
endif
ifneq (,$(findstring Darwin, $(uname)))
104
	$(CWD)/gyp_skia
105 106
endif

107
$(SKIA_OUT)/Makefile:
108
	$(CWD)/gyp_skia
109 110 111 112 113

# For all specific targets: run gyp if necessary, and then pass control to
# the gyp-generated buildfiles.
#
# For the Mac, we create a convenience symlink to the generated binary.
114 115
.PHONY: $(VALID_TARGETS)
$(VALID_TARGETS):: gyp_if_needed
116
ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
117
	$(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE)
118
else ifneq (,$(findstring Linux, $(uname)))
119 120 121
	$(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE)
else ifneq (,$(findstring make, $(GYP_GENERATORS)))
	$(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE)
122
else ifneq (,$(findstring Darwin, $(uname)))
123
	rm -f out/$(BUILDTYPE) || if test -d out/$(BUILDTYPE); then echo "run 'make clean' or otherwise delete out/$(BUILDTYPE)"; exit 1; fi
124
	xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
125
	ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE)
126 127 128
else
	echo "unknown platform $(uname)"
	exit 1
129
endif