OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 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 # Project information | |
12 # | |
13 # These variables store project specific settings for the project name | |
14 # build flags, files to copy or install. In the examples it is typically | |
15 # only the list of sources and project name that will actually change and | |
16 # the rest of the makefile is boilerplate for defining build rules. | |
17 # | |
18 PROJECT:=dlopen | |
19 WARNINGS:=-Wno-long-long -Wall | |
20 CXXFLAGS:=-g -O0 -pthread -std=gnu++98 $(WARNINGS) | |
21 LDFLAGS:=-g -ldl -lppapi_cpp -lppapi | |
22 | |
23 | |
24 # | |
25 # Get pepper directory for toolchain and includes. | |
26 # | |
27 # If PEPPER_ROOT is not set, then assume it can be found a two directories up, | |
28 # from the default example directory location. | |
29 # | |
30 THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) | |
31 NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) | |
32 | |
33 # | |
34 # Compute tool paths | |
35 # | |
36 # | |
37 OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py) | |
38 TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_glibc) | |
39 CXX:=$(TC_PATH)/bin/i686-nacl-g++ | |
40 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py | |
41 | |
42 # | |
43 # Create shell aliases | |
44 # | |
45 # Create Python based aliases for common shell commands like copy or move. | |
46 # | |
47 COPY:= python $(NACL_SDK_ROOT)/tools/oshelpers.py cp | |
48 MKDIR:= python $(NACL_SDK_ROOT)/tools/oshelpers.py mkdir | |
49 RM:= python $(NACL_SDK_ROOT)/tools/oshelpers.py rm | |
50 MV:= python $(NACL_SDK_ROOT)/tools/oshelpers.py mv | |
51 | |
52 # | |
53 # Disable DOS PATH warning when using Cygwin based tools Windows | |
54 # | |
55 CYGWIN ?= nodosfilewarning | |
56 export CYGWIN | |
57 | |
58 | |
59 # | |
60 # NMF Manifiest generation | |
61 # | |
62 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py | |
63 NMF+=-D $(TC_PATH)/x86_64-nacl/bin/objdump | |
64 NMF_PATHS:=-L $(TC_PATH)/x86_64-nacl/lib32 -L $(TC_PATH)/x86_64-nacl/lib | |
65 NMF_PATHS+=-L lib32 -L lib64 | |
66 | |
67 | |
68 # | |
69 # Disable DOS PATH warning when using Cygwin based tools Windows | |
70 # | |
71 CYGWIN ?= nodosfilewarning | |
72 export CYGWIN | |
73 | |
74 | |
75 # Declare the ALL target first, to make the 'all' target the default build. | |
76 # Since the NMF file requires all the binaires for generation we use that as | |
77 # the dependency. | |
78 all : $(PROJECT).nmf | |
79 | |
80 # Rules to create subdirectories for libraries | |
81 lib32: | |
82 $(MKDIR) -p $@ | |
83 | |
84 lib64: | |
85 $(MKDIR) -p $@ | |
86 | |
87 # Copy all files to that config | |
88 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) | |
89 | |
90 # Build debug version dlopen nexe and eightball.so for 32 and 64 bit. | |
91 dlopen_x86_32.o: dlopen.cc $(THIS_MAKE) | |
92 $(CXX) -o $@ -c $< -m32 $(CXXFLAGS) | |
93 | |
94 dlopen_x86_32.nexe: dlopen_x86_32.o | |
95 $(CXX) -o $@ $< -m32 $(LDFLAGS) | |
96 | |
97 dlopen_x86_64.o: dlopen.cc $(THIS_MAKE) | |
98 $(CXX) -o $@ -c $< -m64 $(CXXFLAGS) | |
99 | |
100 dlopen_x86_64.nexe: dlopen_x86_64.o | |
101 $(CXX) -o $@ $< -m64 $(LDFLAGS) | |
102 | |
103 eightball_x86_32.o: eightball.cc $(THIS_MAKE) | |
104 $(CXX) -o $@ -c $< -m32 $(CXXFLAGS) -fPIC | |
105 | |
106 lib32/libeightball.so: eightball_x86_32.o | lib32 | |
107 $(CXX) -o $@ $< -m32 $(LDFLAGS) -shared | |
108 | |
109 eightball_x86_64.o: eightball.cc $(THIS_MAKE) | |
110 $(CXX) -o $@ -c $< -m64 $(CXXFLAGS) -fPIC | |
111 | |
112 lib64/libeightball.so: eightball_x86_64.o | lib64 | |
113 $(CXX) -o $@ $< -m64 $(LDFLAGS) -shared | |
114 | |
115 # | |
116 # NMF Manifiest generation | |
117 # | |
118 # Use the python script create_nmf to scan the binaries for dependencies using | |
119 # objdump. Pass in the (-L) paths to the default library toolchains so that we | |
120 # can find those libraries and have it automatically copy the files (-s) to | |
121 # the target directory for us. | |
122 NEXES:=dlopen_x86_32.nexe dlopen_x86_64.nexe | |
123 NEXES+=lib32/libeightball.so lib64/libeightball.so | |
124 NMF_ARGS:=-D $(TC_PATH)/x86_64-nacl/bin/objdump | |
125 NMF_PATHS:=-L $(TC_PATH)/x86_64-nacl/lib32 -L $(TC_PATH)/x86_64-nacl/lib64 | |
126 | |
127 $(PROJECT).nmf : $(NEXES) | |
128 $(NMF) -o $@ -s . $^ $(NMF_PATHS) | |
129 | |
130 # Define a phony rule so it always runs, to build nexe and start up server. | |
131 .PHONY: RUN | |
132 RUN: all | |
133 python ../httpd.py | |
134 | |
OLD | NEW |