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) |
| 32 | |
| 33 | uname := $(shell uname) |
| 34 | ifneq (,$(findstring CYGWIN, $(uname))) |
| 35 | $(error Cannot build using Make on Windows. See http://code.google.com/p/skia/wiki/GettingStartedOnWindows) |
| 36 | endif |
| 37 | |
| 38 | # Default target. This must be listed before all other targets. |
| 39 | .PHONY: default |
| 40 | default: all |
| 41 | |
| 42 | .PHONY: all |
epoger@google.com | 0236294 | 2011-06-23 19:24:28 +0000 | [diff] [blame] | 43 | all: SampleApp bench gm tests tools |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 44 | |
| 45 | .PHONY: clean |
| 46 | clean: |
| 47 | rm -rf out xcodebuild |
| 48 | |
| 49 | # Any targets not defined above... |
| 50 | # Ask gyp to generate the buildfiles as appropriate for this platform, |
| 51 | # and then pass control to those buildfiles. |
| 52 | # |
| 53 | # For the Mac, we create a convenience symlink to the generated binary. |
| 54 | %: |
| 55 | ./gyp_skia |
| 56 | ifneq (,$(findstring Linux, $(uname))) |
epoger@google.com | eaacf47 | 2011-06-28 16:48:56 +0000 | [diff] [blame^] | 57 | $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE) |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 58 | endif |
| 59 | ifneq (,$(findstring Darwin, $(uname))) |
| 60 | xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE) |
| 61 | mkdir -p out/$(BUILDTYPE) |
| 62 | rm -f out/$(BUILDTYPE)/$@ |
| 63 | ln -s $(CWD)/xcodebuild/$(BUILDTYPE)/$@.app/Contents/MacOS/$@ out/$(BUILDTYPE)/$@ |
| 64 | endif |
| 65 | |
| 66 | # This repetition is ugly, but necessary. |
| 67 | # If there are any files/directories within the same directory as this Makefile |
| 68 | # which share the same name as a target ("tests", for example), then make |
| 69 | # will refuse to rebuild those targets because the file already exists. |
| 70 | local_filenames := $(shell ls) |
| 71 | .PHONY: $(local_filenames) |
| 72 | $(local_filenames):: |
| 73 | ./gyp_skia |
| 74 | ifneq (,$(findstring Linux, $(uname))) |
epoger@google.com | eaacf47 | 2011-06-28 16:48:56 +0000 | [diff] [blame^] | 75 | $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE) |
epoger@google.com | 5d2e4cc | 2011-06-22 19:17:28 +0000 | [diff] [blame] | 76 | endif |
| 77 | ifneq (,$(findstring Darwin, $(uname))) |
| 78 | xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE) |
| 79 | mkdir -p out/$(BUILDTYPE) |
| 80 | rm -f out/$(BUILDTYPE)/$@ |
| 81 | ln -s $(CWD)/xcodebuild/$(BUILDTYPE)/$@.app/Contents/MacOS/$@ out/$(BUILDTYPE)/$@ |
| 82 | endif |