[MacViews] Show comboboxes with a native NSMenu
[chromium-blink-merge.git] / native_client_sdk / src / tools / nacl_llvm.mk
blob46b2a043eb1ed04329d1620905f21bc60c3bebf3
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
11 # Paths to Tools
13 PNACL_CC := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=cc)
14 PNACL_CXX := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=c++)
15 PNACL_LINK := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=c++)
16 PNACL_LIB := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=ar)
17 PNACL_STRIP := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=strip)
18 PNACL_FINALIZE := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=finalize)
19 PNACL_TRANSLATE := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) --tool=translate)
22 # Compile Macro
24 # $1 = Source name
25 # $2 = Compile flags
26 # $3 = Include directories
28 define C_COMPILER_RULE
29 -include $(call SRC_TO_DEP,$(1))
30 $(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
31 $(call LOG,CC ,$$@,$(PNACL_CC) -o $$@ -c $$< $(POSIX_CFLAGS) $(NACL_CFLAGS) $(CFLAGS) $(2))
32 @$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
33 endef
35 define CXX_COMPILER_RULE
36 -include $(call SRC_TO_DEP,$(1))
37 $(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
38 $(call LOG,CXX ,$$@,$(PNACL_CXX) -o $$@ -c $$< $(POSIX_CFLAGS) $(NACL_CFLAGS) $(CXXFLAGS) $(2))
39 @$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
40 endef
43 # $1 = Source Name
44 # $2 = POSIX Compile Flags
45 # $3 = Include Directories
46 # $4 = VC Flags (unused)
47 define COMPILE_RULE
48 ifeq ($(suffix $(1)),.c)
49 $(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3))
50 else
51 $(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3))
52 endif
53 endef
57 # SO Macro
59 # $1 = Target Name
60 # $2 = List of Sources
63 define SO_RULE
64 $(error 'Shared libraries not supported by PNaCl')
65 endef
69 # LIB Macro
71 # $1 = Target Name
72 # $2 = List of Sources
73 # $3 = POSIX Link Flags
74 # $4 = VC Link Flags (unused)
75 define LIB_RULE
76 $(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a
77 @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
79 all: $(LIBDIR)/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a
80 $(LIBDIR)/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src)))
81 $(MKDIR) -p $$(dir $$@)
82 $(RM) -f $$@
83 $(call LOG,LIB,$$@,$(PNACL_LIB) -cr $$@ $$^ $(3))
84 endef
88 # Specific Link Macro
90 # $1 = Target Name
91 # $2 = List of inputs
92 # $3 = List of libs
93 # $4 = List of deps
94 # $5 = List of lib dirs
95 # $6 = Other Linker Args
97 define LINKER_RULE
98 all: $(1).pexe
99 $(1).pexe: $(1).bc
100 $(call LOG,FINALIZE,$$@,$(PNACL_FINALIZE) -o $$@ $$^)
102 $(1).bc: $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
103 $(call LOG,LINK,$$@,$(PNACL_LINK) -o $$@ $(2) $(PNACL_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/pnacl/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(6))
105 $(1)_x86_32.nexe: $(1).bc
106 $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-32 $$^ -o $$@)
108 $(1)_x86_64.nexe: $(1).bc
109 $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-64 $$^ -o $$@)
111 $(1)_arm.nexe: $(1).bc
112 $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch arm $$^ -o $$@)
113 endef
117 # Generalized Link Macro
119 # $1 = Target Name
120 # $2 = List of Sources
121 # $3 = List of LIBS
122 # $4 = List of DEPS
123 # $5 = POSIX Linker Switches
124 # $6 = VC Linker Switches
126 define LINK_RULE
127 $(call LINKER_RULE,$(OUTDIR)/$(1),$(foreach src,$(2),$(call SRC_TO_OBJ,$(src))),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5))
128 endef
132 # Strip Macro
134 # NOTE: pnacl-strip does not really do much for finalized pexes (in a
135 # sense, they are already stripped), but set this rule up for uniformity.
137 # $1 = Target Name
138 # $2 = Input Name
140 define STRIP_RULE
141 all: $(OUTDIR)/$(1).pexe
142 $(OUTDIR)/$(1).pexe: $(OUTDIR)/$(2).pexe
143 $(call LOG,STRIP,$$@,$(PNACL_STRIP) $$^ -o $$@)
145 $(OUTDIR)/$(1)_x86_32.nexe: $(OUTDIR)/$(2)_x86_32.nexe
146 $(call LOG,STRIP,$$@,$(PNACL_STRIP) $$^ -o $$@)
148 $(OUTDIR)/$(1)_x86_64.nexe: $(OUTDIR)/$(2)_x86_64.nexe
149 $(call LOG,STRIP,$$@,$(PNACL_STRIP) $$^ -o $$@)
151 $(OUTDIR)/$(1)_arm.nexe: $(OUTDIR)/$(2)_arm.nexe
152 $(call LOG,STRIP,$$@,$(PNACL_STRIP) $$^ -o $$@)
153 endef
157 # NMF Manifest generation
159 # Use the python script create_nmf to scan the binaries for dependencies using
160 # objdump. Pass in the (-L) paths to the default library toolchains so that we
161 # can find those libraries and have it automatically copy the files (-s) to
162 # the target directory for us.
164 # $1 = Target Name (the basename of the nmf)
165 # $2 = Additional create_nmf.py arguments
167 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
169 EXECUTABLES=$(OUTDIR)/$(1).pexe $(OUTDIR)/$(1)_unstripped.bc
171 define NMF_RULE
172 all: $(OUTDIR)/$(1).nmf
173 $(OUTDIR)/$(1).nmf: $(EXECUTABLES)
174 $(call LOG,CREATE_NMF,$$@,$(NMF) -o $$@ $$^ -s $(OUTDIR) $(2))
175 endef
178 # HTML file generation
180 CREATE_HTML := python $(NACL_SDK_ROOT)/tools/create_html.py
182 define HTML_RULE
183 all: $(OUTDIR)/$(1).html
184 $(OUTDIR)/$(1).html: $(EXECUTABLES)
185 $(call LOG,CREATE_HTML,$$@,$(CREATE_HTML) -o $$@ $$^)
186 endef
189 ifdef STANDALONE
190 run: $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe
191 ifndef NACL_ARCH
192 $(error Cannot run in sel_ldr unless $$NACL_ARCH is set)
193 endif
194 $(SEL_LDR_PATH) $(SEL_LDR_ARGS) $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe -- $(EXE_ARGS)
196 debug: $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe
197 ifndef NACL_ARCH
198 $(error Cannot run in sel_ldr unless $$NACL_ARCH is set)
199 endif
200 $(SEL_LDR_PATH) -d $(SEL_LDR_ARGS) $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe -- $(EXE_ARGS)
201 endif