epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 1 | # 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 | # |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 28 | # See https://sites.google.com/site/skiadocs/ for complete documentation. |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 29 | |
djsollen@google.com | ab5e911 | 2012-11-28 14:11:41 +0000 | [diff] [blame] | 30 | SKIA_OUT ?= out |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 31 | BUILDTYPE ?= Debug |
| 32 | CWD := $(shell pwd) |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 33 | |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 34 | # Soon we should be able to get rid of VALID_TARGETS, and just pass control |
| 35 | # to the gyp-generated Makefile for *any* target name. |
| 36 | # But that will be a bit complicated, so let's keep it for a future CL. |
| 37 | # Tracked as https://code.google.com/p/skia/issues/detail?id=947 ('eliminate |
| 38 | # need for VALID_TARGETS in toplevel Makefile') |
| 39 | VALID_TARGETS := \ |
| 40 | bench \ |
| 41 | debugger \ |
| 42 | everything \ |
| 43 | gm \ |
| 44 | most \ |
caryclark@google.com | 3e475dc | 2013-04-11 14:09:50 +0000 | [diff] [blame] | 45 | pathops_unittest \ |
edisonn@google.com | 01cd4d5 | 2013-06-10 20:44:45 +0000 | [diff] [blame] | 46 | pdfviewer \ |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 47 | SampleApp \ |
| 48 | SkiaAndroidApp \ |
djsollen@google.com | 52f0297 | 2013-06-03 12:10:19 +0000 | [diff] [blame] | 49 | skia_lib \ |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 50 | tests \ |
| 51 | tools |
borenet@google.com | dd3d08e | 2012-06-27 19:04:39 +0000 | [diff] [blame] | 52 | |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 53 | # Default target. This must be listed before all other targets. |
| 54 | .PHONY: default |
epoger@google.com | 9c875d3 | 2012-10-18 16:10:56 +0000 | [diff] [blame] | 55 | default: most |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 56 | |
| 57 | # As noted in http://code.google.com/p/skia/issues/detail?id=330 , building |
| 58 | # multiple targets in parallel was failing. The special .NOTPARALLEL target |
| 59 | # tells gnu make not to run targets within _this_ Makefile in parallel, but the |
| 60 | # recursively invoked Makefile within out/ _is_ allowed to run in parallel |
| 61 | # (so you can still get some speedup that way). |
| 62 | .NOTPARALLEL: |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 63 | |
| 64 | uname := $(shell uname) |
| 65 | ifneq (,$(findstring CYGWIN, $(uname))) |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 66 | $(error Cannot build using Make on Windows. See https://sites.google.com/site/skiadocs/user-documentation/quick-start-guides/windows) |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 67 | endif |
| 68 | |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 69 | # If user requests "make all", chain to our explicitly-declared "everything" |
| 70 | # target. See https://code.google.com/p/skia/issues/detail?id=932 ("gyp |
| 71 | # automatically creates "all" target on some build flavors but not others") |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 72 | .PHONY: all |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 73 | all: everything |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 74 | |
| 75 | .PHONY: clean |
| 76 | clean: |
| 77 | rm -rf out xcodebuild |
djsollen@google.com | ab5e911 | 2012-11-28 14:11:41 +0000 | [diff] [blame] | 78 | ifneq (out, $(SKIA_OUT)) |
| 79 | rm -rf $(SKIA_OUT) |
| 80 | endif |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 81 | |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 82 | # Run gyp no matter what. |
| 83 | .PHONY: gyp |
| 84 | gyp: |
| 85 | $(CWD)/gyp_skia |
| 86 | |
| 87 | # Run gyp if necessary. |
| 88 | # |
| 89 | # On Linux, only run gyp if we haven't already generated the platform-specific |
| 90 | # Makefiles. If the underlying gyp configuration has changed since these |
| 91 | # Makefiles were generated, they will rerun gyp on their own. |
| 92 | # |
| 93 | # This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac. |
| 94 | # TODO(epoger): Figure out a better solution for Mac... maybe compare the |
| 95 | # gypfile timestamps to the xcodebuild project timestamps? |
| 96 | .PHONY: gyp_if_needed |
| 97 | gyp_if_needed: |
| 98 | ifneq (,$(findstring Linux, $(uname))) |
djsollen@google.com | ab5e911 | 2012-11-28 14:11:41 +0000 | [diff] [blame] | 99 | $(MAKE) $(SKIA_OUT)/Makefile |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 100 | endif |
| 101 | ifneq (,$(findstring Darwin, $(uname))) |
| 102 | $(CWD)/gyp_skia |
| 103 | endif |
| 104 | |
djsollen@google.com | ab5e911 | 2012-11-28 14:11:41 +0000 | [diff] [blame] | 105 | $(SKIA_OUT)/Makefile: |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 106 | $(CWD)/gyp_skia |
| 107 | |
| 108 | # For all specific targets: run gyp if necessary, and then pass control to |
| 109 | # the gyp-generated buildfiles. |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 110 | # |
| 111 | # For the Mac, we create a convenience symlink to the generated binary. |
epoger@google.com | 6714ea4 | 2012-10-25 16:32:07 +0000 | [diff] [blame] | 112 | .PHONY: $(VALID_TARGETS) |
| 113 | $(VALID_TARGETS):: gyp_if_needed |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 114 | ifneq (,$(findstring skia_os=android, $(GYP_DEFINES))) |
djsollen@google.com | ab5e911 | 2012-11-28 14:11:41 +0000 | [diff] [blame] | 115 | $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE) |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 116 | else ifneq (,$(findstring Linux, $(uname))) |
djsollen@google.com | ab5e911 | 2012-11-28 14:11:41 +0000 | [diff] [blame] | 117 | $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE) |
| 118 | else ifneq (,$(findstring make, $(GYP_GENERATORS))) |
| 119 | $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE) |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 120 | else ifneq (,$(findstring Darwin, $(uname))) |
epoger@google.com | ab9b658 | 2011-08-15 19:22:39 +0000 | [diff] [blame] | 121 | rm -f out/$(BUILDTYPE) || if test -d out/$(BUILDTYPE); then echo "run 'make clean' or otherwise delete out/$(BUILDTYPE)"; exit 1; fi |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 122 | xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE) |
epoger@google.com | ab9b658 | 2011-08-15 19:22:39 +0000 | [diff] [blame] | 123 | ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE) |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 124 | else |
| 125 | echo "unknown platform $(uname)" |
| 126 | exit 1 |
chudy@google.com | b678911 | 2012-06-29 14:34:58 +0000 | [diff] [blame] | 127 | endif |