Faster `make uninstall'; fast install for JAVA.
[automake/ericb.git] / lib / am / progs.am
blobcc4cf4a9e18ed649d1982b65b951a4eb1a7253e2
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004,
3 ## 2006, 2007, 2008 Free Software Foundation, Inc.
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 3, or (at your option)
8 ## any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 ## ------------ ##
19 ## Installing.  ##
20 ## ------------ ##
22 if %?INSTALL%
23 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
24 %DIR%PROGRAMS_INSTALL = %BASE?$(INSTALL_PROGRAM):$(install_sh_PROGRAM)%
25 .PHONY install-%EXEC?exec:data%-am: install-%DIR%PROGRAMS
26 install-%DIR%PROGRAMS: $(%DIR%_PROGRAMS)
27         @$(NORMAL_INSTALL)
28         test -z "$(%NDIR%dir)" || $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)"
29 ## Funny invocation because Makefile variable can be empty, leading to
30 ## a syntax error in sh.
31         @list='$(%DIR%_PROGRAMS)'; for p in $$list; do \
32 ## On Cygwin with libtool test won't see `foo.exe' but instead `foo'.
33 ## So we check for both.
34           p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
35           if test -f $$p \
36 ?LIBTOOL?            || test -f $$p1 \
37           ; then \
38 ## Compute basename of source file.  Unless this is a nobase_ target, we
39 ## want to install 'python/foo.py' as '$(DESTDIR)$(%NDIR%dir)/foo.yo',
40 ## not '$(DESTDIR)$(%NDIR%dir)/python/foo.yo'.
41 ## However in all cases $(transform) applies only to the basename,
42 ## so we have to strip the directory part.
43             f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
44 ## Prepend the directory part if nobase_ is used.
45 ?!BASE?     f=`echo "$$p1" | sed 's|[^/]*$$||'`"$$f"; \
46 ## Note that we explicitly set the libtool mode.  This avoids any
47 ## lossage if the install program doesn't have a name that libtool
48 ## expects.
49 ?LIBTOOL?          echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(%DIR%PROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
50 ?LIBTOOL?          $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(%DIR%PROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit $$?; \
51 ?!LIBTOOL?         echo " $(INSTALL_PROGRAM_ENV) $(%DIR%PROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
52 ?!LIBTOOL?         $(INSTALL_PROGRAM_ENV) $(%DIR%PROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit $$?; \
53           else :; fi; \
54         done
55 endif %?INSTALL%
58 ## -------------- ##
59 ## Uninstalling.  ##
60 ## -------------- ##
62 if %?INSTALL%
63 .PHONY uninstall-am: uninstall-%DIR%PROGRAMS
64 uninstall-%DIR%PROGRAMS:
65         @$(NORMAL_UNINSTALL)
66         @list='$(%DIR%_PROGRAMS)'; \
67         files=`for p in $$list; do echo "$$p"; done | \
68 ## Remove any leading directory before applying $(transform),
69 ## but keep the directory part in the hold buffer, in order to
70 ## reapply it again afterwards in the nobase case.  Append $(EXEEXT).
71           sed 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/; \
72 ?!BASE?        x;s,[^/]*$$,,;G;s,\n,,; \
73                '`; \
74         test -n "$$list" || exit 0; \
75         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
76         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
77 endif %?INSTALL%
80 ## ---------- ##
81 ## Cleaning.  ##
82 ## ---------- ##
84 .PHONY clean-am: clean-%DIR%PROGRAMS
85 clean-%DIR%PROGRAMS:
86 ?!LIBTOOL?      -test -z "$(%DIR%_PROGRAMS)" || rm -f $(%DIR%_PROGRAMS)
87 ## Under Cygwin, we build `program$(EXEEXT)'.  However, if this
88 ## program uses a Libtool library, Libtool will move it in
89 ## `_libs/program$(EXEEXT)' and create a `program' wrapper (without
90 ## `$(EXEEXT)').  Therefore, if Libtool is used, we must try to erase
91 ## both `program$(EXEEXT)' and `program'.
92 ## Cleaning the `_libs/' or `.libs/' directory is done from clean-libtool.
93 ## FIXME: In the future (i.e., when it works) it would be nice to delegate
94 ## this task to `libtool --mode=clean'.
95 ?LIBTOOL?       @list='$(%DIR%_PROGRAMS)'; for p in $$list; do \
96 ?LIBTOOL?         f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
97 ?LIBTOOL?         echo " rm -f $$p $$f"; \
98 ?LIBTOOL?         rm -f $$p $$f ; \
99 ?LIBTOOL?       done
102 ## ---------- ##
103 ## Checking.  ##
104 ## ---------- ##
106 if %?CK-OPTS%
107 .PHONY installcheck-am: installcheck-%DIR%PROGRAMS
108 installcheck-%DIR%PROGRAMS: $(%DIR%_PROGRAMS)
109         bad=0; pid=$$$$; list="$(%DIR%_PROGRAMS)"; for p in $$list; do \
110           case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
111 ## Match $(srcdir)/$$p in addition to $$p because Sun make might rewrite
112 ## filenames in AM_INSTALLCHECK_STD_OPTIONS_EXEMPT during VPATH builds.
113            *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
114           esac; \
115 ## Strip the directory and $(EXEEXT) before applying $(transform).
116           f=`echo "$$p" | \
117              sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
118 ## Insert the directory back if nobase_ is used.
119 ?!BASE?   f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \
120           for opt in --help --version; do \
121             if "$(DESTDIR)$(%NDIR%dir)/$$f" $$opt >c$${pid}_.out \
122                  2>c$${pid}_.err </dev/null \
123                  && test -n "`cat c$${pid}_.out`" \
124                  && test -z "`cat c$${pid}_.err`"; then :; \
125             else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
126           done; \
127         done; rm -f c$${pid}_.???; exit $$bad
128 endif %?CK-OPTS%