added "C++FLAGS.all" (and "OBJCFLAGS.all"); "CFLAGS.all" is still in effect
[k8jam.git] / defaults / Jambase.pkgcfg
blobaaee4fc9d1fb908751c1835bf1da74381c953cc5
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, version 3 of the License ONLY.
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8 # GNU General Public License for more details.
10 # You should have received a copy of the GNU General Public License
11 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
13 # $(1): check string: 'glib-2.0 >= 1.3.4'
14 # return empty string if condition is not met
15 rule pkg-config-exists {
16   local cf res ;
17   cf = [ Command "$(PKG-CONFIG) --exists '$(1)' 2>/dev/null" : exit-code code-first ] ;
18   if $(cf[1]) = '0' {
19     res = 'tan' ;
20   } else {
21     res = ;
22   }
23   return $(res) ;
27 # call $(1)
28 # add output to var $(2)
29 # return resulting (non-empty) string if library is present
30 # if $(2) = "" -- don't add flags, just return
31 # [ lib-config-ex '$(PKG-CONFIG) sdl --cflags' : 'CFLAGS' ]
32 rule lib-config-ex {
33   local cf lf res ;
34   cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
35   if $(cf[1]) = '0' && $(cf[2]) {
36     res = $(cf[2-]) ;
37     if $(2) {
38       $(2) += $(cf[2-]) ;
39     }
40   } else {
41     res = ;
42   }
43   return $(res) ;
47 # call $(1) --cflags and $(1) --libs (many libs provides such configurators)
48 # add necessary flags to compiler and linker vars
49 # return 'tan' (non-empty string) if library is present
50 # if $(2) != "" -- don't add flags, just check
51 # [ lib-config '$(PKG-CONFIG) sdl' ]
52 rule lib-config {
53   local cf lf hasit ;
55   cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
56   #Echo 'cf:' $(cf) ;
57   if $(cf[1]) = '0' && $(cf[2]) {
58     hasit = 'tan' ;
59     #Echo 'flags:' $(cf[2-]) ;
60     if ! $(2) {
61       CCFLAGS += $(cf[2-]) ;
62       C++FLAGS += $(cf[2-]) ;
63       OBJCFLAGS += $(cf[2-]) ;
64     }
65   }
67   lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
68   #Echo 'lf:' $(lf) ;
69   if $(lf[1]) = '0' && $(lf[2]) {
70     hasit = 'tan' ;
71     #Echo 'flags:' $(lf[2-]) ;
72     if ! $(2) {
73       LINKLIBS += $(lf[2-]) ;
74       C++LINKLIBS += $(lf[2-]) ;
75       OBJCLINKLIBS += $(lf[2-]) ;
76     }
77   }
79   return $(hasit) ;
82 rule pkg-config {
83   local res ;
84   res = [ lib-config "$(PKG-CONFIG) $(1)" ] ;
85   return $(res) ;
89 rule pkg-config-has {
90   local res ;
91   res = [ lib-config-ex "$(PKG-CONFIG) $(1) --cflags --libs" ] ;
92   return $(res) ;