-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
134 lines (105 loc) · 3.7 KB
/
Makefile
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
CHROME_PATH?=Undefined
#
# Defaults
#
NACL_WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic
NACL_CCFLAGS:=-O0 -g -pthread $(NACL_WARNINGS)
NACL_CXXFLAGS:= -O0 -g -pthread -std=gnu++98 $(NACL_WARNINGS)
NACL_LDFLAGS:=-g -pthread -lppapi_cpp -lppapi
#
# Project Settings
#
VALID_TOOLCHAINS:=newlib
TOOLCHAIN?=newlib
CHECKERS_CXX:=main.cc checkers.cc move_gen.cc game_state.cc game.cc helper.cc player.cc random.cc ai.cc minmax.cc search_node.cc
CHECKERS_CXXFLAGS:=$(NACL_CXXFLAGS)
CHECKERS_LDFLAGS:=$(NACL_LDFLAGS)
#
# Default target
#
all: newlib/checkers.nmf
#
# Alias for standard commands
#
CP:=python $(NACL_SDK_ROOT)/tools/oshelpers.py cp
MKDIR:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mkdir
MV:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mv
#
# Verify we selected a valid toolchain for this example
#
ifeq (,$(findstring $(TOOLCHAIN),$(VALID_TOOLCHAINS)))
$(warning Availbile choices are: $(VALID_TOOLCHAINS))
$(error Can not use TOOLCHAIN=$(TOOLCHAIN) on this example.)
endif
#
# Compute path to requested NaCl Toolchain
#
OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain)
#
# Verify we have a valid NACL_SDK_ROOT by looking for the toolchain directory
#
ifeq (,$(wildcard $(TC_PATH)))
$(warning No valid NACL_SDK_ROOT at $(NACL_SDK_ROOT))
ifeq ($(origin NACL_SDK_ROOT), 'file')
$(error Override the default value via enviornment variable, or command-line.)
else
$(error Fix the NACL_SDK_ROOT specified in the environment or command-line.)
endif
endif
#
# Disable DOS PATH warning when using Cygwin based NaCl tools on Windows
#
CYGWIN ?= nodosfilewarning
export CYGWIN
#
# Defaults for TOOLS
#
NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c
NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c
NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed
NEWLIB_DUMP?=$(TC_PATH)/$(OSNAME)_x86_newlib/x86_64-nacl/bin/objdump
#
# NMF Manifiest generation
#
# Use the python script create_nmf to scan the binaries for dependencies using
# objdump. Pass in the (-L) paths to the default library toolchains so that we
# can find those libraries and have it automatically copy the files (-s) to
# the target directory for us.
NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
#
# Verify we can find the Chrome executable if we need to launch it.
#
.PHONY: CHECK_FOR_CHROME
CHECK_FOR_CHROME:
ifeq (,$(wildcard $(CHROME_PATH)))
$(warning No valid Chrome found at CHROME_PATH=$(CHROME_PATH))
$(error Set CHROME_PATH via an environment variable, or command-line.)
else
$(warning Using chrome at: $(CHROME_PATH))
endif
#
# Rules for newlib toolchain
#
newlib:
$(MKDIR) newlib
CHECKERS_x86_32_CXX_O:=$(patsubst %.cc, newlib/%_x86_32.o,$(CHECKERS_CXX))
$(CHECKERS_x86_32_CXX_O) : newlib/%_x86_32.o : %.cc $(THIS_MAKE) | newlib
$(NEWLIB_CXX) -o $@ $< -m32 $(CHECKERS_CXXFLAGS) -DTCNAME=newlib
newlib/checkers_x86_32.nexe : $(CHECKERS_x86_32_CXX_O)
$(NEWLIB_LINK) -o $@ $^ -m32 $(CHECKERS_LDFLAGS)
NEWLIB_NMF+=newlib/checkers_x86_32.nexe
CHECKERS_x86_64_CXX_O:=$(patsubst %.cc, newlib/%_x86_64.o,$(CHECKERS_CXX))
$(CHECKERS_x86_64_CXX_O) : newlib/%_x86_64.o : %.cc $(THIS_MAKE) | newlib
$(NEWLIB_CXX) -o $@ $< -m64 $(CHECKERS_CXXFLAGS) -DTCNAME=newlib
newlib/checkers_x86_64.nexe : $(CHECKERS_x86_64_CXX_O)
$(NEWLIB_LINK) -o $@ $^ -m64 $(CHECKERS_LDFLAGS)
NEWLIB_NMF+=newlib/checkers_x86_64.nexe
newlib/checkers.nmf : $(NEWLIB_NMF)
$(NMF) -D $(NEWLIB_DUMP) -o $@ $^ -t newlib -s newlib
RUN: all
python ../httpd.py
LAUNCH_NEXE: CHECK_FOR_CHROME all
$(CHROME_PATH) $(NEXE_ARGS) "localhost:5103/$(PROJECT).html?tool=$(TOOLCHAIN)"