1 # /Object object : source ;
3 # Compile s a single _source_ file into _object_. The @Main and @Library
4 # rules use it to compile sources.
6 # Causes _source_ to be scanned for #include directives and calls @HdrRule
7 # to make all included files dependencies of _object_.
9 # Calls one of the following rules depending on the suffix to do the
13 # locate object and search for source, if wanted
16 MakeLocate $(<) : $(LOCATE_TARGET) ;
17 SEARCH on $(>) = $(SEARCH_SOURCE) ;
19 # Save HDRS for -I$(HDRS) on compile.
20 # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers
21 # in the .c file's directory, but generated .c files (from
22 # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly
23 # different from $(SEARCH_SOURCE).
24 HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ;
26 # handle #includes for source: Jam scans for headers with
27 # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
28 # with the scanned file as the target and the found headers
29 # as the sources. HDRSEARCH is the value of SEARCH used for
30 # the found header files. Finally, if jam must deal with
31 # header files of the same name in different directories,
32 # they can be distinguished with HDRGRIST.
34 # $(SEARCH_SOURCE:E) is where cc first looks for #include
35 # "foo.h" files. If the source file is in a distant directory,
36 # look there. Else, look in "" (the current directory).
38 HDRRULE on $(>) = HdrRule ;
39 HDRSCAN on $(>) = $(HDRPATTERN) ;
40 HDRSEARCH on $(>) = $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ;
41 HDRGRIST on $(>) = $(HDRGRIST) ;
43 # propagate target specific-defines
44 DEFINES on $(<) += $(DEFINES) ;
46 local _r = [ PreUserObject $(<) : $(>) ] ;
48 if $(WINDOZE) && $(>:S) = ".rc" {
49 WindozeResourceCompiler $(<) : $(>) ;
50 } else if $(WINDOZE) && $(>:S) = ".o" {
53 # if source is not .c, generate .c with specific rule
55 case .asm : As $(<) : $(>) ;
56 case .c : Cc $(<) : $(>) ;
57 case .C : C++ $(<) : $(>) ;
58 case .cc : C++ $(<) : $(>) ;
59 case .cpp : C++ $(<) : $(>) ;
60 case .cxx : C++ $(<) : $(>) ;
61 case .c++ : C++ $(<) : $(>) ;
62 case .C++ : C++ $(<) : $(>) ;
63 case .m : ObjC $(<) : $(>) ;
64 #case .d : Dc $(<) : $(>) ;
65 case .l : Cc $(<) : $(<:S=.c) ;
66 Lex $(<:S=.c) : $(>) ;
67 case .s : As $(<) : $(>) ;
68 case .y : Cc $(<) : $(<:S=$(YACCGEN)) ;
69 Yacc $(<:S=$(YACCGEN)) : $(>) ;
70 case .h : return "" ; # do nothing
71 case .hpp : return "" ; # do nothing
72 case .o : return "" ; # do nothing
73 case * : UserObject $(<) : $(>) ;
80 # /ObjectCcFlags sources : flags ;
82 # this rule is used to add compiler flags to the compilation of
83 # specific C sources files.
86 CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
90 # /ObjectC++Flags sources : flags ;
92 # this rule is used to add compiler flags to the compilation of
93 # specific C++ source files
96 C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
100 rule ObjectObjCFlags {
101 OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
105 # ObjectNoAliasing filelist ;
106 # turn off aliasing optimization for specified files
107 # works only for gcc/g++
108 rule ObjectNoAliasing {
109 if $(OPTIM_NOALIAS) {
110 local _f = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
111 CCFLAGS on $(_f) += $(OPTIM_NOALIAS) ;
112 C++FLAGS on $(_f) += $(OPTIM_NOALIAS) ;
113 OBJCFLAGS on $(_f) += $(OPTIM_NOALIAS) ;
118 # /ObjectDefines objects : macros ;
120 # this rule is used to add macro defines to the compilation of
121 # specific C and C++ source files
124 # must reformat CCDEFS according to current defines
125 local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
127 DEFINES on $(s) += $(>) ;
128 CCDEFS on $(s) = [ on $(s) FDefines $(DEFINES) ] ;
132 # /ObjectHdrs sources : paths ;
134 # this rule is used to add include paths to the compilation of
135 # specific C and C++ source files
138 # Add to HDRS for HdrScan's benefit.
139 # must reformat CCHDRS according to headers
140 local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
142 HDRS on $(s) += $(>) ;
143 CCHDRS on $(s) = [ on $(s) FIncludes $(HDRS) ] ;
149 # this rule is used to compile one or more sources into object files.
150 # do not call it directly, it is used by the Main and Library rules
156 for _i in [ FGristFiles $(<) ] {
157 Object $(_i:S=$(SUFOBJ)) : $(_i) ;
158 Depends obj : $(_i:S=$(SUFOBJ)) ;
165 # this rule is used to compile one or more sources into 'shared object
166 # files'. This means object files used to build either DLLs or Unix shared
169 # do not call this rule directly, it is called by SharedLibrary automatically
172 # temporarily override SUFOBJ with $(SUFOBJSHR) to
173 local SUFOBJ = $(SUFOBJSHR) ;
175 # call the normal Objects rule
178 # add the compiler-specific position-independent-code flag where needed
179 ObjectCcFlags $(<) : $(PICFLAGS) ;
181 # change the compiler invokation for all these objects
182 # to use Libtool on Unix systems. We explicitely disable the
183 # generation of static objects here
184 #!LIBTOOL!# if $(UNIX) {
185 #!LIBTOOL!# #libtool on $(<:S=$(SUFOBJ)) = [ LibToolFind ] ;
186 #!LIBTOOL!# if $(K8_USE_LIBTOOL) {
187 #!LIBTOOL!# local libtool = [ LibToolFind ] ;
188 #!LIBTOOL!# CC on $(<:S=$(SUFOBJ)) = "$(libtool) --mode=compile $(CC:J= ) -dynamic" ;
189 #!LIBTOOL!# C++ on $(<:S=$(SUFOBJ)) = "$(libtool) --mode=compile $(C++:J= ) -dynamic" ; #k8:?