cosmetix in Jambase: use single-quoted string where appropriate
[k8jam.git] / defaults / Jambase.object
blobe14ea3682577d6614a72823761f40f971d1341c8
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
14 # /Object object : source : exename ;
16 # Compile s a single _source_ file into _object_. The @Main and @Library
17 # rules use it to compile sources.
19 # Causes _source_ to be scanned for #include directives and calls @HdrRule
20 # to make all included files dependencies of _object_.
22 # Calls one of the following rules depending on the suffix to do the
23 # actual compilation:
25 rule Object {
26   # locate object and search for source, if wanted
27   local _r = [ PreUserObject $(<) : $(>) : $(3) ] ;
28   if ! $(_r) {
29     Clean clean : $(<) ;
30     MakeLocate $(<) : $(LOCATE_TARGET) ;
31     SEARCH on $(>) = $(SEARCH_SOURCE) ;
33     # Save HDRS for -I$(HDRS) on compile.
34     # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers
35     # in the .c file's directory, but generated .c files (from
36     # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly
37     # different from $(SEARCH_SOURCE).
38     HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ;
40     # handle #includes for source: Jam scans for headers with
41     # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
42     # with the scanned file as the target and the found headers
43     # as the sources.  HDRSEARCH is the value of SEARCH used for
44     # the found header files.  Finally, if jam must deal with
45     # header files of the same name in different directories,
46     # they can be distinguished with HDRGRIST.
48     # $(SEARCH_SOURCE:E) is where cc first looks for #include
49     # "foo.h" files.  If the source file is in a distant directory,
50     # look there.  Else, look in "" (the current directory).
52     HDRRULE on $(>) = HdrRule ;
53     HDRSCAN on $(>) = $(HDRPATTERN) ;
54     HDRSEARCH on $(>) = $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ;
55     HDRGRIST on $(>) = $(HDRGRIST) ;
57     # propagate target specific-defines
58     DEFINES on $(<) += $(DEFINES) ;
60     switch $(>:S) {
61       case .asm : As $(<) : $(>) ;
62       case .c   : Cc $(<) : $(>) ;
63       case .S   : Cc $(<) : $(>) ;
64       # c++ are soooo many...
65       case .C   : C++ $(<) : $(>) ;
66       case .cc  : C++ $(<) : $(>) ;
67       case .cpp : C++ $(<) : $(>) ;
68       case .cxx : C++ $(<) : $(>) ;
69       case .c++ : C++ $(<) : $(>) ;
70       case .C++ : C++ $(<) : $(>) ;
71       #
72       case .m   : ObjC $(<) : $(>) ;
73       # lex
74       case .l   : Cc $(<) : $(<:S=.c) ;
75                   Lex $(<:S=.c) : $(>) ;
76       case .s   : As $(<) : $(>) ;
77       # yacc
78       case .y   : Cc $(<) : $(<:S=$(YACCGEN)) ;
79                   Yacc $(<:S=$(YACCGEN)) : $(>) ;
80       # headers
81       case .h   : return ;
82       case .hpp : return ;
83       case .o   : return ;
84       # windoze resource file
85       case .rc  : if $(WINDOZE) { WindozeResourceCompiler $(<) : $(>) ; }
86                   else -do-UserObject $(<) : $(>) : $(3) ;
87       # other shit
88       case *    : -do-UserObject $(<) : $(>) : $(3) ;
89     }
90     return ;
91   }
92   return $(_r) ;
96 # /ObjectCcFlags  sources : flags ;
98 # this rule is used to add compiler flags to the compilation of
99 # specific C sources files.
101 rule ObjectCcFlags {
102   CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
106 # /ObjectC++Flags  sources : flags ;
108 # this rule is used to add compiler flags to the compilation of
109 # specific C++ source files
111 rule ObjectC++Flags {
112   C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
116 rule ObjectObjCFlags {
117   OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
121 # ObjectNoAliasing filelist ;
122 # turn off aliasing optimization for specified files
123 # works only for gcc/g++
124 rule ObjectNoAliasing {
125   if $(OPTIM_NOALIAS) {
126     local _f = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
127     CCFLAGS on $(_f) += $(OPTIM_NOALIAS) ;
128     C++FLAGS on $(_f) += $(OPTIM_NOALIAS) ;
129     OBJCFLAGS on $(_f) += $(OPTIM_NOALIAS) ;
130   }
134 # /ObjectDefines  objects : macros ;
136 # this rule is used to add macro defines to the compilation of
137 # specific C and C++ source files
139 rule ObjectDefines {
140   # must reformat CCDEFS according to current defines
141   local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
143   DEFINES on $(s) += $(>) ;
144   CCDEFS on $(s) = [ on $(s) FDefines $(DEFINES) ] ;
148 # /ObjectHdrs  sources : paths ;
150 # this rule is used to add include paths to the compilation of
151 # specific C and C++ source files
153 rule ObjectHdrs {
154   # Add to HDRS for HdrScan's benefit.
155   # must reformat CCHDRS according to headers
156   local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
158   HDRS on $(s) += $(>) ;
159   CCHDRS on $(s) = [ on $(s) FIncludes $(HDRS) ] ;
163 # /Objects sources : targets : exename ;
165 # this rule is used to compile one or more sources into object files.
166 # do not call it directly, it is used by the Main and Library rules
167 # automatically
169 rule Objects {
170   local _i _f _t ;
172   if ! $(2) || $(2) = 'obj' { _t = obj ; } else { _t = $(3)_obj ; }
173   for _i in [ FGristFiles $(<) ] {
174     #Echo 'Objects:' "$(_i)" '-->' "$(_i:S=$(SUFOBJ))";
175     #Echo " $(_t)" ':' "$(_i:S=$(SUFOBJ))" ;
176     if ! [ Object $(_i:S=$(SUFOBJ)) : $(_i) : $(3) ] {
177       Depends $(_t) : $(_i:S=$(SUFOBJ)) ;
178       #Echo 'DD' $(_t) ':' $(_i:S=$(SUFOBJ)) ;
179     }
180   }
182   if $(_t) != 'obj' {
183     #Echo "$(3)" 'depends of' "$(_t)" ;
184     Depends $(3) : $(_t) ;
185   }
189 # /SharedObjects
191 # this rule is used to compile one or more sources into 'shared object
192 # files'. This means object files used to build either DLLs or Unix shared
193 # libraries.
195 # do not call this rule directly, it is called by SharedLibrary automatically
197 rule SharedObjects {
198   # temporarily override SUFOBJ with $(SUFOBJSHR) to
199   local SUFOBJ = $(SUFOBJSHR) ;
201   # call the normal Objects rule
202   Objects $(<) ;
204   # add the compiler-specific position-independent-code flag  where needed
205   ObjectCcFlags $(<) : $(PICFLAGS) ;