e17d2af30d15802847f66d87fbac785e31c9e96e
[util-vserver.git] / m4 / pkgconfig.am
1 ## $Id: pkgconfig.am,v 1.1 2003/10/13 19:50:29 ensc Exp $       ---*- 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
29 %.pc:                   %.pc.subst Makefile
30                         rm -f $@
31                         @case '$(libdir)' in                                                    \
32                                 $(BAD_LIB_PATHS))       libflags=;;                             \
33                                 *)                      libflags='-L$${libdir} ';;              \
34                         esac;                                                                   \
35                         case '$(pkgincludedir)' in                                              \
36                                 $(BAD_INC_PATHS))       pkgincflags=;;                          \
37                                 *)                      pkgincflags='-I$${pkgincludedir} ';;    \
38                         esac;                                                                   \
39                         case '$(includedir)' in                                                 \
40                                 $(BAD_INC_PATHS))       incflags=;;                             \
41                                 *)                      incflags='-I$${includedir} ';;          \
42                         esac;                                                                   \
43                         sed -e 's!@'PACKAGE'@!$(PACKAGE)!g;                                     \
44                                 s!@'VERSION'@!$(VERSION)!g;                                     \
45                                 s!@'prefix'@!$(prefix)!g;                                       \
46                                 s!@'exec_prefix'@!$(exec_prefix)!g;                             \
47                                 s!@'libdir'@!$(libdir)!g;                                       \
48                                 s!@'includedir'@!$(includedir)!g;                               \
49                                 s!@'libflags"@!$${libflags}$(pkgconf_LIBFLAGS)!g;"'             \
50                                 s!@'incflags"@!$${incflags}$(pkgconf_INCFLAGS)!g;"'             \
51                                 s!@'pkgincflags"@!$${pkgincflags}$(pkgconf_PKGINCFLAGS)!g;"'    \
52                                 s!@'pkgincludedir'@!$(pkgincludedir)!g'                         \
53                         $< >$@
54                         test -z "$(CHMOD_REFERENCE)" || $(CHMOD_REFERENCE) '$<' '$@'
55                         chmod a-w $@