python: run the 'py-compile' script with $(SHELL)
[platform/upstream/automake.git] / lib / am / python.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1999, 2001, 2003, 2004, 2006, 2007, 2008, 2009, 2011
3 ## Free Software Foundation, Inc.
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, see <http://www.gnu.org/licenses/>.
17
18 if %?INSTALL%
19 include inst-vars.am
20 endif %?INSTALL%
21
22 ## ------------ ##
23 ## Installing.  ##
24 ## ------------ ##
25
26 if %?INSTALL%
27 ?FIRST?am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile)
28 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
29 .PHONY install-%EXEC?exec:data%-am: install-%DIR%PYTHON
30 install-%DIR%PYTHON: $(%DIR%_PYTHON)
31         @$(NORMAL_INSTALL)
32         test -z "$(%NDIR%dir)" || $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)"
33 if %?BASE%
34         @list='$(%DIR%_PYTHON)'; dlist=; list2=; test -n "$(%NDIR%dir)" || list=; \
35         for p in $$list; do \
36 ## A file can be in the source directory or the build directory.
37           if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
38           if test -f $$b$$p; then \
39 ## Compute basename of source file.  Unless this is a nobase_ target, we
40 ## want to install 'python/foo.py' as '$(DESTDIR)$(%NDIR%dir)/foo.py',
41 ## not '$(DESTDIR)$(%NDIR%dir)/python/foo.py'.
42             $(am__strip_dir) \
43             dlist="$$dlist $$f"; \
44             list2="$$list2 $$b$$p"; \
45           else :; fi; \
46         done; \
47         for file in $$list2; do echo $$file; done | $(am__base_list) | \
48         while read files; do \
49 ## Don't perform translation, since script name is important.
50           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(%NDIR%dir)'"; \
51           $(INSTALL_DATA) $$files "$(DESTDIR)$(%NDIR%dir)" || exit $$?; \
52         done || exit $$?; \
53 ## Byte-compile must be done at install time, since file times are
54 ## encoded in the actual files.
55         if test -n "$$dlist"; then \
56           if test -z "$(DESTDIR)"; then \
57             $(am__py_compile) --basedir "$(%NDIR%dir)" $$dlist; \
58           else \
59             $(am__py_compile) --destdir "$(DESTDIR)" \
60                               --basedir "$(%NDIR%dir)" $$dlist; \
61           fi; \
62         else :; fi
63 else !%?BASE%
64         @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
65         $(am__nobase_list) | while read dir files; do \
66           xfiles=; for p in $$files; do \
67 ## A file can be in the source directory or the build directory.
68             if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
69             if test -f "$$b$$p"; then xfiles="$$xfiles $$b$$p"; dlist="$$dlist $$p"; \
70             else :; fi; done; \
71           test -z "$$xfiles" || { \
72             test "x$$dir" = x. || { \
73               echo "$(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
74               $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir"; }; \
75 ## Don't perform translation, since script name is important.
76             echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
77             $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?; }; \
78 ## Byte-compile must be done at install time, since file times are
79 ## encoded in the actual files.
80           if test -n "$$dlist"; then \
81             if test -z "$(DESTDIR)"; then \
82               $(am__py_compile) --basedir "$(%NDIR%dir)" $$dlist; \
83             else \
84               $(am__py_compile) --destdir "$(DESTDIR)" \
85                                 --basedir "$(%NDIR%dir)" $$dlist; \
86             fi; \
87           else :; fi \
88         done
89 endif !%?BASE%
90 endif %?INSTALL%
91
92
93 ## -------------- ##
94 ## Uninstalling.  ##
95 ## -------------- ##
96
97 if %?INSTALL%
98 .PHONY uninstall-am: uninstall-%DIR%PYTHON
99 uninstall-%DIR%PYTHON:
100         @$(NORMAL_UNINSTALL)
101         @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
102 ?BASE?  files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
103 ?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
104         test -n "$$files" || exit 0; \
105         filesc=`echo "$$files" | sed 's|$$|c|'`; \
106         fileso=`echo "$$files" | sed 's|$$|o|'`; \
107         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
108         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
109 ## This is to remove the .pyc and .pyo byte compiled versions (a bit
110 ## of a hack).
111         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
112         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc || exit $$?; \
113         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$fileso ")"; \
114         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$fileso
115 endif %?INSTALL%
116
117
118 ## ---------- ##
119 ## Cleaning.  ##
120 ## ---------- ##
121
122 ## There is nothing to clean here since files are
123 ## byte-compiled when (and where) they are installed.
124
125 ## -------------- ##
126 ## Distributing.  ##
127 ## -------------- ##
128
129 if %?DIST%
130 DIST_COMMON += %DISTVAR%
131 endif %?DIST%