• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Native Client Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5#
6# GNU Make based build file.  For details on GNU Make see:
7# http://www.gnu.org/software/make/manual/make.html
8#
9
10#
11# Get pepper directory for toolchain and includes.
12#
13# If NACL_SDK_ROOT is not set, then assume it can be found three directories up.
14#
15THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
16NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../..)
17
18# Project Build flags
19WARNINGS := -Wno-long-long -Wall -Wswitch-enum -pedantic -Werror
20CXXFLAGS := -pthread -std=gnu++98 $(WARNINGS)
21
22#
23# Compute tool paths
24#
25GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
26OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
27OSNAME := $(shell $(GETOS))
28RM := $(OSHELPERS) rm
29
30PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
31PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang++
32PNACL_FINALIZE := $(PNACL_TC_PATH)/bin/pnacl-finalize
33CXXFLAGS := -I$(NACL_SDK_ROOT)/include
34LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi
35
36#
37# Disable DOS PATH warning when using Cygwin based tools Windows
38#
39CYGWIN ?= nodosfilewarning
40export CYGWIN
41
42
43# Declare the ALL target first, to make the 'all' target the default build
44all: hello_tutorial.pexe
45
46clean:
47	$(RM) hello_tutorial.pexe hello_tutorial.bc
48
49hello_tutorial.bc: hello_tutorial.cc
50	$(PNACL_CXX) -o $@ $< -O2 $(CXXFLAGS) $(LDFLAGS)
51
52hello_tutorial.pexe: hello_tutorial.bc
53	$(PNACL_FINALIZE) -o $@ $<
54
55
56#
57# Makefile target to run the SDK's simple HTTP server and serve this example.
58#
59HTTPD_PY := python $(NACL_SDK_ROOT)/tools/httpd.py
60
61.PHONY: serve
62serve: all
63	$(HTTPD_PY) -C $(CURDIR)
64