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