Port changes to release branch
[util-vserver.git] / Makefile.am
1 ## $Id: Makefile.am,v 1.70 2005/07/03 17:51:00 ensc Exp $
2
3 # Copyright (C) 2003,2004 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; either version 2, or (at your option)
8 # any later version.
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 ACLOCAL_AMFLAGS         =  -I m4
21 SUBDIRS                 =  . distrib
22
23 CVS2CL_AMFLAGS          =  $(CVS2CL_TAG) -U cvsusers.map --show-dead -S --no-wrap
24 CVS2CL_ALLFLAGS        :=  $(CVS2CL_AMFLAGS) $(CVS2CL_FLAGS)
25
26 confdir                 =  $(sysconfdir)/vservers
27 confdefaultsdir         =  $(confdir)/.defaults
28 sbincfgdir              =  $(sbindir)
29 legacydir               =  $(pkglibdir)/legacy
30
31 include_HEADERS =
32 noinst_HEADERS =        $(ENSC_VECTOR_HDRS) \
33                         compat.h compat-c99.h
34
35 noinst_LIBRARIES =      $(ENSC_VECTOR_LIBS)
36 lib_LIBRARIES =
37 lib_LTLIBRARIES =
38 pkglib_LTLIBRARIES =
39
40 pkglib_SCRIPTS =
41 pkglib_DATA =           FEATURES.txt
42 pkglib_PROGRAMS =
43 legacy_SCRIPTS =
44 legacy_PROGRAMS =
45
46 sbin_SCRIPTS =
47 sbin_PROGRAMS =
48 noinst_PROGRAMS =
49 noinst_DATA =
50
51 initrd_SCRIPTS =
52 sysconf_DATA =
53
54 DIETPROGS =             $(LIBENSCVECTOR_DIET)
55
56 BUILT_SOURCES =         pathconfig.h linuxvirtual.h \
57                         .fixups
58
59 man_MANS =
60
61 kernel_HDRS =           kernel/context.h        \
62                         kernel/context_cmd.h    \
63                         kernel/cvirt.h          \
64                         kernel/cvirt_cmd.h      \
65                         kernel/cvirt_def.h      \
66                         kernel/debug.h          \
67                         kernel/debug_cmd.h      \
68                         kernel/dlimit.h         \
69                         kernel/dlimit_cmd.h     \
70                         kernel/inode.h          \
71                         kernel/inode_cmd.h      \
72                         kernel/legacy.h         \
73                         kernel/limit.h          \
74                         kernel/limit_cmd.h      \
75                         kernel/limit_def.h      \
76                         kernel/namespace.h      \
77                         kernel/namespace_cmd.h  \
78                         kernel/network.h        \
79                         kernel/network_cmd.h    \
80                         kernel/sched.h          \
81                         kernel/sched_cmd.h      \
82                         kernel/sched_def.h      \
83                         kernel/signal_cmd.h     \
84                         kernel/switch.h         \
85                         kernel/xid.h
86
87
88 EXTRA_PROGRAMS =
89 EXTRA_DIST =            pathconfig.h.pathsubst \
90                         util-vserver.spec \
91                         THANKS REQUIREMENTS \
92                         $(kernel_HDRS)
93
94 check_PROGRAMS =
95 check_SCRIPTS =
96
97 TESTS_DEBUG =           no
98 TESTS =
99 TESTS_ENVIRONMENT =     ensc_use_expensive_tests="$(ENSC_USE_EXPENSIVE_TESTS)" \
100                         ensc_test_debug="$(TESTS_DEBUG)"
101
102 AM_CPPFLAGS =           -I $(top_srcdir)/lib -I $(top_srcdir)/ensc_wrappers \
103                         -D_GNU_SOURCE -D_REENTRANT $(RELEASE_CPPFLAGS)
104
105 CLEANFILES =            $(BUILT_SOURCES) \
106                         .*.pathsubst.stamp */.*.pathsubst.stamp */*/.*.pathsubst.stamp \
107                         pathconfig.h .fixups
108
109 DISTCLEANFILES =        FEATURES.txt
110
111
112 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT =
113
114 if USE_DIETLIBC
115 DIET_CC                :=  $(DIET) $(DIETFLAGS) $(CC)
116 VSERVER_LDFLGS         :=  -static
117 else
118 VSERVER_LDFLGS         :=
119 endif
120
121 if USE_DIETLIBC_COMPAT
122 DIET_COMPAT_LDADDS =    -lcompat
123 else
124 DIET_COMPAT_LDADDS =
125 endif
126
127 VSERVER_LDADDS =        $(LIBVSERVER) $(DIET_COMPAT_LDADDS)
128
129 silent.%:               FORCE
130                         @t=$$(mktemp /tmp/build.XXXXXX) && \
131                         $(MAKE) '$*' -s 2>$$t >/dev/null && \
132                         ( cat $$t | \
133                                 grep -v ': In function' | \
134                                 grep -v 'your code still has assertions enabled' | \
135                                 grep -v ' is obsoleted' | \
136                                 grep -v 'warning: #warning'; \
137                                 rm -f $$t || : )
138
139
140 linuxvirtual.h:
141 if ENSC_ENABLE_INTERNAL_HEADERS
142                         ln -sf '$(top_srcdir)/lib/virtual.h' '$@'
143 else
144                         ln -sf '$(kernelincludedir)/linux/virtual.h' '$@' && test -e '$@' || \
145                         ln -sf '$(top_srcdir)/lib/virtual.h' '$@'
146 endif
147
148 pathsubst_RULES =       s!@'PKGLIBDIR'@!$(pkglibdir)!g; \
149                         s!@'LEGACYDIR'@!$(legacydir)!g; \
150                         s!@'SBINDIR'@!$(sbindir)!g; \
151                         s!@'CONFDIR'@!$(confdir)!g; \
152                         s!@'SYSCONFDIR'@!$(sysconfdir)!g; \
153                         s!@'PKGSTATEDIR'@!$(pkgstatedir)!g; \
154                         s!@'PKGSTATEREVDIR'@!$(pkgstaterevdir)!g; \
155                         s!@'VSERVERDIR'@!$(vserverdir)!g; \
156                         s!@'VSERVERPKGDIR'@!$(vserverpkgdir)!g; \
157                         s!@'VSERVERPKGDIR'@!$(vserverpkgdir)!g; \
158                         s!@'VSHELPERSTATEDIR'@!$(vshelperstatedir)!g; \
159                         s!@'INITRDDIR'@!$(initrddir)!g; \
160                         s!@'LIBDIR'@!$(libdir)!g; \
161                         s!@'MANDIR'@!$(mandir)!g; \
162                         s!@'INCLUDEDIR'@!$(includedir)!g; \
163                         s!@'PACKAGE'@!$(PACKAGE)!g; \
164                         s!@'PACKAGE_BUGREPORT'@!$(PACKAGE_BUGREPORT)!g; \
165                         s!@'PACKAGE_NAME'@!$(PACKAGE_NAME)!g; \
166                         s!@'PACKAGE_STRING'@!$(PACKAGE_STRING)!g; \
167                         s!@'PACKAGE_TARNAME'@!$(PACKAGE_TARNAME)!g; \
168                         s!@'PACKAGE_VERSION'@!$(PACKAGE_VERSION)!g; \
169                         s!@'ENSC_HAVE_C99_COMPILER_TRUE'@!\@ENSC_HAVE_C99_COMPILER_TRUE@ !g; \
170                         s!@'ENSC_HAVE_C99_COMPILER_FALSE'@!\@ENSC_HAVE_C99_COMPILER_FALSE@ !g; \
171                         s!@'ENSC_HAVE_CXX_COMPILER_TRUE'@!\@ENSC_HAVE_CXX_COMPILER_TRUE@ !g; \
172                         s!@'ENSC_HAVE_CXX_COMPILER_FALSE'@!\@ENSC_HAVE_CXX_COMPILER_FALSE@ !g; \
173                         $(ENSC_PATHPROG_SED)
174
175 pathconfig.h:           .pathconfig.h.pathsubst.stamp
176 .%.pathsubst.stamp:     %.pathsubst Makefile
177                         @mkdir -p $$(dirname '$@')
178                         @echo "$(SED) -e '...' $*.pathsubst >$*"
179                         @$(SED) -e '$(pathsubst_RULES)' '$<' >'$@.tmp'
180                         @-chmod --reference='$<' '$@.tmp'
181                         @if cmp -s '$@.tmp' '$*'; then \
182                                 echo "... no changes, reusing old version"; \
183                                 rm -f '$@.tmp'; \
184                         else \
185                                 rm -f '$*'; mv '$@.tmp' '$*'; \
186                         fi
187                         @chmod a-w '$*'
188                         @touch '$@'
189
190 pkgstatedir =           $(localstatedir)/run/vservers
191 pkgstaterevdir =        $(confdefaultsdir)/run.rev
192 vserverpkgdir =         $(vserverdir)/.pkg
193 vshelperstatedir =      $(localstatedir)/run/vshelper
194
195 fix_SCRPTS              =  $(addprefix $(pkglibdir)/, $(notdir $(pkglib_SCRIPTS))) \
196                            $(addprefix $(legacydir)/, $(notdir $(legacy_SCRIPTS))) \
197                            $(addprefix $(sbindir)/,   $(notdir $(sbin_SCRIPTS))) \
198                            $(addprefix $(initrddir)/, $(notdir $(initrd_SCRIPTS)))
199
200 update-doc:             doc
201                         $(top_srcdir)/update-doc
202
203 install-data-hook:      install-fix-script-paths install-create-dirs
204
205 install-create-dirs:
206                         $(mkinstalldirs) -m 755 $(DESTDIR)$(pkgstatedir) $(DESTDIR)$(pkgstatedir).rev $(DESTDIR)$(vshelperstatedir)
207                         $(mkinstalldirs) -m 755 $(DESTDIR)$(confdefaultsdir)
208                         f=$(DESTDIR)$(confdefaultsdir)/vdirbase; test -e "$$f" || ln -sf '$(vserverdir)'      "$$f"
209                         f=$(DESTDIR)$(pkgstaterevdir);           test -e "$$f" || ln -sf '$(pkgstatedir).rev' "$$f"
210
211 install-fix-script-paths:
212                         test "/usr/lib/util-vserver" = "$(pkglibdir)" || \
213                         for i in $(fix_SCRPTS); do \
214                                 f="$(DESTDIR)$$i"; \
215                                 $(SED) -e 's!/usr/lib/util-vserver!$(pkglibdir)!g' "$$f" >"$$f.tmp"; \
216                                 $(CMP) -s "$$f.tmp" "$$f" || cat "$$f.tmp" >"$$f"; \
217                                 rm -f "$$f.tmp"; \
218                         done
219
220 install-distribution:   _install-vserverdir _install-vshelperlink
221
222 _install-vshelperlink:
223                         $(mkinstalldirs) $(DESTDIR)/sbin
224                         ln -sf ..$(pkglibdir)/vshelper $(DESTDIR)/sbin/vshelper
225
226 _install-vserverdir:
227                         $(mkinstalldirs) $(DESTDIR)$(vserverdir) $(DESTDIR)$(vserverpkgdir)
228
229
230 .fixups:                config.status util-vserver.spec
231                         chmod a-w util-vserver.spec
232                         touch $@
233
234 if USE_DIETLIBC
235 $(addsuffix $(EXEEXT), $(DIETPROGS)) \
236 $(addsuffix $(OBJEXT), $(DIETPROGS)) \
237                 :               CC=$(DIET_CC)
238 else    !USE_DIETLIBC
239 nodist_lib_dietlibc_not_enabled_error_a_SOURCES = \
240                         lib-dietlibc-not-enabled-error.c
241 endif
242
243 install-exec-hook:
244         cd $(DESTDIR)$(sbindir) && $(LN_S) vuseradd vadduser
245         cd $(DESTDIR)$(sbindir) && $(LN_S) vuserdel vdeluser
246         mkdir -p $(DESTDIR)/bin
247         cd $(DESTDIR)/bin && $(LN_S) ../$(sbindir)/vsh
248
249 install-data-hook:
250         install -D -m 644 scripts/vcached.logrotate $(DESTDIR)/$(sysconfdir)/logrotate.d/vcached
251         install -D -m 644 scripts/vcached.cron $(DESTDIR)/$(sysconfdir)/cron.d/vcached
252
253 include $(top_srcdir)/lib/Makefile-files
254 include $(top_srcdir)/src/Makefile-files
255 include $(top_srcdir)/doc/Makefile-files
256 include $(top_srcdir)/man/Makefile-files
257 include $(top_srcdir)/scripts/Makefile-files
258 include $(top_srcdir)/tests/Makefile-files
259 include $(top_srcdir)/sysv/Makefile-files
260 include $(top_srcdir)/contrib/Makefile-files
261 include $(top_srcdir)/ensc_vector/Makefile-files
262 include $(top_srcdir)/ensc_wrappers/Makefile-files
263 include $(top_srcdir)/ensc_fmt/Makefile-files
264 include $(top_srcdir)/lib_internal/Makefile-files
265 include $(top_srcdir)/vserver-start/Makefile-files
266
267 include $(top_srcdir)/m4/gpgsig.am
268 include $(top_srcdir)/m4/validate.am
269 include $(top_srcdir)/m4/changelog.am
270 include $(top_srcdir)/m4/pkgconfig.am
271 include $(top_srcdir)/m4/libsel.am
272 include $(top_srcdir)/m4/install-notify.am
273
274 .PHONY:         FORCE update-doc