Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / src / tools / hp_cxx.jam
1 # Copyright 2001 David Abrahams.
2 # Copyright 2004, 2005 Markus Schoepflin.
3 # Distributed under the Boost Software License, Version 1.0.
4 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
5
6 #
7 # HP CXX compiler
8 # See http://h30097.www3.hp.com/cplus/?jumpid=reg_R1002_USEN
9 #
10 #
11 # Notes on this toolset:
12 #
13 # - Because of very subtle issues with the default ansi mode, strict_ansi mode
14 #   is used for compilation. One example of things that don't work correctly in
15 #   the default ansi mode is overload resolution of function templates when
16 #   mixed with non-template functions.
17 #
18 # - For template instantiation "-timplicit_local" is used. Previously,
19 #   "-tlocal" has been tried to avoid the need for a template repository
20 #   but this doesn't work with manually instantiated templates. "-tweak"
21 #   has not been used to avoid the stream of warning messages issued by
22 #   ar or ld when creating a library or linking an application.
23 #
24 # - Debug symbols are generated with "-g3", as this works both in debug and
25 #   release mode. When compiling C++ code without optimization, we additionally
26 #   use "-gall", which generates full symbol table information for all classes,
27 #   structs, and unions. As this turns off optimization, it can't be used when
28 #   optimization is needed.
29 #
30
31 import feature generators common ;
32 import toolset : flags ;
33
34 feature.extend toolset : hp_cxx ;
35 feature.extend c++abi : cxxarm ;
36
37 # Inherit from Unix toolset to get library ordering magic.
38 toolset.inherit  hp_cxx : unix ;
39
40 generators.override hp_cxx.prebuilt : builtin.lib-generator ;
41 generators.override hp_cxx.prebuilt : builtin.prebuilt ;
42 generators.override hp_cxx.searched-lib-generator : searched-lib-generator ;
43
44
45 rule init ( version ? : command * : options * )
46 {
47     local condition = [ common.check-init-parameters hp_cxx : version $(version) ] ;
48     
49     local command = [ common.get-invocation-command hp_cxx : cxx : $(command) ] ;
50     
51     if $(command)
52     {
53         local root = [ common.get-absolute-tool-path $(command[-1]) ] ;
54
55         if $(root)
56         {
57             flags hp_cxx .root $(condition) : "\"$(root)\"/" ;
58         }        
59     }      
60     # If we can't find 'cxx' anyway, at least show 'cxx' in the commands
61     command ?= cxx ;
62         
63     common.handle-options hp_cxx : $(condition) : $(command) : $(options) ;               
64 }
65
66 generators.register-c-compiler hp_cxx.compile.c++ : CPP : OBJ : <toolset>hp_cxx ;
67 generators.register-c-compiler hp_cxx.compile.c : C : OBJ : <toolset>hp_cxx ;
68
69
70
71 # No static linking as far as I can tell.
72 # flags cxx LINKFLAGS <runtime-link>static : -bstatic ;
73 flags hp_cxx.compile OPTIONS <debug-symbols>on : -g3 ;
74 flags hp_cxx.compile OPTIONS <optimization>off/<debug-symbols>on : -gall ;
75 flags hp_cxx.link OPTIONS <debug-symbols>on : -g ;
76 flags hp_cxx.link OPTIONS <debug-symbols>off : -s ;
77
78 flags hp_cxx.compile OPTIONS <optimization>off : -O0 ;
79 flags hp_cxx.compile OPTIONS <optimization>speed/<inlining>on : -O2 ;
80 flags hp_cxx.compile OPTIONS <optimization>speed : -O2 ;
81
82 # This (undocumented) macro needs to be defined to get all C function
83 # overloads required by the C++ standard.
84 flags hp_cxx.compile.c++ OPTIONS : -D__CNAME_OVERLOADS ;
85
86 # Added for threading support
87 flags hp_cxx.compile OPTIONS <threading>multi : -pthread ;
88 flags hp_cxx.link OPTIONS <threading>multi : -pthread ;
89
90 flags hp_cxx.compile OPTIONS <optimization>space/<inlining>on : <inlining>size ;
91 flags hp_cxx.compile OPTIONS <optimization>space : -O1 ;
92 flags hp_cxx.compile OPTIONS <inlining>off : -inline none ;
93
94 # The compiler versions tried (up to V6.5-040) hang when compiling Boost code
95 # with full inlining enabled. So leave it at the default level for now.
96 #
97 # flags hp_cxx.compile OPTIONS <inlining>full : -inline all ;
98
99 flags hp_cxx.compile OPTIONS <profiling>on : -pg ;
100 flags hp_cxx.link OPTIONS <profiling>on : -pg ;
101
102 # Selection of the object model. This flag is needed on both the C++ compiler
103 # and linker command line.
104
105 # Unspecified ABI translates to '-model ansi' as most
106 # standard-conforming.
107 flags hp_cxx.compile.c++ OPTIONS <c++abi> : -model ansi : : hack-hack ;
108 flags hp_cxx.compile.c++ OPTIONS <c++abi>cxxarm : -model arm ;
109 flags hp_cxx.link OPTIONS <c++abi> : -model ansi : : hack-hack ;
110 flags hp_cxx.link OPTIONS <c++abi>cxxarm : -model arm ;
111
112 # Display a descriptive tag together with each compiler message. This tag can
113 # be used by the user to explicitely suppress the compiler message.
114 flags hp_cxx.compile OPTIONS : -msg_display_tag ;
115
116 flags hp_cxx.compile OPTIONS <cflags> ;
117 flags hp_cxx.compile.c++ OPTIONS <cxxflags> ;
118 flags hp_cxx.compile DEFINES <define> ;
119 flags hp_cxx.compile INCLUDES <include> ;
120 flags hp_cxx.link OPTIONS <linkflags> ;
121
122 flags hp_cxx.link LIBPATH <library-path> ;
123 flags hp_cxx.link LIBRARIES <library-file> ;
124 flags hp_cxx.link FINDLIBS-ST <find-static-library> ;
125 flags hp_cxx.link FINDLIBS-SA <find-shared-library> ;
126
127 flags hp_cxx.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ;
128
129 actions link bind LIBRARIES
130 {
131     $(CONFIG_COMMAND) -noimplicit_include $(OPTIONS) -o "$(<)" -L$(LIBPATH) "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) -lrt -lm
132 }
133
134 # When creating dynamic libraries, we don't want to be warned about unresolved
135 # symbols, therefore all unresolved symbols are marked as expected by
136 # '-expect_unresolved *'. This also mirrors the behaviour of the GNU tool
137 # chain.
138
139 actions link.dll bind LIBRARIES
140 {
141     $(CONFIG_COMMAND) -shared -expect_unresolved \* -noimplicit_include $(OPTIONS) -o "$(<[1])" -L$(LIBPATH)  "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) -lm
142 }
143
144
145 # Note: Relaxed ANSI mode (-std) is used for compilation because in strict ANSI
146 # C89 mode (-std1) the compiler doesn't accept C++ comments in C files. As -std
147 # is the default, no special flag is needed.
148 actions compile.c
149 {
150     $(.root:E=)cc -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
151 }
152
153 # Note: The compiler is forced to compile the files as C++ (-x cxx) because
154 # otherwise it will silently ignore files with no file extension.
155 #
156 # Note: We deliberately don't suppress any warnings on the compiler command
157 # line, the user can always do this in a customized toolset later on.
158
159 rule compile.c++
160 {
161     # We preprocess the TEMPLATE_DEPTH command line option here because we found
162     # no way to do it correctly in the actual action code. There we either get
163     # the -pending_instantiations parameter when no c++-template-depth property
164     # has been specified or we get additional quotes around
165     # "-pending_instantiations ".
166     local template-depth = [ on $(1) return $(TEMPLATE_DEPTH) ] ;
167     TEMPLATE_DEPTH on $(1) = "-pending_instantiations "$(template-depth) ;
168 }
169
170 actions compile.c++
171 {
172     $(CONFIG_COMMAND) -x cxx -c -std strict_ansi -nopure_cname -noimplicit_include -timplicit_local -ptr "$(<[1]:D)/cxx_repository" $(OPTIONS) $(TEMPLATE_DEPTH) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
173 }
174
175 # Always create archive from scratch. See the gcc toolet for rationale.
176 RM = [ common.rm-command ] ;
177 actions together piecemeal archive
178 {
179   $(RM) "$(<)"
180   ar rc $(<) $(>)
181 }