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