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 | # |
| 28 | # See http://code.google.com/p/skia/wiki/DocRoot for complete documentation. |
| 29 | |
| 30 | BUILDTYPE ?= Debug |
| 31 | CWD := $(shell pwd) |
djsollen@google.com | 686989b | 2012-06-29 18:51:29 +0000 | [diff] [blame] | 32 | ALL_TARGETS := core SampleApp bench gm tests tools |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 33 | |
borenet@google.com | dd3d08e | 2012-06-27 19:04:39 +0000 | [diff] [blame] | 34 | ifneq (,$(findstring skia_os=android, $(GYP_DEFINES))) |
borenet@google.com | 7ef3929 | 2012-07-18 14:59:54 +0000 | [diff] [blame] | 35 | ifeq (,$(findstring android_make_apk=0, $(GYP_DEFINES))) |
borenet@google.com | dd3d08e | 2012-06-27 19:04:39 +0000 | [diff] [blame] | 36 | ALL_TARGETS += SkiaAndroidApp |
| 37 | endif |
borenet@google.com | 7ef3929 | 2012-07-18 14:59:54 +0000 | [diff] [blame] | 38 | endif |
borenet@google.com | dd3d08e | 2012-06-27 19:04:39 +0000 | [diff] [blame] | 39 | |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 40 | # Default target. This must be listed before all other targets. |
| 41 | .PHONY: default |
djsollen@google.com | 686989b | 2012-06-29 18:51:29 +0000 | [diff] [blame] | 42 | default: $(ALL_TARGETS) |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 43 | |
| 44 | # As noted in http://code.google.com/p/skia/issues/detail?id=330 , building |
| 45 | # multiple targets in parallel was failing. The special .NOTPARALLEL target |
| 46 | # tells gnu make not to run targets within _this_ Makefile in parallel, but the |
| 47 | # recursively invoked Makefile within out/ _is_ allowed to run in parallel |
| 48 | # (so you can still get some speedup that way). |
| 49 | .NOTPARALLEL: |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 50 | |
| 51 | uname := $(shell uname) |
| 52 | ifneq (,$(findstring CYGWIN, $(uname))) |
| 53 | $(error Cannot build using Make on Windows. See http://code.google.com/p/skia/wiki/GettingStartedOnWindows) |
| 54 | endif |
| 55 | |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 56 | .PHONY: all |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 57 | all: $(ALL_TARGETS) |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 58 | |
| 59 | .PHONY: clean |
| 60 | clean: |
| 61 | rm -rf out xcodebuild |
| 62 | |
djsollen@google.com | 686989b | 2012-06-29 18:51:29 +0000 | [diff] [blame] | 63 | # Add the debugger to the target list after the 'all' target is defined so that the |
| 64 | # debugger is only executed with 'make debugger' and not 'make all' as well. The reason |
| 65 | # for this is unless the user has Qt installed the debugger target will fail. |
| 66 | ALL_TARGETS += debugger |
| 67 | |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 68 | # Run gyp no matter what. |
| 69 | .PHONY: gyp |
| 70 | gyp: |
| 71 | $(CWD)/gyp_skia |
| 72 | |
| 73 | # Run gyp if necessary. |
| 74 | # |
| 75 | # On Linux, only run gyp if we haven't already generated the platform-specific |
| 76 | # Makefiles. If the underlying gyp configuration has changed since these |
| 77 | # Makefiles were generated, they will rerun gyp on their own. |
| 78 | # |
| 79 | # This does not work for Mac, though... so for now, we ALWAYS rerun gyp on Mac. |
| 80 | # TODO(epoger): Figure out a better solution for Mac... maybe compare the |
| 81 | # gypfile timestamps to the xcodebuild project timestamps? |
| 82 | .PHONY: gyp_if_needed |
| 83 | gyp_if_needed: |
| 84 | ifneq (,$(findstring Linux, $(uname))) |
| 85 | $(MAKE) out/Makefile |
| 86 | endif |
| 87 | ifneq (,$(findstring Darwin, $(uname))) |
| 88 | $(CWD)/gyp_skia |
| 89 | endif |
| 90 | |
| 91 | out/Makefile: |
| 92 | $(CWD)/gyp_skia |
| 93 | |
| 94 | # For all specific targets: run gyp if necessary, and then pass control to |
| 95 | # the gyp-generated buildfiles. |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 96 | # |
| 97 | # For the Mac, we create a convenience symlink to the generated binary. |
epoger@google.com | c9493a4 | 2011-07-27 14:06:25 +0000 | [diff] [blame] | 98 | .PHONY: $(ALL_TARGETS) |
| 99 | $(ALL_TARGETS):: gyp_if_needed |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 100 | ifneq (,$(findstring skia_os=android, $(GYP_DEFINES))) |
epoger@google.com | eaacf47 | 2011-06-28 16:48:56 +0000 | [diff] [blame] | 101 | $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE) |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 102 | else ifneq (,$(findstring Linux, $(uname))) |
| 103 | $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE) |
| 104 | else ifneq (,$(findstring Darwin, $(uname))) |
epoger@google.com | ab9b658 | 2011-08-15 19:22:39 +0000 | [diff] [blame] | 105 | 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] | 106 | xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE) |
epoger@google.com | ab9b658 | 2011-08-15 19:22:39 +0000 | [diff] [blame] | 107 | ln -s $(CWD)/xcodebuild/$(BUILDTYPE) out/$(BUILDTYPE) |
borenet@google.com | b52cf3d | 2012-06-05 17:57:48 +0000 | [diff] [blame] | 108 | else |
| 109 | echo "unknown platform $(uname)" |
| 110 | exit 1 |
chudy@google.com | b678911 | 2012-06-29 14:34:58 +0000 | [diff] [blame] | 111 | endif |