Merge branch 'sanity-sleep-fix-master'
[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 ## 2007, 2008, 2009, 2010 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 2, 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 ## Building.  ##
24 ## ---------- ##
25
26 elc-stamp: $(LISP)
27         @echo 'WARNING: Warnings can be ignored. :-)'
28         @rm -f elc-temp && touch elc-temp
29         if test "$(EMACS)" != no; then \
30 ## Make sure "$@" isn't empty initially.
31           set x; \
32 ## Populate "$@" with elisp files (found in the current directory
33 ## or in $srcdir).
34           list='$(LISP)'; for p in $$list; do \
35             if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
36             set x "$$@" "$$d$$p"; shift; \
37           done; \
38 ## Finally call elisp-comp for all files.
39           shift; \
40           EMACS="$(EMACS)" $(SHELL) $(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         @dry=; for f in x $$MAKEFLAGS; do \
56           case $$f in \
57             *=*|--*);; \
58             *n*) dry=:;; \
59           esac; \
60         done; \
61         if test "$(EMACS)" != no && test ! -f $@; then \
62 ## If `make -j' is used and more than one file has been erased, several
63 ## processes can execute this block.  We have to make sure that only
64 ## the first one will run `$(MAKE) $(AM_MAKEFLAGS) elc-stamp', and the
65 ## other ones will wait.
66 ##
67 ## There is a race here if only one child of make receive a signal.
68 ## In that case the build may fail.  We remove elc-stamp when we receive
69 ## a signal so we are sure the build will succeed the next time.
70           $$dry trap 'rm -rf elc-lock elc-stamp' 1 2 13 15; \
71           if $$dry mkdir elc-lock 2>/dev/null; then \
72 ## This code is being executed by the first process.
73             $$dry rm -f elc-stamp; \
74             $(MAKE) $(AM_MAKEFLAGS) elc-stamp; \
75             $$dry rmdir elc-lock; \
76           else \
77 ## This code is being executed by the follower processes.
78 ## Wait until the first process is done.
79             while test -d elc-lock && test -z "$$dry"; do sleep 1; done; \
80 ## Succeed if and only if the first process succeeded.
81             $$dry test -f elc-stamp; exit $$?; \
82           fi; \
83         else : ; fi
84
85
86 ## ------------ ##
87 ## Installing.  ##
88 ## ------------ ##
89
90 if %?INSTALL%
91 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
92 %DIR%LISP_INSTALL = %BASE?$(INSTALL_DATA):$(install_sh_DATA)%
93 .PHONY install-%EXEC?exec:data%-am: install-%DIR%LISP
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           $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)"; \
99 ?!BASE?   $(am__vpath_adj_setup) \
100 ## Funny invocation because Makefile variable can be empty, leading to
101 ## a syntax error in sh.
102           list='$(%DIR%_LISP)'; for p in $$list; do \
103 ## A lisp file can be in the source directory or the build directory.
104             if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
105             %BASE?$(am__strip_dir):$(am__vpath_adj)% \
106             echo " $(%DIR%LISP_INSTALL) '$$d$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
107             $(%DIR%LISP_INSTALL) "$$d$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit $$?; \
108 ## Only install .elc file if it exists.
109             if test -f $${p}c; then \
110               echo " $(%DIR%LISP_INSTALL) '$${p}c' '$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
111               $(%DIR%LISP_INSTALL) "$${p}c" "$(DESTDIR)$(%NDIR%dir)/$${f}c" || exit $$?; \
112             else : ; fi; \
113           done; \
114         else : ; fi
115 endif %?INSTALL%
116
117
118 ## -------------- ##
119 ## Uninstalling.  ##
120 ## -------------- ##
121
122 if %?INSTALL%
123 .PHONY uninstall-am: uninstall-%DIR%LISP
124 uninstall-%DIR%LISP:
125         @$(NORMAL_UNINSTALL)
126 ## Do not uninstall anything if EMACS was not found.
127         @test "$(EMACS)" != no && test -n "$(%NDIR%dir)" || exit 0; \
128         list='$(%DIR%_LISP)'; \
129 ?BASE?  files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
130 ?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
131         test -n "$$files" || exit 0; \
132         filesc=`echo "$$files" | sed 's|$$|c|'`; \
133         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
134         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
135         echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
136         cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc
137 endif %?INSTALL%
138
139
140 ## ---------- ##
141 ## Cleaning.  ##
142 ## ---------- ##
143
144 .PHONY clean-am: clean-lisp
145 clean-lisp:
146         -rm -f elc-stamp $(ELCFILES)
147
148
149 ## -------------- ##
150 ## Distributing.  ##
151 ## -------------- ##
152
153 if %?DIST%
154 DIST_COMMON += %DISTVAR%
155 endif %?DIST%