Autofill: Add WalletIntegrationAvailable() to components.
[chromium-blink-merge.git] / native_client_sdk / src / tools / host_gcc.mk
blob604b073b6872faaa1e9edf92c8f067299a3e709b
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
12 # Macros for TOOLS
14 # We use the C++ compiler for everything and then use the -Wl,-as-needed flag
15 # in the linker to drop libc++ unless it's actually needed.
17 CC ?= $(NACL_COMPILER_PREFIX) gcc
18 CXX ?= $(NACL_COMPILER_PREFIX) g++
19 LINK ?= $(CXX)
20 AR ?= ar
21 ARFLAGS = -crs
22 STRIP ?= strip
24 ifeq (,$(findstring gcc,$(shell $(WHICH) gcc)))
25 $(warning To skip the host build use:)
26 $(warning "make all_versions NO_HOST_BUILDS=1")
27 $(error Unable to find gcc in PATH while building Host build)
28 endif
30 HOST_WARNINGS ?= -Wno-long-long -Wall -Werror
31 HOST_CFLAGS = -fPIC -pthread $(HOST_WARNINGS) -I$(NACL_SDK_ROOT)/include
33 ifneq ($(OSNAME),mac)
34 # Adding -Wl,-Bsymbolic means that symbols defined within the module are always
35 # used by the module, and not shadowed by symbols already loaded in, for
36 # exmaple, libc. Without this the libc symbols (or anything injected with
37 # LD_PRELOAD will take precedence).
38 # -pthread is not needed on mac (libpthread is a symlink to libSystem) and
39 # in fact generated a warning if passed at link time.
40 HOST_LDFLAGS ?= -Wl,-Map,$(OUTDIR)/$(TARGET).map -Wl,-Bsymbolic -pthread
41 HOST_CFLAGS += -I$(NACL_SDK_ROOT)/include/mac
42 else
43 HOST_LDFLAGS ?= -Wl,-map -Wl,$(OUTDIR)/$(TARGET).map
44 HOST_CFLAGS += -I$(NACL_SDK_ROOT)/include/linux
45 endif
49 # Individual Macros
51 # $1 = Source name
52 # $2 = Compile flags
54 define C_COMPILER_RULE
55 -include $(call SRC_TO_DEP,$(1))
56 $(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
57 $(call LOG,CC ,$$@,$(CC) -o $$@ -c $$< -fPIC $(POSIX_CFLAGS) $(HOST_CFLAGS) $(CFLAGS) $(2))
58 @$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
59 endef
61 define CXX_COMPILER_RULE
62 -include $(call SRC_TO_DEP,$(1))
63 $(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
64 $(call LOG,CXX ,$$@,$(CXX) -o $$@ -c $$< -fPIC $(POSIX_CFLAGS) $(HOST_CFLAGS) $(CXXFLAGS) $(2))
65 @$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
66 endef
69 # Compile Macro
71 # $1 = Source name
72 # $2 = POSIX compiler flags
73 # $3 = VC compiler flags (unused)
75 define COMPILE_RULE
76 ifeq ($(suffix $(1)),.c)
77 $(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)))
78 else
79 $(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)))
80 endif
81 endef
85 # SO Macro
87 # $1 = Target name
88 # $2 = list of source files
90 define SO_RULE
91 $(error 'Shared libraries not supported by Host')
92 endef
96 # LIB Macro
98 # $1 = Target name
99 # $2 = List of source files
101 define LIB_RULE
102 $(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a
103 @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
105 all: $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a
106 $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src)))
107 $(MKDIR) -p $$(dir $$@)
108 $(RM) -f $$@
109 $(call LOG,LIB,$$@,$(AR) $(ARFLAGS) $$@ $$^)
110 endef
114 # Link Macro
116 # $1 = Target name
117 # $2 = List of inputs
118 # $3 = List of libs
119 # $4 = List of deps
120 # $5 = List of lib dirs
121 # $6 = Linker flags
123 ifdef STANDALONE
124 define LINKER_RULE
125 all: $(1)
126 $(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
127 $(call LOG,LINK,$$@,$(LINK) -o $(1) $(2) $(HOST_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(OSNAME)_host)/$(CONFIG) $(foreach lib,$(3),-l$(lib)) $(6))
128 endef
129 else
130 define LINKER_RULE
131 all: $(1)
132 $(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
133 $(call LOG,LINK,$$@,$(LINK) -shared -o $(1) $(2) $(HOST_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(OSNAME)_host)/$(CONFIG) $(foreach lib,$(3),-l$(lib)) $(6))
134 endef
135 endif
139 # Link Macro
141 # $1 = Target Name
142 # $2 = List of source files
143 # $3 = List of LIBS
144 # $4 = List of DEPS
145 # $5 = POSIX linker flags
146 # $6 = VC linker flags
148 define LINK_RULE
149 $(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(call SRC_TO_OBJ,$(src))),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5))
150 endef
152 all: $(LIB_LIST) $(DEPS_LIST)
156 # Strip Macro
157 # The host build makes shared libraries, so the best we can do is -S, which
158 # only strip debug symbols. We don't strip the symbol names.
160 # $1 = Target name
161 # $2 = Input name
163 define STRIP_RULE
164 all: $(OUTDIR)/$(1)$(HOST_EXT)
165 $(OUTDIR)/$(1)$(HOST_EXT): $(OUTDIR)/$(2)$(HOST_EXT)
166 $(call LOG,STRIP,$$@,$(STRIP) -S -o $$@ $$^)
167 endef
171 # Run standalone builds (command line builds outside of chrome)
173 ifdef STANDALONE
174 run: all
175 $(RUN_UNDER) $(OUTDIR)/$(TARGET)$(HOST_EXT) $(EXE_ARGS)
176 endif