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

Side by Side Diff: native_client_sdk/src/tools/nacl_gcc.mk

Issue 11882012: Convert all project to use common.mk (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 7 years, 11 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
« no previous file with comments | « native_client_sdk/src/tools/host_vc.mk ('k') | native_client_sdk/src/tools/nacl_llvm.mk » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium 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
12 #
13 # Default Paths
14 #
15
16 LD_X86_32:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)
17 LD_X86_64:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)
18 LD_ARM:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)
19
20
21 #
22 # Macros for TOOLS
23 #
24 # We use the C++ compiler for everything and then use the -Wl,-as-needed flag
25 # in the linker to drop libc++ unless it's actually needed.
26 #
27 X86_CC?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-gcc
28 X86_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++
29 X86_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ -Wl,-as-needed
30 X86_LIB?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-ar r
31
32 ARM_CC?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-gcc
33 ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++
34 ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ -Wl,-as-needed
35 ARM_LIB?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-ar r
36
37
38 #
39 # Compile Macro
40 #
41 # $1 = Source Name
42 # $2 = Compile Flags
43 #
44 define C_COMPILER_RULE
45 $(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(TOP_MAKE) | $(OUTDIR)
46 $(X86_CC) -o $$@ -c $$< -m32 $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
47
48 $(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(TOP_MAKE) | $(OUTDIR)
49 $(X86_CC) -o $$@ -c $$< -m64 $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
50
51 $(OUTDIR)/$(basename $(1))_arm.o : $(1) $(TOP_MAKE) | $(OUTDIR)
52 $(ARM_CC) -o $$@ -c $$< $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
53 endef
54
55 define CXX_COMPILER_RULE
56 $(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(TOP_MAKE) | $(OUTDIR)
57 $(X86_CXX) -o $$@ -c $$< -m32 $(POSIX_OPT_FLAGS) $(2) $(NACL_CXXFLAGS)
58
59 $(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(TOP_MAKE) | $(OUTDIR)
60 $(X86_CXX) -o $$@ -c $$< -m64 $(POSIX_OPT_FLAGS) $(2) $(NACL_CXXFLAGS)
61
62 $(OUTDIR)/$(basename $(1))_arm.o : $(1) $(TOP_MAKE) | $(OUTDIR)
63 $(ARM_CXX) -o $$@ -c $$< $(POSIX_OPT_FLAGS) $(2) $(NACL_CXXFLAGS)
64 endef
65
66
67 #
68 # $1 = Source Name
69 # $2 = POSIX Compile Flags
70 # $3 = Include Directories
71 # $4 = VC Flags (unused)
72 #
73 define COMPILE_RULE
74 ifeq ('.c','$(suffix $(1))')
75 $(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3))
76 else
77 $(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3))
78 endif
79 endef
80
81
82 #
83 # SO Macro
84 #
85 # $1 = Target Name
86 # $2 = List of Sources
87 #
88 #
89 GLIBC_REMAP:=
90 define SO_RULE
91 NMF_TARGETS+=$$(OUTDIR)/$(1)_x86_32.so
92 $(OUTDIR)/$(1)_x86_32.so : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_3 2.o) $(4)
93 $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -shared -m32 $$(LD_X86_32) $$ (LD_FLAGS) $(foreach lib,$(3),-l$(lib))
94
95 NMF_TARGETS+=$(OUTDIR)/$(1)_x86_64.so
96 $(OUTDIR)/$(1)_x86_64.so : $(foreach src,$(2),$$(OUTDIR)/$(basename $(src))_x86_ 64.o) $(4)
97 $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -shared -m64 $(LD_X86_64) $$( LD_FLAGS) $(foreach lib,$(3),-l$(lib))
98
99 GLIBC_SO_LIST+=$(OUTDIR)/$(1)_x86_32.so $(OUTDIR)/$(1)_x86_64.so
100 GLIBC_REMAP+=-n $(1)_x86_32.so,$(1).so
101 GLIBC_REMAP+=-n $(1)_x86_64.so,$(1).so
102 endef
103
104
105 #
106 # LIB Macro
107 #
108 # $1 = Target Name
109 # $2 = List of Sources
110 # $3 = POSIX Link Flags
111 # $4 = VC Link Flags (unused)
112 #
113 define LIB_RULE
114 all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a
115 $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a : $(foreach src,$(2 ),$(OUTDIR)/$(basename $(src))_x86_32.o)
116 $(MKDIR) -p $$(dir $$@)
117 $(X86_LIB) $$@ $$^
118
119 all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a
120 $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a : $(foreach src,$(2 ),$(OUTDIR)/$(basename $(src))_x86_64.o)
121 $(MKDIR) -p $$(dir $$@)
122 $(X86_LIB) $$@ $$^
123
124 ifneq ('glibc','$(TOOLCHAIN)')
125 all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a
126 endif
127 $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$ (OUTDIR)/$(basename $(src))_arm.o)
128 $(MKDIR) -p $$(dir $$@)
129 $(ARM_LIB) $$@ $$^
130 endef
131
132
133 #
134 # Specific Link Macro
135 #
136 # $1 = Target Name
137 # $2 = List of Sources
138 # $3 = List of LIBS
139 # $4 = List of DEPS
140 # $5 = POSIX Link Flags
141 # $6 = Library Paths
142 #
143 define LINKER_RULE
144 $(OUTDIR)/$(1)_x86_32.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86 _32.o) $(4)
145 $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -m32 $(foreach path,$(6),-L$( path)/$(TOOLCHAIN)_x86_32/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)
146
147 $(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$$(OUTDIR)/$(basename $(src))_x8 6_64.o) $(4)
148 $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -m64 $(foreach path,$(6),-L$( path)/$(TOOLCHAIN)_x86_64/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)
149
150 $(OUTDIR)/$(1)_arm.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_arm.o) $(4)
151 $(ARM_LINK) -o $$@ $$(filter-out $(4),$$^) $(foreach path,$(6),-L$(path) /$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)
152 endef
153
154
155 #
156 # Generalized Link Macro
157 #
158 # $1 = Target Name
159 # $2 = List of Sources
160 # $3 = List of LIBS
161 # $4 = List of DEPS
162 # $5 = POSIX Linker Switches
163 # $6 = VC Linker Switches
164 #
165 define LINK_RULE
166 $(call LINKER_RULE,$(1),$(2),$(filter-out pthread,$(3)),$(4),$(5),$(LIB_PATHS))
167 endef
168
169
170 #
171 # Generate NMF_TARGETS
172 #
173 ARCHES=x86_32 x86_64
174 ifeq "newlib" "$(TOOLCHAIN)"
175 ARCHES+=arm
176 endif
177 NMF_ARCHES:=$(foreach arch,$(ARCHES),_$(arch).nexe)
178
179
180 #
181 # NMF Manifiest generation
182 #
183 # Use the python script create_nmf to scan the binaries for dependencies using
184 # objdump. Pass in the (-L) paths to the default library toolchains so that we
185 # can find those libraries and have it automatically copy the files (-s) to
186 # the target directory for us.
187 #
188 # $1 = Target Name (the basename of the nmf
189 # $2 = Additional create_nmf.py arguments
190 #
191 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
192 GLIBC_DUMP:=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump
193 GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32
194 GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib
195
196 define NMF_RULE
197 all:$(OUTDIR)/$(1).nmf
198 $(OUTDIR)/$(1).nmf : $(foreach arch,$(NMF_ARCHES),$(OUTDIR)/$(1)$(arch)) $(GLIBC _SO_LIST)
199 $(NMF) -o $$@ $$^ -D $(GLIBC_DUMP) $(GLIBC_PATHS) -s $(OUTDIR) $(2) $(GL IBC_REMAP)
200 endef
201
202
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/host_vc.mk ('k') | native_client_sdk/src/tools/nacl_llvm.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698