fixed bug in configure
[k8jam.git] / defaults / Jambase.pkgcfg
blobe871e455d1b981863ad595294b13f8529b2db826
1 # call $(1)
2 # add output to var $(2)
3 # return resulting (non-empty) string if library is present
4 # if $(2) = "" -- don't add flags, just return
5 # [ lib-config-ex "pkg-config sdl --cflags" : "CFLAGS" ]
6 rule lib-config-ex {
7   local cf lf res ;
8   cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
9   if $(cf[1]) = "0" && $(cf[2]) {
10     res = $(cf[2-]) ;
11     if $(2) {
12       $(2) += $(cf[2-]) ;
13     }
14   } else {
15     res = ;
16   }
17   return $(res) ;
21 # call $(1) --cflags and $(1) --libs (many libs provides such configurators)
22 # add necessary flags to compiler and linker vars
23 # return "tan" (non-empty string) if library is present
24 # if $(2) != "" -- don't add flags, just check
25 # [ lib-config "pkg-config sdl" ]
26 rule lib-config {
27   local cf lf hasit ;
29   cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
30   #Echo "cf:" $(cf) ;
31   if $(cf[1]) = "0" && $(cf[2]) {
32     hasit = "tan" ;
33     #Echo "flags:" $(cf[2-]) ;
34     if ! $(2) {
35       CCFLAGS += $(cf[2-]) ;
36       C++FLAGS += $(cf[2-]) ;
37       OBJCFLAGS += $(cf[2-]) ;
38     }
39   }
41   lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
42   #Echo "lf:" $(lf) ;
43   if $(lf[1]) = "0" && $(lf[2]) {
44     hasit = "tan" ;
45     #Echo "flags:" $(lf[2-]) ;
46     if ! $(2) {
47       LINKLIBS += $(lf[2-]) ;
48       C++LINKLIBS += $(lf[2-]) ;
49       OBJCLINKLIBS += $(lf[2-]) ;
50     }
51   }
53   return $(hasit) ;
56 rule pkg-config {
57   local res ;
58   res = [ lib-config "pkg-config $(1)" ] ;
59   return $(res) ;
63 rule pkg-config-has {
64   local res ;
65   res = [ lib-config-ex "pkg-config $(1) --cflags --libs" ] ;
66   return $(res) ;