elisp: simplify suffix rules using emacs '-L' option
[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 .el.elc:
26 ## We add $(builddir) and $(srcdir) to load-path, so that any '.el' files
27 ## that $< depends upon can be found (including generated ones).
28 ## We prefer files from the build directory to those from the source
29 ## directory, in true VPATH spirit.
30 ## The destination file is normally determined by appending "c" to the
31 ## input (which would erronously put it in $(srcdir) in VPATH builds),
32 ## so we override that, too.
33         if test "$(EMACS)" != "no"; then \
34           $(EMACS) -q --batch \
35             -L '$(builddir)' -L '$(srcdir)' \
36             --eval "(defun byte-compile-dest-file (f) \"$@\")" \
37             --eval "(unless (byte-compile-file \"$<\") (kill-emacs 1))"; \
38         else :; fi
39
40
41 ## ------------ ##
42 ## Installing.  ##
43 ## ------------ ##
44
45 if %?INSTALL%
46 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
47
48 ?BASE?%DIR%LISP_INSTALL = $(INSTALL_DATA)
49 ?!BASE?%DIR%LISP_INSTALL = $(install_sh_DATA)
50
51 ?EXEC?.PHONY install-exec-am: install-%DIR%LISP
52 ?!EXEC?.PHONY install-data-am: install-%DIR%LISP
53
54 install-%DIR%LISP: $(%DIR%_LISP) $(ELCFILES)
55         @$(NORMAL_INSTALL)
56 ## Do not install anything if EMACS was not found.
57         @if test "$(EMACS)" != no && test -n "$(%NDIR%dir)"; then \
58 ?!BASE?   $(am__vpath_adj_setup) \
59 ## Funny invocation because Makefile variable can be empty, leading to
60 ## a syntax error in sh.
61           list='$(%DIR%_LISP)'; \
62           if test -n "$$list"; then \
63             echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
64             $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
65           fi; \
66           for p in $$list; do \
67 ## A lisp file can be in the source directory or the build directory.
68             if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
69 ?BASE?      $(am__strip_dir) \
70 ?!BASE?     $(am__vpath_adj) \
71             echo " $(%DIR%LISP_INSTALL) '$$d$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
72             $(%DIR%LISP_INSTALL) "$$d$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit $$?; \
73 ## Only install .elc file if it exists.
74             if test -f $${p}c; then \
75               echo " $(%DIR%LISP_INSTALL) '$${p}c' '$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
76               $(%DIR%LISP_INSTALL) "$${p}c" "$(DESTDIR)$(%NDIR%dir)/$${f}c" || exit $$?; \
77             else : ; fi; \
78           done; \
79         else : ; fi
80 endif %?INSTALL%
81
82
83 ## -------------- ##
84 ## Uninstalling.  ##
85 ## -------------- ##
86
87 if %?INSTALL%
88 .PHONY uninstall-am: uninstall-%DIR%LISP
89 uninstall-%DIR%LISP:
90         @$(NORMAL_UNINSTALL)
91 ## Do not uninstall anything if EMACS was not found.
92         @test "$(EMACS)" != no && test -n "$(%NDIR%dir)" || exit 0; \
93         list='$(%DIR%_LISP)'; \
94 ?BASE?  files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
95 ?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
96         files="$$files "`echo "$$files" | sed 's|$$|c|'`; \
97         dir='$(DESTDIR)$(%NDIR%dir)'; $(am__uninstall_files_from_dir)
98 endif %?INSTALL%
99
100
101 ## ---------- ##
102 ## Cleaning.  ##
103 ## ---------- ##
104
105 .PHONY clean-am: clean-lisp
106 clean-lisp:
107         -rm -f $(ELCFILES)
108
109
110 ## -------------- ##
111 ## Distributing.  ##
112 ## -------------- ##
113
114 if %?DIST%
115 DIST_COMMON += %DISTVAR%
116 endif %?DIST%