Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: native_client_sdk/src/examples/hello_world_glibc/Makefile

Issue 9234043: Support GLBIC example. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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:=hello_world
19 CXX_SOURCES:=hello_world.cc helper_functions.cc
20 COPY_FILES:=hello_world.html
21 LDFLAGS:=-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 PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
32
33 # Project Build flags
34 DEFINES:=
35 INCLUDES:=
36 WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror
37 CXXFLAGS:= -shared -pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES)
38
39 #
40 # Compute tool paths
41 #
42 #
43 OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py)
44 TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_glibc)
45 CC:=$(TC_PATH)/bin/i686-nacl-gcc
46 CXX:=$(TC_PATH)/bin/i686-nacl-g++
47 STRIP:=$(TC_PATH)/bin/i686-nacl-strip
48
49 #
50 # Create shell aliases
51 #
52 # Create Python based aliases for common shell commands like copy or move.
53 #
54 COPY:= python $(PEPPER_ROOT)/tools/oshelpers.py cp
55 MKDIR:= python $(PEPPER_ROOT)/tools/oshelpers.py mkdir
56 RM:= python $(PEPPER_ROOT)/tools/oshelpers.py rm
57 MV:= python $(PEPPER_ROOT)/tools/oshelpers.py mv
58
59 #
60 # NMF Manifiest generation
61 #
62 NMF:=python $(PEPPER_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
66 #
67 # Disable DOS PATH warning when using Cygwin based tools Windows
68 #
69 CYGWIN ?= nodosfilewarning
70 export CYGWIN
71
72 #
73 # Define a macro for copying files to the configuration directory
74 #
75 # Copys a source file to the destination directory, removing the base path
76 # from the source. Adds a dependency to the destination directory in case it
77 # needs to be created.
78 #
79 # $(1) = Source file
80 # $(2) = Destination directory
81 define FILE_COPY
82 $(2)/$(notdir $(1)) : $(1) | $(2)
83 $(COPY) $(1) $(2)
84 $(2)_COPIES+=$(2)/$(notdir $(1))
85 endef
86
87
88 # Declare the ALL target first, to make the 'all' target the default build
89 all: DEBUG RELEASE
90
91
92 #
93 # Debug Build rules.
94 #
95 DEBUG_x86_32_FLAGS:=-m32 -O0 -g
96 DEBUG_x86_64_FLAGS:=-m64 -O0 -g
97 DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES))
98 DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES))
99
100 # Create DBG configuration directories
101 DBG:
102 $(MKDIR) -p $@
103
104 DBG/x86_32:
105 $(MKDIR) -p $@
106
107 DBG/x86_64:
108 $(MKDIR) -p $@
109
110 # Copy all files to that config
111 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG)))
112
113 # Include generated dependencies
114 -include DBG/x86_32/*.d
115 -include DBG/x86_64/*.d
116
117 # Define compile rule for all 32 bit debug objects
118 DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32
119 $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d
120
121 # Define compile rule for all 64 bit debug objects
122 DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64
123 $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) -MMD -MF $@.d
124
125 # Define Link rule for 32 bit debug NEXE
126 DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS)
127 $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS)
128
129 # Define Link rule for 64 bit debug NEXE
130 DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS)
131 $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS)
132
133 # Define rule for building NMF file and copying dependencies
134 DBG/$(PROJECT).nmf : DBG/$(PROJECT)_x86_64.nexe DBG/$(PROJECT)_x86_32.nexe
135 $(NMF) -o $@ -s DBG $(NMF_PATHS) $^
136
137 # Define a DEBUG alias to build the debug version
138 DBG_NEXES:= DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe
139 .PHONY : DEBUG RUN_DEBUG
140 DEBUG : $(DBG_NEXES) DBG/$(PROJECT).nmf $(DBG_COPIES)
141
142 # Define a RUN_DEBUG alias to build and server the DEBUG version
143 RUN_DEBUG: DEBUG
144 cd DBG && python ../../httpd.py
145
146
147 #
148 # Release build rules.
149 #
150 RELEASE_x86_32_FLAGS:=-m32 -O2 -g
151 RELEASE_x86_64_FLAGS:=-m64 -O2 -g
152 RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES))
153 RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES))
154
155 REL:
156 $(MKDIR) -p $@
157
158 REL/x86_32:
159 $(MKDIR) -p $@
160
161 REL/x86_64:
162 $(MKDIR) -p $@
163
164 # Copy all files to that config
165 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL)))
166
167 # Include generated dependencies
168 -include REL/x86_32/*.d
169 -include REL/x86_64/*.d
170
171 # Define compile rule for all 32 bit debug objects
172 REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32
173 $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d
174
175 # Define compile rule for all 64 bit debug objects
176 REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64
177 $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) -MMD -MF $@.d
178
179 # Define Link rule for 32 bit optimized and stripped NEXE
180 REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS)
181 $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS)
182 $(STRIP) $< -o $@
183
184 # Define Link rule for 64 bit optimized and stripped NEXE
185 REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS)
186 $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS)
187 $(STRIP) $@.unstripped -o $@
188
189 # Define rule for building NMF file and copying dependencies
190 REL/$(PROJECT).nmf : REL/$(PROJECT)_x86_64.nexe REL/$(PROJECT)_x86_32.nexe
191 $(NMF) -o $@ -s REL $(NMF_PATHS) $^
192
193 # Define a RELEASE alias to build the debug version
194 .PHONY : RELEASE RUN_RELEASE
195 REL_NEXES:=REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe
196 RELEASE : $(REL_NEXES) REL/$(PROJECT).nmf $(REL_COPIES)
197
198 # Define a RUN_RELEASE alias to build and server the RELEASE version
199 RUN_RELEASE: RELEASE
200 cd REL && python ../../httpd.py
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698