Jambase cleanup; removed GNUstep utils (not really working anyway)
[k8jam.git] / defaults / Jambase.main
blob0efd3cb7160f0872ae747778b06bd88197224245
1 # $(1): image
2 # $(2): target list
3 # returns "_" for 'selftarget'
4 rule --MainNormalizeTargets-- {
5   local _ctt = $(2) ;
6   if ! $(_ctt) { _ctt = exe ; }
7   else if $(_ctt) = $(1) { _ctt = "_" ; }
8   return $(_ctt) ;
12 # /--MainFromObjects-- image : objects : targets : linkrule : origlist ;
14 # Links _objects_ into _image_. Dependency of exe.
15 # @MainFromObjects provides a default suffix for _image_
17 rule --MainFromObjects-- {
18   local _s _t _ctt _f have_attrs _xl ;
19   local _ctt = $(3) ;
21   # check if we have attributes
22   have_attrs = ;
23   for _f in $(5) {
24     if $(_f) ~= '^!' {
25       have_attrs = tan ;
26       break;
27     }
28   }
30   # Add grist to file names
31   if $(have_attrs) {
32     # rebuild list removing any attributes
33     local lastfile = ;
34     _s = ;
35     for _f in $(>) {
36       if ! ( $(_f) ~= '^![^!]' ) {
37         #Echo "FILE:" $(_f) ;
38         if $(_f) ~= '^!!' {
39           _f = [ Match '^!([^\s]+)' : $(_f) ] ;
40           _f = $(_f[1]) ;
41         }
42         if $(lastfile) { _s += $(lastfile) ; }
43         lastfile = [ FGristFiles $(_f) ] ;
44       } else {
45         #Echo "NOT-FILE:" $(_f) ;
46         if $(_f:S=) = "!dont-link" { lastfile = ; }
47       }
48     }
49     if $(lastfile) { _s += $(lastfile) ; }
50   } else {
51     _s = [ FGristFiles $(>) ] ;
52   }
53   _s = [ ListRemoveDuplicates $(_s) ] ;
54   #Echo "5:" $(5) ;
55   #Echo ">:" $(>) ;
56   #Echo "_s:" $(_s) ;
58   # Add suffix to exe
59   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
60   # so 'jam foo' works when it's really foo.exe
61   if $(_t) != $(<) {
62     Depends $(<) : $(_t) ;
63     NotFile $(<) ;
64   }
66   #Echo "MainFromObjects: _t:" "$(_t)" "_ctt:" "$(_ctt)" ;
68   # make compiled sources a dependency of target
69   if $(_ctt) != "_" {
70     for _f in $(_ctt) {
71       #Echo "separate target:" "$(_f)" ;
72       Depends $(_f) : $(_t) ;
73       Clean $(_f)_clean : $(_t) ;
74       Depends $(_f)_clean : clean ;
75     }
76   } else {
77     #Echo "separate target:" "$(_t)" ;
78     Clean $(_t)_clean : $(_t) ;
79     Depends $(_t)_clean : clean ;
80   }
81   #Depends exe : $(_t) ;
82   Depends $(_t) : $(_s) ;
83   #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
84   MakeLocate $(_t) : $(LOCATE_BIN) ;
85   Clean clean : $(_t) ;
87   # special case for stupid Borland C++, which always generates a
88   # .tds file for executables, even when no debug information is needed
89   #
90   #if $(JAM_TOOLSET) = BORLANDC {
91   #  MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
92   #  Clean  clean : $(_t:S=.tds) ;
93   #}
95   $(4) $(_t) : $(_s) ;
97   if $(have_attrs) {
98     # some files have some special attributes, process this
99     _s = ; # last file met, gristed
100     _t = ; # last file met, unmodified
101     _xl = ;
102     for _f in $(5) {
103       _ctt = [ Match '^!([^!][^\s]+)' : $(_f) ] ;
104       if $(_ctt) {
105         if $(_s) {
106           _ctt = $(_ctt[1]);
107           #Echo "ATTR:" $(_ctt) "for file:" $(_s) "ungristed:" $(_t) ;
108           if $(_ctt) != "dont-link" {
109             if [ HaveRule --main-option-$(_ctt)-- ] {
110               --main-option-$(_ctt)-- $(_s) : $(_t) ;
111             } else {
112               Exit "FATAL: invalid attribute" $(_ctt) "for file" $(_t) ;
113             }
114           }
115         }
116       } else {
117         if $(_f) ~= '^!!' {
118           _f = [ Match '^!([^\s]+)' : $(_f) ] ;
119           _f = $(_f[1]) ;
120         }
121         _xl += $(_f) ;
122         _t = $(_f) ;
123         _s = [ FGristFiles $(_f:S=$(SUFOBJ)) ] ;
124       }
125     }
126     return $(_xl) ;
127   } else {
128     return $(5) ;
129   }
132 . Jambase.main.attrs
133 . main/Jambase.main.c
134 . main/Jambase.main.cpp
135 . main/Jambase.main.objc
136 . main/Jambase.main.lib
137 . main/Jambase.main.libso
138 . main/Jambase.main.libboth