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 ?EXEC?.PHONY install-exec-am: install-%DIR%PYTHON
30 ?!EXEC?.PHONY install-data-am: install-%DIR%PYTHON
31 install-%DIR%PYTHON: $(%DIR%_PYTHON)
32         @$(NORMAL_INSTALL)
33 if %?BASE%
34         @list='$(%DIR%_PYTHON)'; dlist=; list2=; 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         for p in $$list; do \
40 ## A file can be in the source directory or the build directory.
41           if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
42           if test -f $$b$$p; then \
43 ## Compute basename of source file.  Unless this is a nobase_ target, we
44 ## want to install 'python/foo.py' as '$(DESTDIR)$(%NDIR%dir)/foo.py',
45 ## not '$(DESTDIR)$(%NDIR%dir)/python/foo.py'.
46             $(am__strip_dir) \
47             dlist="$$dlist $$f"; \
48             list2="$$list2 $$b$$p"; \
49           else :; fi; \
50         done; \
51         for file in $$list2; do echo $$file; done | $(am__base_list) | \
52         while read files; do \
53 ## Don't perform translation, since script name is important.
54           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(%NDIR%dir)'"; \
55           $(INSTALL_DATA) $$files "$(DESTDIR)$(%NDIR%dir)" || exit $$?; \
56         done || exit $$?; \
57 ## Byte-compile must be done at install time, since file times are
58 ## encoded in the actual files.
59         if test -n "$$dlist"; then \
60           $(am__py_compile) --destdir "$(DESTDIR)" \
61                             --basedir "$(%NDIR%dir)" $$dlist; \
62         else :; fi
63 else !%?BASE%
64         @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
65         if test -n "$$list"; then \
66           echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
67           $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
68         fi; \
69         $(am__nobase_list) | while read dir files; do \
70           xfiles=; for p in $$files; do \
71 ## A file can be in the source directory or the build directory.
72             if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
73             if test -f "$$b$$p"; then xfiles="$$xfiles $$b$$p"; dlist="$$dlist $$p"; \
74             else :; fi; done; \
75           test -z "$$xfiles" || { \
76             test "x$$dir" = x. || { \
77               echo "$(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
78               $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir"; }; \
79 ## Don't perform translation, since script name is important.
80             echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
81             $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?; }; \
82 ## Byte-compile must be done at install time, since file times are
83 ## encoded in the actual files.
84           if test -n "$$dlist"; then \
85             $(am__py_compile) --destdir "$(DESTDIR)" \
86                               --basedir "$(%NDIR%dir)" $$dlist; \
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         dir='$(DESTDIR)$(%NDIR%dir)'; \
106 ## Also remove the .pyc and .pyo byte compiled versions.
107         filesc=`echo "$$files" | sed 's|$$|c|'`; \
108         fileso=`echo "$$files" | sed 's|$$|o|'`; \
109         st=0; \
110         for files in "$$files" "$$filesc" "$$fileso"; do \
111           $(am__uninstall_files_from_dir) || st=$$?; \
112         done; \
113         exit $$st
114 endif %?INSTALL%
115
116
117 ## ---------- ##
118 ## Cleaning.  ##
119 ## ---------- ##
120
121 ## There is nothing to clean here since files are
122 ## byte-compiled when (and where) they are installed.
123
124 ## -------------- ##
125 ## Distributing.  ##
126 ## -------------- ##
127
128 if %?DIST%
129 DIST_COMMON += %DISTVAR%
130 endif %?DIST%