Makefile 3.55 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 28 29 30 31
# 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.
#
# See http://code.google.com/p/skia/wiki/DocRoot for complete documentation.

BUILDTYPE ?= Debug
CWD := $(shell pwd)
32 33 34
ALL_TARGETS := skia_base_libs \
               bench \
               gm \
35
               most \
36 37 38
               SampleApp \
               tests \
               tools
39

40 41 42 43
ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
  ALL_TARGETS += SkiaAndroidApp
endif

44 45
# Default target.  This must be listed before all other targets.
.PHONY: default
46
default: most
47 48 49 50 51 52 53

# 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:
54 55 56 57 58 59 60

uname := $(shell uname)
ifneq (,$(findstring CYGWIN, $(uname)))
  $(error Cannot build using Make on Windows. See http://code.google.com/p/skia/wiki/GettingStartedOnWindows)
endif

.PHONY: all
61
all: $(ALL_TARGETS)
62 63 64 65 66

.PHONY: clean
clean:
	rm -rf out xcodebuild

67 68 69 70 71
# Add the debugger to the target list after the 'all' target is defined so that the
# debugger is only executed with 'make debugger' and not 'make all' as well. The reason
# for this is unless the user has Qt installed the debugger target will fail.
ALL_TARGETS += debugger

72 73 74
# Run gyp no matter what.
.PHONY: gyp
gyp:
75
	$(CWD)/gyp_skia
76 77 78 79 80 81 82 83 84 85 86 87

# 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:
88
ifneq (,$(findstring Linux, $(uname)))
89
	$(MAKE) out/Makefile
90 91
endif
ifneq (,$(findstring Darwin, $(uname)))
92
	$(CWD)/gyp_skia
93 94
endif

95
out/Makefile:
96
	$(CWD)/gyp_skia
97 98 99 100 101 102 103

# 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.
.PHONY: $(ALL_TARGETS)
$(ALL_TARGETS):: gyp_if_needed
104
ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
105
	$(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
106 107 108
else ifneq (,$(findstring Linux, $(uname)))
	$(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE)
else ifneq (,$(findstring Darwin, $(uname)))
109
	rm -f out/$(BUILDTYPE) || if test -d out/$(BUILDTYPE); then echo "run 'make clean' or otherwise delete out/$(BUILDTYPE)"; exit 1; fi
110
	xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE)
111
	ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE)
112 113 114
else
	echo "unknown platform $(uname)"
	exit 1
115
endif