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