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 # $(1): check string: 'glib-2.0 >= 1.3.4'
15 # return empty string if condition is not met
16 rule pkg-config-exists {
18 cf = [ Command "pkg-config --exists '$(1)' 2>/dev/null" : exit-code code-first ] ;
29 # add output to var $(2)
30 # return resulting (non-empty) string if library is present
31 # if $(2) = "" -- don't add flags, just return
32 # [ lib-config-ex 'pkg-config sdl --cflags' : 'CFLAGS' ]
35 cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
36 if $(cf[1]) = '0' && $(cf[2]) {
48 # call $(1) --cflags and $(1) --libs (many libs provides such configurators)
49 # add necessary flags to compiler and linker vars
50 # return 'tan' (non-empty string) if library is present
51 # if $(2) != "" -- don't add flags, just check
52 # [ lib-config 'pkg-config sdl' ]
56 cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
58 if $(cf[1]) = '0' && $(cf[2]) {
60 #Echo 'flags:' $(cf[2-]) ;
62 CCFLAGS += $(cf[2-]) ;
63 C++FLAGS += $(cf[2-]) ;
64 OBJCFLAGS += $(cf[2-]) ;
68 lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
70 if $(lf[1]) = '0' && $(lf[2]) {
72 #Echo 'flags:' $(lf[2-]) ;
74 LINKLIBS += $(lf[2-]) ;
75 C++LINKLIBS += $(lf[2-]) ;
76 OBJCLINKLIBS += $(lf[2-]) ;
85 res = [ lib-config "pkg-config $(1)" ] ;
92 res = [ lib-config-ex "pkg-config $(1) --cflags --libs" ] ;