Merge branch 'next' (early part) into mh-vala-support
[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  Free
3 ## 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 3, 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 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           if test -z "$(DESTDIR)"; then \
56             PYTHON=$(PYTHON) $(py_compile) --basedir "$(%NDIR%dir)" $$dlist; \
57           else \
58             PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(%NDIR%dir)" $$dlist; \
59           fi; \
60         else :; fi
61 else !%?BASE%
62         @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
63         $(am__nobase_list) | while read dir files; do \
64           xfiles=; for p in $$files; do \
65 ## A file can be in the source directory or the build directory.
66             if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
67             if test -f "$$b$$p"; then xfiles="$$xfiles $$b$$p"; dlist="$$dlist $$p"; \
68             else :; fi; done; \
69           test -z "$$xfiles" || { \
70             test "x$$dir" = x. || { \
71               echo "$(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
72               $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir"; }; \
73 ## Don't perform translation, since script name is important.
74             echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
75             $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?; }; \
76 ## Byte-compile must be done at install time, since file times are
77 ## encoded in the actual files.
78           if test -n "$$dlist"; then \
79             if test -z "$(DESTDIR)"; then \
80               PYTHON=$(PYTHON) $(py_compile) --basedir "$(%NDIR%dir)" $$dlist; \
81             else \
82               PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(%NDIR%dir)" $$dlist; \
83             fi; \
84           else :; fi \
85         done
86 endif !%?BASE%
87 endif %?INSTALL%
88
89
90 ## -------------- ##
91 ## Uninstalling.  ##
92 ## -------------- ##
93
94 if %?INSTALL%
95 .PHONY uninstall-am: uninstall-%DIR%PYTHON
96 uninstall-%DIR%PYTHON:
97         @$(NORMAL_UNINSTALL)
98         @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
99 ?BASE?  files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
100 ?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
101         test -n "$$files" || exit 0; \
102         filesc=`echo "$$files" | sed 's|$$|c|'`; \
103         fileso=`echo "$$files" | sed 's|$$|o|'`; \
104         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
105         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
106 ## This is to remove the .pyc and .pyo byte compiled versions (a bit
107 ## of a hack).
108         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
109         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc || exit $$?; \
110         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$fileso ")"; \
111         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$fileso
112 endif %?INSTALL%
113
114
115 ## ---------- ##
116 ## Cleaning.  ##
117 ## ---------- ##
118
119 ## There is nothing to clean here since files are
120 ## byte-compiled when (and where) they are installed.
121
122 ## -------------- ##
123 ## Distributing.  ##
124 ## -------------- ##
125
126 if %?DIST%
127 DIST_COMMON += %DISTVAR%
128 endif %?DIST%