Add ICU message format support
[chromium-blink-merge.git] / native_client_sdk / src / tools / host_gcc.mk
blobc9ab5e58ffcb37d51d3be47e4634cb5532b93b6f
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
10 ifdef ASAN
11 CLANG = 1
12 endif
14 ifdef TSAN
15 CLANG = 1
16 endif
19 # Macros for TOOLS
21 # We use the C++ compiler for everything and then use the -Wl,-as-needed flag
22 # in the linker to drop libc++ unless it's actually needed.
24 ifdef CLANG
25 CC = clang
26 CXX = clang++
27 endif
29 ifdef NACL_COMPILER_PREFIX
30 CC = $(NACL_COMPILER_PREFIX) $(CC)
31 CXX = $(NACL_COMPILER_PREFIX) $(CXX)
32 endif
34 LINK ?= $(CXX)
35 AR ?= ar
36 ARFLAGS = -crs
37 STRIP ?= strip
39 ifeq (,$(findstring gcc,$(shell $(WHICH) gcc)))
40 $(warning To skip the host build use:)
41 $(warning "make all_versions NO_HOST_BUILDS=1")
42 $(error Unable to find gcc in PATH while building Host build)
43 endif
45 HOST_WARNINGS ?= -Wno-long-long -Wall -Werror
46 HOST_CFLAGS = -fPIC -pthread $(HOST_WARNINGS) -I$(NACL_SDK_ROOT)/include
48 ifneq ($(OSNAME),mac)
49 # Adding -Wl,-Bsymbolic means that symbols defined within the module are always
50 # used by the module, and not shadowed by symbols already loaded in, for
51 # exmaple, libc. Without this the libc symbols (or anything injected with
52 # LD_PRELOAD will take precedence).
53 # -pthread is not needed on mac (libpthread is a symlink to libSystem) and
54 # in fact generated a warning if passed at link time.
55 HOST_LDFLAGS ?= -Wl,-Map,$(OUTDIR)/$(TARGET).map -Wl,-Bsymbolic -pthread
56 HOST_CFLAGS += -I$(NACL_SDK_ROOT)/include/mac
57 else
58 HOST_LDFLAGS ?= -Wl,-map -Wl,$(OUTDIR)/$(TARGET).map
59 HOST_CFLAGS += -I$(NACL_SDK_ROOT)/include/linux
60 endif
62 ifdef ASAN
63 HOST_CFLAGS += -fsanitize=address
64 HOST_LDFLAGS += -pie -fsanitize=address
65 endif
67 ifdef TSAN
68 HOST_CFLAGS += -fsanitize=thread
69 HOST_LDFLAGS += -pie -fsanitize=thread
70 endif
73 # Individual Macros
75 # $1 = Source name
76 # $2 = Compile flags
78 define C_COMPILER_RULE
79 -include $(call SRC_TO_DEP,$(1))
80 $(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
81 $(call LOG,CC ,$$@,$(CC) -o $$@ -c $$< $(POSIX_CFLAGS) $(HOST_CFLAGS) $(CFLAGS) $(2))
82 @$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
83 endef
85 define CXX_COMPILER_RULE
86 -include $(call SRC_TO_DEP,$(1))
87 $(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
88 $(call LOG,CXX ,$$@,$(CXX) -o $$@ -c $$< $(POSIX_CFLAGS) $(HOST_CFLAGS) $(CXXFLAGS) $(2))
89 @$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
90 endef
93 # Compile Macro
95 # $1 = Source name
96 # $2 = POSIX compiler flags
97 # $3 = VC compiler flags (unused)
99 define COMPILE_RULE
100 ifeq ($(suffix $(1)),.c)
101 $(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)))
102 else
103 $(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)))
104 endif
105 endef
109 # SO Macro
111 # $1 = Target name
112 # $2 = list of source files
114 define SO_RULE
115 $(error 'Shared libraries not supported by Host')
116 endef
120 # LIB Macro
122 # $1 = Target name
123 # $2 = List of source files
125 define LIB_RULE
126 $(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(OSNAME)_host/$(CONFIG_DIR)/lib$(1).a
127 @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
129 all: $(LIBDIR)/$(OSNAME)_host/$(CONFIG_DIR)/lib$(1).a
130 $(LIBDIR)/$(OSNAME)_host/$(CONFIG_DIR)/lib$(1).a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src)))
131 $(MKDIR) -p $$(dir $$@)
132 $(RM) -f $$@
133 $(call LOG,LIB,$$@,$(AR) $(ARFLAGS) $$@ $$^)
134 endef
138 # Link Macro
140 # $1 = Target name
141 # $2 = List of inputs
142 # $3 = List of libs
143 # $4 = List of deps
144 # $5 = List of lib dirs
145 # $6 = Linker flags
147 ifdef STANDALONE
148 define LINKER_RULE
149 all: $(1)
150 $(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
151 $(call LOG,LINK,$$@,$(LINK) -o $(1) $(2) $(HOST_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(OSNAME)_host/$(CONFIG_DIR) -L$(path)/$(OSNAME)_host/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(6))
152 endef
153 else
154 define LINKER_RULE
155 all: $(1)
156 $(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
157 $(call LOG,LINK,$$@,$(LINK) -shared -o $(1) $(2) $(HOST_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(OSNAME)_host/$(CONFIG_DIR) -L$(path)/$(OSNAME)_host/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(6))
158 endef
159 endif
163 # Link Macro
165 # $1 = Target Name
166 # $2 = List of source files
167 # $3 = List of LIBS
168 # $4 = List of DEPS
169 # $5 = POSIX linker flags
170 # $6 = VC linker flags
172 define LINK_RULE
173 $(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(call SRC_TO_OBJ,$(src))),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5))
174 endef
176 all: $(LIB_LIST) $(DEPS_LIST)
180 # Strip Macro
181 # The host build makes shared libraries, so the best we can do is -S, which
182 # only strip debug symbols. We don't strip the symbol names.
184 # $1 = Target name
185 # $2 = Input name
187 define STRIP_RULE
188 all: $(OUTDIR)/$(1)$(HOST_EXT)
189 $(OUTDIR)/$(1)$(HOST_EXT): $(OUTDIR)/$(2)$(HOST_EXT)
190 $(call LOG,STRIP,$$@,$(STRIP) -S -o $$@ $$^)
191 endef
195 # Run standalone builds (command line builds outside of chrome)
197 ifdef STANDALONE
198 run: all
199 $(RUN_UNDER) $(OUTDIR)/$(TARGET)$(HOST_EXT) $(EXE_ARGS)
200 endif