Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / native_client_sdk / src / tools / nacl_gcc.mk
blob9a4fee18b1e6d96955ae1e9ef4acddac86f29626
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.
6 # GNU Make based build file. For details on GNU Make see:
7 # http://www.gnu.org/software/make/manual/make.html
13 # Default Paths
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)
22 # Macros for TOOLS
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.
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
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
39 # Compile Macro
41 # $1 = Source Name
42 # $2 = Compile Flags
44 define C_COMPILER_RULE
45 $(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(TOP_MAKE) | $(OUTDIR)
46 $(X86_CC) -o $$@ -c $$< -m32 $(POSIX_FLAGS) $(2) $(NACL_CFLAGS)
48 $(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(TOP_MAKE) | $(OUTDIR)
49 $(X86_CC) -o $$@ -c $$< -m64 $(POSIX_FLAGS) $(2) $(NACL_CFLAGS)
51 $(OUTDIR)/$(basename $(1))_arm.o : $(1) $(TOP_MAKE) | $(OUTDIR)
52 $(ARM_CC) -o $$@ -c $$< $(POSIX_FLAGS) $(2) $(NACL_CFLAGS)
53 endef
55 define CXX_COMPILER_RULE
56 $(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(TOP_MAKE) | $(OUTDIR)
57 $(X86_CXX) -o $$@ -c $$< -m32 $(POSIX_FLAGS) $(2) $(NACL_CXXFLAGS)
59 $(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(TOP_MAKE) | $(OUTDIR)
60 $(X86_CXX) -o $$@ -c $$< -m64 $(POSIX_FLAGS) $(2) $(NACL_CXXFLAGS)
62 $(OUTDIR)/$(basename $(1))_arm.o : $(1) $(TOP_MAKE) | $(OUTDIR)
63 $(ARM_CXX) -o $$@ -c $$< $(POSIX_FLAGS) $(2) $(NACL_CXXFLAGS)
64 endef
68 # $1 = Source Name
69 # $2 = POSIX Compile Flags
70 # $3 = Include Directories
71 # $4 = VC Flags (unused)
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
83 # SO Macro
85 # $1 = Target Name
86 # $2 = List of Sources
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_32.o) $(4)
93 $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -shared -m32 $$(LD_X86_32) $$(LD_FLAGS) $(foreach lib,$(3),-l$(lib))
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))
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
106 # LIB Macro
108 # $1 = Target Name
109 # $2 = List of Sources
110 # $3 = POSIX Link Flags
111 # $4 = VC Link Flags (unused)
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) $$@ $$^
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) $$@ $$^
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
134 # Specific Link Macro
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
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)
147 $(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$$(OUTDIR)/$(basename $(src))_x86_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)
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
156 # Generalized Link Macro
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
165 define LINK_RULE
166 $(call LINKER_RULE,$(1),$(2),$(filter-out pthread,$(3)),$(4),$(5),$(LIB_PATHS))
167 endef
171 # Generate NMF_TARGETS
173 ARCHES=x86_32 x86_64
174 ifeq "newlib" "$(TOOLCHAIN)"
175 ARCHES+=arm
176 endif
177 NMF_ARCHES:=$(foreach arch,$(ARCHES),_$(arch).nexe)
181 # NMF Manifiest generation
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.
188 # $1 = Target Name (the basename of the nmf
189 # $2 = Additional create_nmf.py arguments
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
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) $(GLIBC_REMAP)
200 endef