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
26 # locate object and search for source, if wanted
27 local _r = [ PreUserObject $(<) : $(>) : $(3) ] ;
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) ;
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++ $(<) : $(>) ;
72 case .m : ObjC $(<) : $(>) ;
74 case .d : Gdc $(<) : $(>) ;
76 case .l : Cc $(<) : $(<:S=.c) ;
77 Lex $(<:S=.c) : $(>) ;
78 case .s : As $(<) : $(>) ;
80 case .y : Cc $(<) : $(<:S=$(YACCGEN)) ;
81 Yacc $(<:S=$(YACCGEN)) : $(>) ;
86 # windoze resource file
87 case .rc : if $(WINDOZE) { WindozeResourceCompiler $(<) : $(>) ; }
88 else -do-UserObject $(<) : $(>) : $(3) ;
90 case * : -do-UserObject $(<) : $(>) : $(3) ;
98 # /ObjectCcFlags sources : flags ;
100 # this rule is used to add compiler flags to the compilation of
101 # specific C sources files.
104 CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
108 # /ObjectC++Flags sources : flags ;
110 # this rule is used to add compiler flags to the compilation of
111 # specific C++ source files
113 rule ObjectC++Flags {
114 C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
118 rule ObjectObjCFlags {
119 OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
124 GDCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
128 rule ObjectDInlineFlags {
129 GDCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(GDC_INLINE_FLAGS) ;
133 # ObjectNoAliasing filelist ;
134 # turn off aliasing optimization for specified files
135 # works only for gcc/g++
136 rule ObjectNoAliasing {
137 if $(OPTIM_NOALIAS) {
138 local _f = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
139 CCFLAGS on $(_f) += $(OPTIM_NOALIAS) ;
140 C++FLAGS on $(_f) += $(OPTIM_NOALIAS) ;
141 OBJCFLAGS on $(_f) += $(OPTIM_NOALIAS) ;
146 # /ObjectDefines objects : macros ;
148 # this rule is used to add macro defines to the compilation of
149 # specific C and C++ source files
152 # must reformat CCDEFS according to current defines
153 local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
155 DEFINES on $(s) += $(>) ;
156 CCDEFS on $(s) = [ on $(s) FDefines $(DEFINES) ] ;
160 # /ObjectHdrs sources : paths ;
162 # this rule is used to add include paths to the compilation of
163 # specific C and C++ source files
166 # Add to HDRS for HdrScan's benefit.
167 # must reformat CCHDRS according to headers
168 local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
170 HDRS on $(s) += $(>) ;
171 CCHDRS on $(s) = [ on $(s) FIncludes $(HDRS) ] ;
175 # /Objects sources : targets : exename ;
177 # this rule is used to compile one or more sources into object files.
178 # do not call it directly, it is used by the Main and Library rules
184 if ! $(2) || $(2) = 'obj' { _t = obj ; } else { _t = $(3)_obj ; }
185 for _i in [ FGristFiles $(<) ] {
186 #Echo 'Objects:' "$(_i)" '-->' "$(_i:S=$(SUFOBJ))";
187 #Echo " $(_t)" ':' "$(_i:S=$(SUFOBJ))" ;
188 if ! [ Object $(_i:S=$(SUFOBJ)) : $(_i) : $(3) ] {
189 Depends $(_t) : $(_i:S=$(SUFOBJ)) ;
190 #Echo 'DD' $(_t) ':' $(_i:S=$(SUFOBJ)) ;
195 #Echo "$(3)" 'depends of' "$(_t)" ;
196 Depends $(3) : $(_t) ;
203 # this rule is used to compile one or more sources into 'shared object
204 # files'. This means object files used to build either DLLs or Unix shared
207 # do not call this rule directly, it is called by SharedLibrary automatically
210 # temporarily override SUFOBJ with $(SUFOBJSHR) to
211 local SUFOBJ = $(SUFOBJSHR) ;
213 # call the normal Objects rule
216 # add the compiler-specific position-independent-code flag where needed
217 ObjectCcFlags $(<) : $(PICFLAGS) ;