Import util-vserver rev 2847
[util-vserver.git] / m4 / pkgconfig.am
1 ## $Id: pkgconfig.am 2846 2009-08-23 12:36:40Z ensc $   ---*- makefile -*---
2
3 ## Copyright (C) 2002, 2003, 2005, 2009
4 ##     Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; version 2 and/or 3 of the License.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ##
19
20 BAD_INC_PATHS           =  /usr/include|/usr/local/include
21 BAD_LIB_PATHS           =  /usr/lib
22
23 pkgconfdir              =  $(libdir)/pkgconfig
24 pkgconf_DATA            =  $(addsuffix .pc, $(PKGCONFIG_FILES))
25
26 CLEANFILES              += $(addsuffix .pc,       $(PKGCONFIG_FILES))
27 EXTRA_DIST              += $(addsuffix .pc.subst, $(PKGCONFIG_FILES))
28
29 pkgconf_SUBST =         s!@'PACKAGE'@!$(PACKAGE)!g;                                     \
30                         s!@'VERSION'@!$(VERSION)!g;                                     \
31                         s!@'prefix'@!$(prefix)!g;                                       \
32                         s!@'exec_prefix'@!$(exec_prefix)!g;                             \
33                         s!@'libdir'@!$(libdir)!g;                                       \
34                         s!@'includedir'@!$(includedir)!g;                               \
35                         s!@'libflags"@!$${libflags}$(pkgconf_LIBFLAGS)!g;"'             \
36                         s!@'incflags"@!$${incflags}$(pkgconf_INCFLAGS)!g;"'             \
37                         s!@'pkgincflags"@!$${pkgincflags}$(pkgconf_PKGINCFLAGS)!g;"'    \
38                         s!@'pkgincludedir'@!$(pkgincludedir)!g
39
40
41 %.pc:                   %.pc.subst Makefile
42                         rm -f $@
43                         @case '$(libdir)' in                                                    \
44                                 $(BAD_LIB_PATHS))       libflags=;;                             \
45                                 *)                      libflags='-L$${libdir} ';;              \
46                         esac;                                                                   \
47                         case '$(pkgincludedir)' in                                              \
48                                 $(BAD_INC_PATHS))       pkgincflags=;;                          \
49                                 *)                      pkgincflags='-I$${pkgincludedir} ';;    \
50                         esac;                                                                   \
51                         case '$(includedir)' in                                                 \
52                                 $(BAD_INC_PATHS))       incflags=;;                             \
53                                 *)                      incflags='-I$${includedir} ';;          \
54                         esac;                                                                   \
55                         sed -e '$(pkgconf_SUBST)' $< >$@
56                         test -z "$(CHMOD_REFERENCE)" || $(CHMOD_REFERENCE) '$<' '$@'
57                         chmod a-w $@