Merge branch 'minor'
[automake.git] / lib / am / scripts.am
blob6a9a23e563722afa0d63a1f505b0d2a93f831aff
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-2017 Free Software Foundation, Inc.
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.
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.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 if %?INSTALL%
18 include inst-vars.am
19 endif %?INSTALL%
21 ## ------------ ##
22 ## Installing.  ##
23 ## ------------ ##
25 if %?INSTALL%
26 ## if doesn't work properly for Automake variables yet.
27 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
28 ?EXEC?.PHONY install-exec-am: install-%DIR%SCRIPTS
29 ?!EXEC?.PHONY install-data-am: install-%DIR%SCRIPTS
30 install-%DIR%SCRIPTS: $(%DIR%_SCRIPTS)
31         @$(NORMAL_INSTALL)
32 ## Funny invocation because Makefile variable can be empty, leading to
33 ## a syntax error in sh.
34         @list='$(%DIR%_SCRIPTS)'; test -n "$(%NDIR%dir)" || list=; \
35         if test -n "$$list"; then \
36           echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
37           $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
38         fi; \
39 ?!BASE? $(am__nobase_strip_setup); \
40         for p in $$list; do \
41 ## A file can be in the source directory or the build directory.
42           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
43 ## A script may or may not exist.
44           if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
45         done | \
46 ## We now have a list of "sourcefile newline (nobase-)target" pairs.
47 ## Turn that into "sourcefile source_base target_dir xformed_target_base",
48 ## with newlines being turned into spaces in a second step.
49         sed -e 'p;s,.*/,,;n' \
50 ?BASE?      -e 'h;s|.*|.|' \
51 ?!BASE?     -e "s|$$srcdirstrip/||" -e 'h;s|[^/]*$$||; s|^$$|.|' \
52             -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
53         $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
54           { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
55             if ($$2 == $$4) { files[d] = files[d] " " $$1; \
56               if (++n[d] == $(am__install_max)) { \
57                 print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
58             else { print "f", d "/" $$4, $$1 } } \
59           END { for (d in files) print "f", d, files[d] }' | \
60         while read type dir files; do \
61 ?!BASE?   case $$type in \
62 ?!BASE?   d) echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
63 ?!BASE?      $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?;; \
64 ?!BASE?   f) \
65              if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
66              test -z "$$files" || { \
67                echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(%NDIR%dir)$$dir'"; \
68                $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(%NDIR%dir)$$dir" || exit $$?; \
69              } \
70 ?!BASE?   ;; esac \
71         ; done
72 endif %?INSTALL%
75 ## -------------- ##
76 ## Uninstalling.  ##
77 ## -------------- ##
79 if %?INSTALL%
80 .PHONY uninstall-am: uninstall-%DIR%SCRIPTS
81 uninstall-%DIR%SCRIPTS:
82         @$(NORMAL_UNINSTALL)
83         @list='$(%DIR%_SCRIPTS)'; test -n "$(%NDIR%dir)" || exit 0; \
84 ?BASE?  files=`for p in $$list; do echo "$$p"; done | \
85 ?BASE?         sed -e 's,.*/,,;$(transform)'`; \
86 ?!BASE? $(am__nobase_strip_setup); \
87 ?!BASE? files=`$(am__nobase_strip) \
88 ?!BASE?        -e 'h;s,.*/,,;$(transform);x;s|[^/]*$$||;G;s,\n,,'`; \
89         dir='$(DESTDIR)$(%NDIR%dir)'; $(am__uninstall_files_from_dir)
90 endif %?INSTALL%
93 ## -------------- ##
94 ## Distributing.  ##
95 ## -------------- ##
97 if %?DIST%
98 DIST_COMMON += %DISTVAR%
99 endif %?DIST%
102 ## ---------- ##
103 ## Checking.  ##
104 ## ---------- ##
106 if %?CK-OPTS%
107 .PHONY installcheck-am: installcheck-%DIR%SCRIPTS
108 installcheck-%DIR%SCRIPTS: $(%DIR%_SCRIPTS)
109         bad=0; pid=$$$$; list="$(%DIR%_SCRIPTS)"; 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 any leading directory before applying $(transform).
116           f=`echo "$$p" | sed 's,^.*/,,;$(transform)'`; \
117 ## Insert the directory back if nobase_ is used.
118 ?!BASE?   f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \
119           for opt in --help --version; do \
120             if "$(DESTDIR)$(%NDIR%dir)/$$f" $$opt >c$${pid}_.out \
121                  2>c$${pid}_.err </dev/null \
122                  && test -n "`cat c$${pid}_.out`" \
123                  && test -z "`cat c$${pid}_.err`"; then :; \
124             else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
125           done; \
126         done; rm -f c$${pid}_.???; exit $$bad
127 endif %?CK-OPTS%