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