am: do not quote `like this', as per GCS recommendation
[platform/upstream/automake.git] / lib / am / progs.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-2012 Free Software Foundation, Inc.
3
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
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, see <http://www.gnu.org/licenses/>.
16
17 ## ------------ ##
18 ## Installing.  ##
19 ## ------------ ##
20
21 if %?INSTALL%
22 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
23 .PHONY install-%EXEC?exec:data%-am: install-%DIR%PROGRAMS
24 install-%DIR%PROGRAMS: $(%DIR%_PROGRAMS)
25         @$(NORMAL_INSTALL)
26         test -z "$(%NDIR%dir)" || $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)"
27 ## Funny invocation because Makefile variable can be empty, leading to
28 ## a syntax error in sh.
29         @list='$(%DIR%_PROGRAMS)'; test -n "$(%NDIR%dir)" || list=; \
30         for p in $$list; do echo "$$p $$p"; done | \
31 ## On Cygwin with libtool test won't see 'foo.exe' but instead 'foo'.
32 ## So we check for both.
33         sed 's/$(EXEEXT)$$//' | \
34         while read p p1; do if test -f $$p%LIBTOOL? || test -f $$p1%; \
35           then echo "$$p"; echo "$$p"; else :; fi; \
36         done | \
37 ## We now have a list of sourcefile pairs, separated by newline.
38 ## Turn that into "sourcefile source_base target_dir xformed_target_base",
39 ## with newlines being turned into spaces in a second step.
40         sed -e 'p;s,.*/,,;n;h' -e '%BASE?s|.*|.|:s|[^/]*$$||; s|^$$|.|%' \
41             -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
42         sed 'N;N;N;s,\n, ,g' | \
43 ## The following awk script turns that into one line containing directories
44 ## and then lines of 'type target_name_or_directory sources ...', with type
45 ## 'd' designating directories, and 'f' files.
46         $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
47           { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
48             if ($$2 == $$4) files[d] = files[d] " " $$1; \
49             else { print "f", $$3 "/" $$4, $$1; } } \
50           END { for (d in files) print "f", d, files[d] }' | \
51         while read type dir files; do \
52 ?!BASE?   case $$type in \
53 ?!BASE?   d) echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
54 ?!BASE?      $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?;; \
55 ?!BASE?   f) \
56             if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
57             test -z "$$files" || { \
58 ?!LIBTOOL?            echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(%NDIR%dir)$$dir'"; \
59 ?!LIBTOOL?            $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(%NDIR%dir)$$dir" || exit $$?; \
60 ## Note that we explicitly set the libtool mode.  This avoids any
61 ## lossage if the install program doesn't have a name that libtool
62 ## expects.
63 ?LIBTOOL?           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(%NDIR%dir)$$dir'"; \
64 ?LIBTOOL?           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(%NDIR%dir)$$dir" || exit $$?; \
65             } \
66 ?!BASE?   ;; esac \
67         ; done
68
69 endif %?INSTALL%
70
71
72 ## -------------- ##
73 ## Uninstalling.  ##
74 ## -------------- ##
75
76 if %?INSTALL%
77 .PHONY uninstall-am: uninstall-%DIR%PROGRAMS
78 uninstall-%DIR%PROGRAMS:
79         @$(NORMAL_UNINSTALL)
80         @list='$(%DIR%_PROGRAMS)'; test -n "$(%NDIR%dir)" || list=; \
81         files=`for p in $$list; do echo "$$p"; done | \
82 ## Remove any leading directory before applying $(transform),
83 ## but keep the directory part in the hold buffer, in order to
84 ## reapply it again afterwards in the nobase case.  Append $(EXEEXT).
85           sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
86               -e 's/$$/$(EXEEXT)/'%BASE? : -e 'x;s,[^/]*$$,,;G;s,\n,,'%`; \
87         test -n "$$list" || exit 0; \
88         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
89         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
90 endif %?INSTALL%
91
92
93 ## ---------- ##
94 ## Cleaning.  ##
95 ## ---------- ##
96
97 .PHONY clean-am: clean-%DIR%PROGRAMS
98 clean-%DIR%PROGRAMS:
99 ?!LIBTOOL?      -test -z "$(%DIR%_PROGRAMS)" || rm -f $(%DIR%_PROGRAMS)
100 ## Under Cygwin, we build 'program$(EXEEXT)'.  However, if this
101 ## program uses a Libtool library, Libtool will move it in
102 ## '_libs/program$(EXEEXT)' and create a 'program' wrapper (without
103 ## '$(EXEEXT)').  Therefore, if Libtool is used, we must try to erase
104 ## both 'program$(EXEEXT)' and 'program'.
105 ## Cleaning the '_libs/' or '.libs/' directory is done from clean-libtool.
106 ## FIXME: In the future (i.e., when it works) it would be nice to delegate
107 ## this task to "libtool --mode=clean".
108 ?LIBTOOL?       @list='$(%DIR%_PROGRAMS)'; test -n "$$list" || exit 0; \
109 ?LIBTOOL?       echo " rm -f" $$list; \
110 ?LIBTOOL?       rm -f $$list || exit $$?; \
111 ?LIBTOOL?       test -n "$(EXEEXT)" || exit 0; \
112 ?LIBTOOL?       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
113 ?LIBTOOL?       echo " rm -f" $$list; \
114 ?LIBTOOL?       rm -f $$list
115
116
117 ## ---------- ##
118 ## Checking.  ##
119 ## ---------- ##
120
121 if %?CK-OPTS%
122 .PHONY installcheck-am: installcheck-%DIR%PROGRAMS
123 installcheck-%DIR%PROGRAMS: $(%DIR%_PROGRAMS)
124         bad=0; pid=$$$$; list="$(%DIR%_PROGRAMS)"; for p in $$list; do \
125           case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
126 ## Match $(srcdir)/$$p in addition to $$p because Sun make might rewrite
127 ## filenames in AM_INSTALLCHECK_STD_OPTIONS_EXEMPT during VPATH builds.
128            *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
129           esac; \
130 ## Strip the directory and $(EXEEXT) before applying $(transform).
131           f=`echo "$$p" | \
132              sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
133 ## Insert the directory back if nobase_ is used.
134 ?!BASE?   f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \
135           for opt in --help --version; do \
136             if "$(DESTDIR)$(%NDIR%dir)/$$f" $$opt >c$${pid}_.out \
137                  2>c$${pid}_.err </dev/null \
138                  && test -n "`cat c$${pid}_.out`" \
139                  && test -z "`cat c$${pid}_.err`"; then :; \
140             else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
141           done; \
142         done; rm -f c$${pid}_.???; exit $$bad
143 endif %?CK-OPTS%