* COPYING, lib/COPYING: Update to GPLv3. All uses changed.
[platform/upstream/automake.git] / lib / am / lisp.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
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 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, write to the Free Software
17 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA.
19
20 if %?INSTALL%
21 include inst-vars.am
22 endif %?INSTALL%
23
24 ## ---------- ##
25 ## Building.  ##
26 ## ---------- ##
27
28 elc-stamp: $(LISP)
29         @echo 'WARNING: Warnings can be ignored. :-)'
30         @rm -f elc-temp && touch elc-temp
31         if test "$(EMACS)" != no; then \
32 ## Make sure "$@" isn't empty initially.
33           set x; \
34 ## Populate "$@" with elisp files (found in the current directory
35 ## or in $srcdir).
36           list='$(LISP)'; for p in $$list; do \
37             if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
38             set x "$$@" "$$d$$p"; shift; \
39           done; \
40 ## Finally call elisp-comp for all files.
41           shift; \
42           EMACS="$(EMACS)" $(SHELL) $(elisp_comp) "$$@" || exit 1; \
43         else : ; fi
44         @mv -f elc-temp $@
45
46 ## Do not use $(ELCFILES) as target, because it may have been emptied
47 ## by the user (to disable byte-compilation), and POSIX does not allow
48 ## an empty target.
49 $(am__ELCFILES): elc-stamp
50 ## Recover from the removal of $@.
51 ##
52 ## Do not call `make elc-stamp' if emacs is not available, because it would
53 ## be useless.
54         @if test "$(EMACS)" != no && test ! -f $@; then \
55 ## If `make -j' is used and more than one file has been erased, several
56 ## processes can execute this block.  We have to make sure that only
57 ## the first one will run `$(MAKE) $(AM_MAKEFLAGS) elc-stamp', and the
58 ## other ones will wait.
59 ##
60 ## There is a race here if only one child of make receive a signal.
61 ## In that case the build may fail.  We remove elc-stamp when we receive
62 ## a signal so we are sure the build will succeed the next time.
63           trap 'rm -rf elc-lock elc-stamp' 1 2 13 15; \
64           if mkdir elc-lock 2>/dev/null; then \
65 ## This code is being executed by the first process.
66             rm -f elc-stamp; \
67             $(MAKE) $(AM_MAKEFLAGS) elc-stamp; \
68             rmdir elc-lock; \
69           else \
70 ## This code is being executed by the follower processes.
71 ## Wait until the first process is done.
72             while test -d elc-lock; do sleep 1; done; \
73 ## Succeed if and only if the first process succeeded.
74             test -f elc-stamp; exit $$?; \
75           fi; \
76         else : ; fi
77
78
79 ## ------------ ##
80 ## Installing.  ##
81 ## ------------ ##
82
83 if %?INSTALL%
84 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
85 ?BASE?%DIR%LISP_INSTALL = $(INSTALL_DATA)
86 ?!BASE?%DIR%LISP_INSTALL = $(install_sh_DATA)
87 ?EXEC?.PHONY install-exec-am: install-%DIR%LISP
88 ?!EXEC?.PHONY install-data-am: install-%DIR%LISP
89 install-%DIR%LISP: $(%DIR%_LISP) $(ELCFILES)
90         @$(NORMAL_INSTALL)
91 ## Do not install anything if EMACS was not found.
92         @if test "$(EMACS)" != no; then \
93           test -z "$(%NDIR%dir)" || $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)"; \
94 ?!BASE?   $(am__vpath_adj_setup) \
95 ## Funny invocation because Makefile variable can be empty, leading to
96 ## a syntax error in sh.
97           list='$(%DIR%_LISP)'; for p in $$list; do \
98 ## A lisp file can be in the source directory or the build directory.
99             if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
100 ?BASE?      f=$(am__strip_dir) \
101 ?!BASE?     $(am__vpath_adj) \
102             echo " $(%DIR%LISP_INSTALL) '$$d$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
103             $(%DIR%LISP_INSTALL) "$$d$$p" "$(DESTDIR)$(%NDIR%dir)/$$f"; \
104 ## Only install .elc file if it exists.
105             if test -f $${p}c; then \
106               echo " $(%DIR%LISP_INSTALL) '$${p}c' '$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
107               $(%DIR%LISP_INSTALL) "$${p}c" "$(DESTDIR)$(%NDIR%dir)/$${f}c"; \
108             else : ; fi; \
109           done; \
110         else : ; fi
111 endif %?INSTALL%
112
113
114 ## -------------- ##
115 ## Uninstalling.  ##
116 ## -------------- ##
117
118 if %?INSTALL%
119 .PHONY uninstall-am: uninstall-%DIR%LISP
120 uninstall-%DIR%LISP:
121         @$(NORMAL_UNINSTALL)
122 ## Do not uninstall anything if EMACS was not found.
123         @if test "$(EMACS)" != no; then \
124 ?!BASE?   $(am__vpath_adj_setup) \
125           list='$(%DIR%_LISP)'; for p in $$list; do \
126 ?BASE?      f=$(am__strip_dir) \
127 ?!BASE?     $(am__vpath_adj) \
128             echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f' '$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
129             rm -f "$(DESTDIR)$(%NDIR%dir)/$$f" "$(DESTDIR)$(%NDIR%dir)/$${f}c"; \
130           done; \
131         else : ; fi
132 endif %?INSTALL%
133
134
135 ## ---------- ##
136 ## Cleaning.  ##
137 ## ---------- ##
138
139 .PHONY clean-am: clean-lisp
140 clean-lisp:
141         -rm -f elc-stamp $(ELCFILES)
142
143
144 ## -------------- ##
145 ## Distributing.  ##
146 ## -------------- ##
147
148 if %?DIST%
149 DIST_COMMON += %DISTVAR%
150 endif %?DIST%