OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # | 5 # |
6 # GNU Make based build file. For details on GNU Make see: | 6 # GNU Make based build file. For details on GNU Make see: |
7 # http://www.gnu.org/software/make/manual/make.html | 7 # http://www.gnu.org/software/make/manual/make.html |
8 # | 8 # |
9 # | 9 # |
10 | 10 |
11 | 11 |
12 # | 12 # |
13 # Paths to Tools | 13 # Paths to Tools |
14 # | 14 # |
15 PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang -c | 15 PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang -c |
16 PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ -c | 16 PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ -c |
17 PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ | 17 PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ |
18 PNACL_LIB?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-ar r | 18 PNACL_LIB?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-ar r |
19 | 19 |
20 | 20 |
21 # | 21 # |
22 # Compile Macro | 22 # Compile Macro |
23 # | 23 # |
24 # $1 = Source Name | 24 # $1 = Source Name |
25 # $2 = Compile Flags | 25 # $2 = Compile Flags |
26 # $3 = Include Directories | 26 # $3 = Include Directories |
27 # | 27 # |
28 define C_COMPILER_RULE | 28 define C_COMPILER_RULE |
29 -include $(OUTDIR)/$(basename $(1))_pnacl.d | 29 -include $(call SRC_TO_DEP,$(1),_pnacl) |
30 $(OUTDIR)/$(basename $(1))_pnacl.o : $(1) $(TOP_MAKE) | $(dir $(OUTDIR)/$(basena me $(1)))dir.stamp | 30 $(call SRC_TO_OBJ,$(1),_pnacl): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)) )dir.stamp |
31 $(call LOG,CC,$$@,$(PNACL_CC) -o $$@ -c $$< $(POSIX_FLAGS) $(2) $(NACL_C FLAGS)) | 31 $(call LOG,CC,$$@,$(PNACL_CC) -o $$@ -c $$< $(POSIX_FLAGS) $(2) $(NACL_C FLAGS)) |
32 endef | 32 endef |
33 | 33 |
34 define CXX_COMPILER_RULE | 34 define CXX_COMPILER_RULE |
35 -include $(OUTDIR)/$(basename $(1))_pnacl.d | 35 -include $(call SRC_TO_DEP,$(1)) |
36 $(OUTDIR)/$(basename $(1))_pnacl.o : $(1) $(TOP_MAKE) | $(dir $(OUTDIR)/$(basena me $(1)))dir.stamp | 36 $(call SRC_TO_OBJ,$(1),_pnacl): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)) )dir.stamp |
37 $(call LOG,CXX,$$@,$(PNACL_CXX) -o $$@ -c $$< $(POSIX_FLAGS) $(2) $(NACL _CFLAGS)) | 37 $(call LOG,CXX,$$@,$(PNACL_CXX) -o $$@ -c $$< $(POSIX_FLAGS) $(2) $(NACL _CFLAGS)) |
38 endef | 38 endef |
39 | 39 |
40 | 40 |
41 # $1 = Source Name | 41 # $1 = Source Name |
42 # $2 = POSIX Compile Flags | 42 # $2 = POSIX Compile Flags |
43 # $3 = Include Directories | 43 # $3 = Include Directories |
44 # $4 = VC Flags (unused) | 44 # $4 = VC Flags (unused) |
45 define COMPILE_RULE | 45 define COMPILE_RULE |
46 ifeq ('.c','$(suffix $(1))') | 46 ifeq ($(suffix $(1)),.c) |
47 $(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3)) | 47 $(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3)) |
48 else | 48 else |
49 $(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3)) | 49 $(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3)) |
50 endif | 50 endif |
51 endef | 51 endef |
52 | 52 |
53 | 53 |
54 # | 54 # |
55 # SO Macro | 55 # SO Macro |
56 # | 56 # |
57 # $1 = Target Name | 57 # $1 = Target Name |
58 # $2 = List of Sources | 58 # $2 = List of Sources |
59 # | 59 # |
60 # | 60 # |
61 define SO_RULE | 61 define SO_RULE |
62 $(error 'Shared libraries not supported by PNaCl') | 62 $(error 'Shared libraries not supported by PNaCl') |
63 endef | 63 endef |
64 | 64 |
65 | 65 |
66 # | 66 # |
67 # LIB Macro | 67 # LIB Macro |
68 # | 68 # |
69 # $1 = Target Name | 69 # $1 = Target Name |
70 # $2 = List of Sources | 70 # $2 = List of Sources |
71 # $3 = POSIX Link Flags | 71 # $3 = POSIX Link Flags |
72 # $4 = VC Link Flags (unused) | 72 # $4 = VC Link Flags (unused) |
73 define LIB_RULE | 73 define LIB_RULE |
74 $(STAMPDIR)/$(1).stamp : $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a | 74 $(STAMPDIR)/$(1).stamp: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a |
75 @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp | 75 @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp |
76 | 76 |
77 all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a | 77 all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a |
78 $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(OUT DIR)/$(basename $(src))_pnacl.o) | 78 $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_pnacl)) |
79 $(MKDIR) -p $$(dir $$@) | 79 $(MKDIR) -p $$(dir $$@) |
80 $(call LOG,LIB,$$@,$(PNACL_LIB) $$@ $$^ $(3)) | 80 $(call LOG,LIB,$$@,$(PNACL_LIB) $$@ $$^ $(3)) |
81 endef | 81 endef |
82 | 82 |
83 | 83 |
84 # | 84 # |
85 # Specific Link Macro | 85 # Specific Link Macro |
86 # | 86 # |
87 # $1 = Target Name | 87 # $1 = Target Name |
88 # $2 = List of inputs | 88 # $2 = List of inputs |
89 # $3 = List of libs | 89 # $3 = List of libs |
90 # $4 = List of deps | 90 # $4 = List of deps |
91 # $5 = List of lib dirs | 91 # $5 = List of lib dirs |
92 # $6 = Other Linker Args | 92 # $6 = Other Linker Args |
93 # | 93 # |
94 define LINKER_RULE | 94 define LINKER_RULE |
95 all: $(1) | 95 all: $(1) |
96 $(1) : $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) | 96 $(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) |
97 $(call LOG,LINK,$$@,$(PNACL_LINK) -o $(1) $(2) $(foreach path,$(5),-L$(p ath)/pnacl/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(6)) | 97 $(call LOG,LINK,$$@,$(PNACL_LINK) -o $(1) $(2) $(foreach path,$(5),-L$(p ath)/pnacl/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(6)) |
98 endef | 98 endef |
99 | 99 |
100 | 100 |
101 # | 101 # |
102 # Generalized Link Macro | 102 # Generalized Link Macro |
103 # | 103 # |
104 # $1 = Target Name | 104 # $1 = Target Name |
105 # $2 = List of Sources | 105 # $2 = List of Sources |
106 # $3 = List of LIBS | 106 # $3 = List of LIBS |
107 # $4 = List of DEPS | 107 # $4 = List of DEPS |
108 # $5 = POSIX Linker Switches | 108 # $5 = POSIX Linker Switches |
109 # $6 = VC Linker Switches | 109 # $6 = VC Linker Switches |
110 # | 110 # |
111 define LINK_RULE | 111 define LINK_RULE |
112 $(call LINKER_RULE,$(OUTDIR)/$(1).pexe,$(foreach src,$(2),$(OUTDIR)/$(basename $ (src))_pnacl.o),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5)) | 112 $(call LINKER_RULE,$(OUTDIR)/$(1).pexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(sr c),_pnacl)),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5)) |
113 endef | 113 endef |
114 | 114 |
115 | 115 |
116 | 116 |
117 # | 117 # |
118 # NMF Manifiest generation | 118 # NMF Manifiest generation |
119 # | 119 # |
120 # Use the python script create_nmf to scan the binaries for dependencies using | 120 # Use the python script create_nmf to scan the binaries for dependencies using |
121 # objdump. Pass in the (-L) paths to the default library toolchains so that we | 121 # objdump. Pass in the (-L) paths to the default library toolchains so that we |
122 # can find those libraries and have it automatically copy the files (-s) to | 122 # can find those libraries and have it automatically copy the files (-s) to |
123 # the target directory for us. | 123 # the target directory for us. |
124 # | 124 # |
125 # $1 = Target Name (the basename of the nmf | 125 # $1 = Target Name (the basename of the nmf |
126 # $2 = Additional create_nmf.py arguments | 126 # $2 = Additional create_nmf.py arguments |
127 # | 127 # |
128 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py | 128 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py |
129 | 129 |
130 define NMF_RULE | 130 define NMF_RULE |
131 all:$(OUTDIR)/$(1).nmf | 131 all:$(OUTDIR)/$(1).nmf |
132 $(OUTDIR)/$(1).nmf : $(OUTDIR)/$(1).pexe | 132 $(OUTDIR)/$(1).nmf : $(OUTDIR)/$(1).pexe |
133 $(call LOG,CREATE_NMF,$$@,$(NMF) -o $$@ $$^ -s $(OUTDIR) $(2)) | 133 $(call LOG,CREATE_NMF,$$@,$(NMF) -o $$@ $$^ -s $(OUTDIR) $(2)) |
134 endef | 134 endef |
135 | |
noelallen1
2013/03/07 20:06:25
blank line.
| |
136 | |
OLD | NEW |