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

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

Issue 9370041: Clean up examples (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
OLDNEW
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # 5 #
6 # GNU Make based build file.  For details on GNU Make see: 6 # GNU Make based build file.  For details on GNU Make see:
7 #   http://www.gnu.org/software/make/manual/make.html 7 #   http://www.gnu.org/software/make/manual/make.html
8 # 8 #
9 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 10
24 # 11 #
25 # Get pepper directory for toolchain and includes. 12 # Get pepper directory for toolchain and includes.
26 # 13 #
27 # If PEPPER_ROOT is not set, then assume it can be found a two directories up, 14 # If NACL_SDK_ROOT is not set, then assume it can be found a two directories up,
28 # from the default example directory location. 15 # from the default example directory location.
29 # 16 #
30 THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) 17 THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST)))
31 PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) 18 NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
32 19
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 20
39 # 21 #
40 # Compute tool paths 22 # Project Build flags
41 # 23 #
42 # 24 # Turns on warnings (-Wxxx), builds with zero optimization (-O0) and adds debug
43 OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) 25 # information (-g) for correctness and ease of debugging.
44 TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_glibc) 26 WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic
45 CC:=$(TC_PATH)/bin/i686-nacl-gcc 27 CFLAGS:=-pthread -O0 -g $(WARNINGS)
46 CXX:=$(TC_PATH)/bin/i686-nacl-g++ 28
47 STRIP:=$(TC_PATH)/bin/i686-nacl-strip
48 29
49 # 30 #
50 # Create shell aliases 31 # Compute path to compiler
51 # 32 #
52 # Create Python based aliases for common shell commands like copy or move. 33 OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
53 # 34 TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_glibc)
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 35
59 # 36
60 # NMF Manifiest generation 37 # Alias for C++ compiler
61 # 38 CC:=$(TC_PATH)/bin/i686-nacl-gcc
62 NMF:=python $(PEPPER_ROOT)/tools/create_nmf.py 39
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 40
66 # 41 #
67 # Disable DOS PATH warning when using Cygwin based tools Windows 42 # Disable DOS PATH warning when using Cygwin based tools Windows
68 # 43 #
69 CYGWIN ?= nodosfilewarning 44 CYGWIN ?= nodosfilewarning
70 export CYGWIN 45 export CYGWIN
71 46
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 47
48 # Default target is everything
49 all : hello_world_x86_32.nexe hello_world_x86_64.nexe hello_world.nmf
87 50
88 # Declare the ALL target first, to make the 'all' target the default build 51 # Define compile and link rule for 32 bit (-m32) nexe
89 all: DEBUG RELEASE 52 hello_world_x86_32.nexe : hello_world.c $(THIS_MAKE)
53 » $(CC) -o $@ $< -m32 -O0 -g $(CFLAGS) -lppapi
90 54
55 # Define compile and link rule for 64 bit (-m64) nexe
56 hello_world_x86_64.nexe : hello_world.c $(THIS_MAKE)
57 $(CC) -o $@ $< -m64 -O0 -g $(CFLAGS) -lppapi
91 58
92 # 59 #
93 # Debug Build rules. 60 # NMF Manifiest generation
94 # 61 #
95 DEBUG_x86_32_FLAGS:=-m32 -O0 -g 62 # Use the python script create_nmf to scan the binaries for dependencies using
96 DEBUG_x86_64_FLAGS:=-m64 -O0 -g 63 # objdump. Pass in the (-L) paths to the default library toolchains so that we
97 DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) 64 # can find those libraries and have it automatically copy the files (-s) to
98 DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) 65 # the target directory for us.
66 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
67 NMF_ARGS:=-D $(TC_PATH)/x86_64-nacl/bin/objdump
68 NMF_PATHS:=-L $(TC_PATH)/x86_64-nacl/lib32 -L $(TC_PATH)/x86_64-nacl/lib
99 69
100 # Create DBG configuration directories 70 hello_world.nmf : hello_world_x86_64.nexe hello_world_x86_32.nexe
101 DBG: 71 » echo $(NMF) $(NMF_ARGS) -s . -o $@ $(NMF_PATHS) $^
102 » $(MKDIR) -p $@ 72 » $(NMF) $(NMF_ARGS) -s . -o $@ $(NMF_PATHS) $^
103 73
104 DBG/x86_32: 74 # Define a phony rule so it always runs, to build nexe and start up server.
105 » $(MKDIR) -p $@ 75 .PHONY: RUN
106 76 RUN: all
107 DBG/x86_64: 77 » python ../httpd.py
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