summaryrefslogtreecommitdiff
path: root/Makefile
blob: 15566dd9a98ca0ccfcb39b0359f5040476e371e8 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
-include config.mk

BUILDTYPE ?= Release
PYTHON ?= python
V ?= 1

all: setup

setup: config.gypi

config.gypi:
	./setup-libraries.sh

# Builds the regular library
mbgl: config.gypi mbgl.gyp node
	deps/run_gyp mbgl.gyp --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
	$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-x86

node:
	@if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi;

##### Test cases ###############################################################

build/test/Makefile: src common config.gypi test/test.gyp
	deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make

test: build/test/Makefile
	$(MAKE) -C build/test BUILDTYPE=Testing V=$(V) test

test/%: build/test/Makefile
	$(MAKE) -C build/test BUILDTYPE=Testing V=$(V) $*
	(cd build/Testing && exec ./test_$*)

# build Mac OS X project for Xcode
xtest: config.gypi clear_xcode_cache node
	deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build -f xcode
	open ./build/test/test.xcodeproj

##### Makefile builds ##########################################################


# Builds the linux app with make. This is also used by Travis CI
linux: config.gypi linux/mbgl-app.gyp node
	deps/run_gyp linux/mbgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make
	$(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp

# Executes the Linux binary
run-linux: linux
	(cd build/$(BUILDTYPE) && ./mapbox-gl)



# Builds the OS X app with make.
osx: config.gypi macosx/mbgl-app.gyp node
	deps/run_gyp macosx/mbgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make
	$(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp

# Executes the OS X binary
run-osx: osx
	build/$(BUILDTYPE)/Mapbox\ GL.app/Contents/MacOS/MAPBOX\ GL

##### Xcode projects ###########################################################

clear_xcode_cache:
    @CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \
    if [[ $$CUSTOM_DD ]]; then \
        echo clearing files in $$CUSTOM_DD older than one day; \
        find $$CUSTOM_DD/mbgl-app-* -mtime +1 | xargs rm -rf; \
    fi; \
    if [[ -d ~/Library/Developer/Xcode/DerivedData/ ]] && [[ ! $$CUSTOM_DD ]]; then \
        echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/mbgl-app-* older than one day'; \
        find ~/Library/Developer/Xcode/DerivedData/mbgl-app-* -mtime +1 | xargs rm -rf; \
    fi

# build Mac OS X project for Xcode
xproj: config.gypi macosx/mbgl-app.gyp clear_xcode_cache node
	deps/run_gyp macosx/mbgl-app.gyp --depth=. --generator-output=./build -f xcode
	open ./build/macosx/mbgl-app.xcodeproj

# build iOS project for Xcode
iproj: config.gypi ios/mapbox-gl-cocoa/app/mbgl-app.gyp clear_xcode_cache node
	deps/run_gyp ios/mapbox-gl-cocoa/app/mbgl-app.gyp --depth=. --generator-output=./build -f xcode
	open ./build/ios/mapbox-gl-cocoa/app/mbgl-app.xcodeproj

# build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code)
lproj: config.gypi linux/mbgl-app.gyp clear_xcode_cache node
	deps/run_gyp linux/mbgl-app.gyp --depth=. --generator-output=./build -f xcode
	open ./build/linux/mbgl-app.xcodeproj


##### Maintenace operations ####################################################

clean: clear_xcode_cache
	-find ./deps/gyp -name "*.pyc" -exec rm {} \;
	-rm -rf ./build/
	-rm -rf ./config.mk
	-rm -rf ./config.gypi

distclean: clean
	-rm -rf ./config.mk
	-rm -rf ./config.gypi
	-rm -rf ./mapnik-packaging/osx/out/

.PHONY: mbgl test linux