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 {
17 cf = [ Command "$(PKG-CONFIG) --exists '$(1)' 2>/dev/null" : exit-code code-first ] ;
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' ]
34 cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
35 if $(cf[1]) = '0' && $(cf[2]) {
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' ]
55 cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
57 if $(cf[1]) = '0' && $(cf[2]) {
59 #Echo 'flags:' $(cf[2-]) ;
61 CCFLAGS += $(cf[2-]) ;
62 C++FLAGS += $(cf[2-]) ;
63 OBJCFLAGS += $(cf[2-]) ;
67 lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
69 if $(lf[1]) = '0' && $(lf[2]) {
71 #Echo 'flags:' $(lf[2-]) ;
73 LINKLIBS += $(lf[2-]) ;
74 C++LINKLIBS += $(lf[2-]) ;
75 OBJCLINKLIBS += $(lf[2-]) ;
84 res = [ lib-config "$(PKG-CONFIG) $(1)" ] ;
91 res = [ lib-config-ex "$(PKG-CONFIG) $(1) --cflags --libs" ] ;