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