Fix bootstrapping problem. (Reported by "mace".)
[emacs.git] / lisp / makefile.w32-in
blob15fab8083813c0e39fee2e3407c2c1c73db7c748
1 #  -*- Makefile -*- for GNU Emacs on the Microsoft W32 API.
2 #  Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 #                2005 Free Software Foundation, Inc.
5 #  This file is part of GNU Emacs.
7 #  GNU Emacs is free software; you can redistribute it and/or modify
8 #  it under the terms of the GNU General Public License as published by
9 #  the Free Software Foundation; either version 2, or (at your option)
10 #  any later version.
12 #  GNU Emacs is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #  GNU General Public License for more details.
17 #  You should have received a copy of the GNU General Public License
18 #  along with GNU Emacs; see the file COPYING.  If not, write to the
19 #  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 #  Boston, MA 02110-1301, USA.
23 ALL =
25 all: $(ALL)
27 SQUOTE='
28 # '
30 lisp = $(CURDIR)
31 srcdir = $(CURDIR)/..
33 # You can specify a different executable on the make command line,
34 # e.g. "make EMACS=../src/emacs ...".
36 EMACS = "$(THISDIR)/../bin/emacs.exe"
38 # Command line flags for Emacs.  This must include --multibyte,
39 # otherwise some files will not compile.
41 EMACSOPT = -batch --no-init-file --no-site-file --multibyte
43 # Set EMACSLOADPATH correctly (already defined in environment).
44 EMACSLOADPATH=$(lisp)
46 lisptagsfiles1 = $(lisp)/*.el
47 lisptagsfiles2 = $(lisp)/*/*.el
48 ETAGS = "../lib-src/$(BLD)/etags"
50 # Files to compile before others during a bootstrap.  This is done to
51 # speed up the bootstrap process.  The CC files are compiled first
52 # because CC mode tweaks the compilation process, and requiring
53 # cc-mode when it is not compiled doesn't work during the
54 # bootstrapping.
56 COMPILE_FIRST = \
57         $(lisp)/emacs-lisp/byte-opt.el \
58         $(lisp)/emacs-lisp/bytecomp.el \
59         $(lisp)/subr.el \
60         $(lisp)/progmodes/cc-mode.el \
61         $(lisp)/progmodes/cc-vars.el
63 # The actual Emacs command run in the targets below.
65 emacs = $(EMACS) $(EMACSOPT)
67 # Common command to find subdirectories
69 setwins=subdirs=`find $$wd -type d -print`; \
70         for file in $$subdirs; do \
71            case $$file in */Old | */RCS | */CVS | */CVS/* | */=* ) ;; \
72                 *) wins="$$wins $$file" ;; \
73            esac; \
74         done
76 # Have to define the list of subdirs manually when not using sh.
77 WINS=\
78         calc \
79         calendar \
80         emacs-lisp \
81         emulation \
82         erc \
83         eshell \
84         gnus \
85         international \
86         language \
87         mail \
88         mh-e \
89         net \
90         obsolete \
91         play \
92         progmodes \
93         term \
94         textmodes \
95         url
97 doit:
99 $(lisp)/cus-load.el:
100         touch $@
101 # WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as
102 #          this can break with GNU Make 3.81 and later if sh.exe is used.
103 custom-deps: $(lisp)/cus-load.el doit
104         @echo Directories: $(WINS)
105         -$(emacs) -l cus-dep --eval $(ARGQUOTE)(setq find-file-hook nil)$(ARGQUOTE) -f custom-make-dependencies $(lisp) $(WINS)
107 finder-data: doit
108         @echo Directories: $(WINS)
109         $(emacs) -l finder -f finder-compile-keywords-make-dist $(lisp) $(WINS)
111 $(lisp)/loaddefs.el:
112         $(MAKE) $(MFLAGS) loaddefs.el-$(SHELLTYPE)
113         cp loaddefs.el-$(SHELLTYPE) $@
114         rm loaddefs.el-$(SHELLTYPE)
116 loaddefs.el-SH:
117         echo ";;; loaddefs.el --- automatically extracted autoloads" > $@
118         echo ";;" >> $@; echo ";;; Code:" >> $@
119         echo "(autoload 'define-minor-mode \"easy-mmode\")" >>$@
120         echo "(autoload 'define-ccl-program \"ccl\")" >>$@
121         echo "(autoload 'regexp-opt \"regexp-opt\")" >>$@
122         echo "(autoload 'string-to-list \"mule-util\")" >>$@
123         echo "(autoload 'define-derived-mode \"derived\")" >>$@
124         echo "(autoload 'encoded-kbd-mode \"encoded-kb\")" >>$@
125         echo "(defvar cvs-global-menu nil)" >>$@
126         echo "\f" >> $@
127         echo ";;; Local Variables:" >> $@
128         echo ";;; version-control: never" >> $@
129         echo ";;; no-byte-compile: t" >> $@
130         echo ";;; no-update-autoloads: t" >> $@
131         echo ";;; End:" >> $@
132         echo ";;; loaddefs.el ends here" >> $@
134 loaddefs.el-CMD:
135         echo ;;; loaddefs.el --- automatically extracted autoloads> $@
136         echo ;;; Code:>> $@
137         echo (autoload 'define-minor-mode "easy-mmode")>> $@
138         echo (autoload 'define-ccl-program "ccl")>> $@
139         echo (autoload 'regexp-opt "regexp-opt")>> $@
140         echo (autoload 'string-to-list "mule-util")>> $@
141         echo (autoload 'define-derived-mode "derived")>> $@
142         echo (autoload 'encoded-kbd-mode "encoded-kb")>> $@
143         echo (defvar cvs-global-menu nil)>> $@
144         echo.\f>> $@
145         echo ;;; Local Variables:>> $@
146         echo ;;; version-control: never>> $@
147         echo ;;; no-byte-compile: t>> $@
148         echo ;;; no-update-autoloads: t>> $@
149         echo ;;; End:>> $@
150         echo ;;; loaddefs.el ends here>> $@
152 # Use . instead of $(lisp) because $(lisp) is an absolute file name,
153 # including a drive letter and any leading directories, so the generated
154 # loaddefs.el will mention file names that on other machine reference
155 # possibly non-existent directories.
157 # WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as
158 #          this can break with GNU Make 3.81 and later if sh.exe is used.
159 autoloads: $(lisp)/loaddefs.el doit
160         @echo Directories: . $(WINS)
161         $(emacs) -l autoload \
162                 --eval $(ARGQUOTE)(setq find-file-hook nil find-file-suppress-same-file-warnings t)$(ARGQUOTE) \
163                 -f w32-batch-update-autoloads "$(lisp)/loaddefs.el" . $(WINS)
165 $(lisp)/subdirs.el:
166         $(MAKE) $(MFLAGS) update-subdirs
168 # Need separate version for sh and native cmd.exe
169 update-subdirs: update-subdirs-$(SHELLTYPE)
171 update-subdirs-CMD: doit
172         echo ;; -*- no-byte-compile: t -*-> $(lisp)/subdirs.el
173         echo ;; In load-path, after this directory should come>> $(lisp)/subdirs.el
174         echo ;; certain of its subdirectories.  Here we specify them.>> $(lisp)/subdirs.el
175         echo (normal-top-level-add-to-load-path $(SQUOTE)(>> $(lisp)/subdirs.el
176         @for %%d in ($(WINS)) do if not (%%d)==(term) echo "%%d">> $(lisp)/subdirs.el
177         echo ))>> $(lisp)/subdirs.el
179 update-subdirs-SH: doit
180         $(srcdir)/update-subdirs $(lisp); \
181         for file in $(WINS); do \
182            $(srcdir)/update-subdirs $$file; \
183         done;
185 updates: update-subdirs autoloads mh-autoloads finder-data custom-deps
187 # This is useful after "cvs up".
188 cvs-update: recompile autoloads finder-data custom-deps
190 # Update the AUTHORS file.
192 update-authors:
193         $(emacs) -l authors -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
195 TAGS: $(lisptagsfiles1) $(lisptagsfiles2)
196         $(ETAGS) $(lisptagsfiles1) $(lisptagsfiles2)
198 TAGS-LISP: $(lisptagsfiles1) $(lisptagsfiles2)
199         $(ETAGS) -o TAGS-LISP $(lisptagsfiles1) $(lisptagsfiles2)
201 .SUFFIXES: .elc .el
203 .el.elc:
204         -$(emacs) -f batch-byte-compile $<
206 # Compile all Lisp files, but don't recompile those that are up to
207 # date.  Some files don't actually get compiled because they set the
208 # local variable no-byte-compile.
210 # All .elc files are made writable before compilation in case we
211 # checked out read-only (CVS option -r).  Files MUST be compiled one by
212 # one.  If we compile several files in a row we can't make sure that
213 # the compilation environment is clean.  We also set the load-path of
214 # the Emacs used for compilation to the current directory and its
215 # subdirectories, to make sure require's and load's in the files being
216 # compiled find the right files.
218 # Need separate version for sh and native cmd.exe
219 compile: $(lisp)/subdirs.el mh-autoloads compile-$(SHELLTYPE) doit
221 compile-CMD:
222 #       -for %%f in ($(lisp) $(WINS)) do for %%g in (%%f\*.elc) do @attrib -r %%g
223         for %%f in ($(COMPILE_FIRST)) do \
224           $(emacs) -l loaddefs -f batch-byte-compile-if-not-done %%f
225         for %%f in (. $(WINS)) do for %%g in (%%f/*.el) do \
226           $(emacs) -l loaddefs -f batch-byte-compile-if-not-done %%f/%%g
228 compile-SH:
229 #       for elc in $(lisp)/*.elc $(lisp)/*/*.elc; do attrib -r $$elc; done
230         for el in $(COMPILE_FIRST); do \
231           echo Compiling $$el; \
232           $(emacs) -l loaddefs -f batch-byte-compile-if-not-done $$el; \
233         done
234         for dir in $(lisp) $(WINS); do \
235           for el in $$dir/*.el; do \
236             if test -f $$el; \
237             then \
238               echo Compiling $$el; \
239               $(emacs) -l loaddefs -f batch-byte-compile-if-not-done $$el; \
240             fi \
241           done; \
242         done
244 # Compile all Lisp files.  This is like `compile' but compiles files
245 # unconditionally.  Some files don't actually get compiled because they
246 # set the local variable no-byte-compile.
248 compile-always: $(lisp)/subdirs.el compile-always-$(SHELLTYPE) doit
250 compile-always-CMD:
251 #       -for %%f in ($(lisp) $(WINS)) do for %%g in (%%f\*.elc) do @attrib -r %%g
252         for %%f in ($(COMPILE_FIRST)) do $(emacs) -f batch-byte-compile %%f
253         for %%f in (. $(WINS)) do for %%g in (%%f/*.el) do $(emacs) -f batch-byte-compile %%f/%%g
255 compile-always-SH:
256 #       for elc in $(lisp)/*.elc $(lisp)/*/*.elc; do attrib -r $$elc; done
257         for el in $(COMPILE_FIRST); do \
258           echo Compiling $$el; \
259           $(emacs) -f batch-byte-compile $$el || exit 1; \
260         done
261         for dir in $(lisp) $(WINS); do \
262           for el in $$dir/*.el; do \
263             echo Compiling $$el; \
264             $(emacs) -f batch-byte-compile $$el || exit 1; \
265           done; \
266         done
268 compile-calc: compile-calc-$(SHELLTYPE)
270 compile-calc-CMD:
271         for %%f in ($(lisp)/calc/*.el) do $(emacs) -f batch-byte-compile %%f
273 compile-calc-SH:
274         for el in $(lisp)/calc/*.el; do \
275           echo Compiling $$el; \
276           $(emacs) -f batch-byte-compile $$el || exit 1; \
277         done
279 # Backup compiled Lisp files in elc.tar.gz.  If that file already
280 # exists, make a backup of it.
282 backup-compiled-files:
283         -mv $(lisp)/elc.tar.gz $(lisp)/elc.tar.gz~
284         -tar czf $(lisp)/elc.tar.gz $(lisp)/*.elc $(lisp)/*/*.elc
286 # Compile Lisp files, but save old compiled files first.
288 compile-after-backup: backup-compiled-files compile-always
290 # Recompile all Lisp files which are newer than their .elc files.
291 # Note that this doesn't create .elc files.  It only recompiles if an
292 # .elc is present.
293 # WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as
294 #          this can break with GNU Make 3.81 and later if sh.exe is used.
295 recompile: mh-autoloads doit $(lisp)/progmodes/cc-mode.elc
296         $(emacs) --eval $(ARGQUOTE)(batch-byte-recompile-directory 0)$(ARGQUOTE) $(lisp)
298 # Update MH-E internal autoloads. These are not to be confused with
299 # the autoloads for the MH-E entry points, which are already in
300 # loaddefs.el.
301 MH_E_SRC = $(lisp)/mh-e/mh-acros.el $(lisp)/mh-e/mh-alias.el    \
302         $(lisp)/mh-e/mh-buffers.el $(lisp)/mh-e/mh-compat.el    \
303         $(lisp)/mh-e/mh-comp.el $(lisp)/mh-e/mh-e.el            \
304         $(lisp)/mh-e/mh-folder.el $(lisp)/mh-e/mh-funcs.el      \
305         $(lisp)/mh-e/mh-gnus.el $(lisp)/mh-e/mh-identity.el     \
306         $(lisp)/mh-e/mh-inc.el $(lisp)/mh-e/mh-junk.el          \
307         $(lisp)/mh-e/mh-letter.el $(lisp)/mh-e/mh-limit.el      \
308         $(lisp)/mh-e/mh-mime.el $(lisp)/mh-e/mh-print.el        \
309         $(lisp)/mh-e/mh-scan.el $(lisp)/mh-e/mh-search.el       \
310         $(lisp)/mh-e/mh-seq.el $(lisp)/mh-e/mh-show.el          \
311         $(lisp)/mh-e/mh-speed.el $(lisp)/mh-e/mh-thread.el      \
312         $(lisp)/mh-e/mh-tool-bar.el $(lisp)/mh-e/mh-utils.el    \
313         $(lisp)/mh-e/mh-xface.el
315 mh-autoloads: $(lisp)/mh-e/mh-loaddefs.el
316 $(lisp)/mh-e/mh-loaddefs.el: $(MH_E_SRC)
317         $(MAKE) $(MFLAGS) pre-mh-loaddefs.el-$(SHELLTYPE)
318         cp pre-mh-loaddefs.el-$(SHELLTYPE) $@
319         rm pre-mh-loaddefs.el-$(SHELLTYPE)
320         $(EMACS) $(EMACSOPT) \
321            -l autoload \
322            --eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \
323            --eval "(setq find-file-suppress-same-file-warnings t)" \
324            --eval "(setq make-backup-files nil)" \
325            -f w32-batch-update-autoloads \
326            "$(lisp)/mh-e/mh-loaddefs.el" $(lisp)/mh-e
328 pre-mh-loaddefs.el-SH:
329         echo ";;; mh-loaddefs.el --- automatically extracted autoloads" > $@
330         echo ";;" >> $@
331         echo ";; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc." >> $@
332         echo ";; Author: Bill Wohler <wohler@newt.com>" >> $@
333         echo ";; Keywords: mail" >> $@
334         echo ";;; Commentary:" >> $@
335         echo ";;; Change Log:" >> $@
336         echo ";;; Code:" >> $@
337         echo "\f" >> $@
338         echo "(provide 'mh-loaddefs)" >> $@
339         echo ";; Local Variables:" >> $@
340         echo ";; version-control: never" >> $@
341         echo ";; no-byte-compile: t" >> $@
342         echo ";; no-update-autoloads: t" >> $@
343         echo ";; End:" >> $@
344         echo ";;; mh-loaddefs.el ends here" >> $@
346 pre-mh-loaddefs.el-CMD:
347         echo ;;; mh-loaddefs.el --- automatically extracted autoloads> $@
348         echo ;;>> $@
349         echo ;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.>> $@
350         echo ;; Author: Bill Wohler (wohler@newt.com)>> $@
351         echo ;; Keywords: mail>> $@
352         echo ;;; Commentary:>> $@
353         echo ;;; Change Log:>> $@
354         echo ;;; Code:>> $@
355         echo.\f>> $@
356         echo (provide 'mh-loaddefs)>> $@
357         echo ;; Local Variables:>> $@
358         echo ;; version-control: never>> $@
359         echo ;; no-byte-compile: t>> $@
360         echo ;; no-update-autoloads: t>> $@
361         echo ;; End:>> $@
362         echo ;;; mh-loaddefs.el ends here>> $@
364 # Prepare a bootstrap in the lisp subdirectory.
366 # Build loaddefs.el to make sure it's up-to-date.  If it's not, that
367 # might lead to errors during the bootstrap because something fails to
368 # autoload as expected.  If there is no emacs binary, then we can't
369 # build autoloads yet.  In that case we have to use ldefs-boot.el;
370 # bootstrap should always work with ldefs-boot.el.  (Because
371 # loaddefs.el is an automatically generated file, we don't want to
372 # store it in the source repository).
374 # Remove compiled Lisp files so that bootstrap-emacs will be built from
375 # sources only.
377 # Need separate version for sh and native cmd.exe
378 bootstrap-clean: bootstrap-clean-$(SHELLTYPE) $(lisp)/loaddefs.el
380 bootstrap-clean-CMD:
381 #       if exist $(EMACS) $(MAKE) $(MFLAGS) autoloads
382         cp $(lisp)/ldefs-boot.el $(lisp)/loaddefs.el
383         -for %%f in (. $(WINS)) do for %%g in (%%f\*.elc) do @$(DEL) %%g
385 bootstrap-clean-SH:
386 #       if test -f $(EMACS); then $(MAKE) $(MFLAGS) autoloads; fi
387 #       -rm -f $(lisp)/*.elc $(lisp)/*/*.elc
388         cp $(lisp)/ldefs-boot.el $(lisp)/loaddefs.el
389         -for dir in . $(WINS); do rm -f $$dir/*.elc; done
391 # Generate/update files for the bootstrap process.
392 # When done, remove bootstrap-emacs from ../bin, so that
393 # it will not be mistaken for an installed binary.
395 bootstrap: update-subdirs autoloads mh-autoloads compile finder-data custom-deps
396         - $(DEL) $(EMACS)
399 # Assuming INSTALL_DIR is defined, copy the elisp files to it
400 # Windows 95 makes this harder than it should be.
402 install:
403                 - mkdir "$(INSTALL_DIR)/lisp"
404                 - $(DEL) ../same-dir.tst
405                 - $(DEL) "$(INSTALL_DIR)/same-dir.tst"
406                 echo SameDirTest > "$(INSTALL_DIR)/same-dir.tst"
407 #ifdef COPY_LISP_SOURCE
408                 $(IFNOTSAMEDIR) $(CP_DIR) . "$(INSTALL_DIR)/lisp" $(ENDIF)
409 #else
410 #               $(IFNOTSAMEDIR) $(CP_DIR) *.elc "$(INSTALL_DIR)/lisp" $(ENDIF)
411 #               $(IFNOTSAMEDIR) $(CP) cus-load.el "$(INSTALL_DIR)/lisp" $(ENDIF)
412 #               $(IFNOTSAMEDIR) $(CP) forms*.el "$(INSTALL_DIR)/lisp" $(ENDIF)
413 #               $(IFNOTSAMEDIR) $(CP) patcomp.el "$(INSTALL_DIR)/lisp" $(ENDIF)
414 #               $(IFNOTSAMEDIR) $(CP) subdirs.el "$(INSTALL_DIR)/lisp" $(ENDIF)
415 #               $(IFNOTSAMEDIR) $(CP) version.el "$(INSTALL_DIR)/lisp" $(ENDIF)
416 #               $(IFNOTSAMEDIR) $(CP) mail/blessmail.el "$(INSTALL_DIR)/lisp/mail" $(ENDIF)
417 #               $(IFNOTSAMEDIR) $(CP) mail/sc.el "$(INSTALL_DIR)/lisp/mail" $(ENDIF)
418 #               $(IFNOTSAMEDIR) $(CP) play/bruce.el "$(INSTALL_DIR)/lisp/play" $(ENDIF)
419 #               $(IFNOTSAMEDIR) $(CP) international/latin-*.el "$(INSTALL_DIR)/lisp/international" $(ENDIF)
420 #               $(IFNOTSAMEDIR) $(CP) international/mule-conf.el "$(INSTALL_DIR)/lisp/international" $(ENDIF)
421 #endif
422                 - $(DEL) ../same-dir.tst
423                 - $(DEL) "$(INSTALL_DIR)/same-dir.tst"
426 # Maintenance
428 clean:
429                 - $(DEL) *~