Subject: Re: bug#1004: 23.0.60; Error visiting C files

From: Eli Zaretskii <[email-masked]>
Date: Sat, 20 Sep 2008 13:15:24 +0300

> Date: Fri, 19 Sep 2008 20:05:42 +0200
> From: martin rudalics <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>
> 
> >  emacs -Q
> >  C-x C-f foo.c
> > 
> > This produces error messages (see near the end of this report) and
> > does NOT enter the C Mode.
> [...]
> > Eval error in the `c-lang-defconst' for `c-cpp-matchers' in c-mode:
> > Eval error in the `c-lang-defconst' for `c-matchers-1' in c-mode:
> > File mode specification error: (error "`c-opt-cpp-prefix' got no (prior) value in c-mode (might be a cyclic reference)")
> 
> See Bug#913: 23.0.60; File mode specification error for w32.c.
> 
> What shall we do about this?

IMO, we should add explicit dependencies for cc*.elc files.  The patch
below works for me; does anyone see a problem with it?

2008-09-20  Eli Zaretskii  <[email-masked]>

	* Makefile.in ($(lisp)/progmodes/cc-mode.elc): Remove.
	($(lisp)/progmodes/cc-align.elc, $(lisp)/progmodes/cc-cmds.elc)
	($(lisp)/progmodes/cc-compat.elc, $(lisp)/progmodes/cc-defs.elc)
	($(lisp)/progmodes/cc-engine.elc)
	($(lisp)/progmodes/cc-fonts.elc, $(lisp)/progmodes/cc-langs.elc)
	($(lisp)/progmodes/cc-mode.elc, $(lisp)/progmodes/cc-styles.elc)
	($(lisp)/progmodes/cc-subword.elc)
	($(lisp)/progmodes/cc-vars.elc): New dependencies.

Index: lisp/Makefile.in
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/Makefile.in,v
retrieving revision 1.158
diff -u -r1.158 Makefile.in
--- lisp/Makefile.in	6 Sep 2008 18:22:45 -0000	1.158
+++ lisp/Makefile.in	20 Sep 2008 10:12:56 -0000
@@ -1362,15 +1362,6 @@
 recompile: doit $(LOADDEFS) $(lisp)/progmodes/cc-mode.elc
 	$(emacs) --eval "(batch-byte-recompile-directory 0)" $(lisp)
 
-# CC Mode uses a compile time macro system which causes a compile time
-# dependency in cc-mode.elc on the macros in cc-langs.el and the
-# version string in cc-defs.el.
-$(lisp)/progmodes/cc-mode.elc: \
-	$(lisp)/progmodes/cc-mode.el \
-	$(lisp)/progmodes/cc-langs.el \
-	$(lisp)/progmodes/cc-defs.el
-	$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
-
 # Update MH-E internal autoloads. These are not to be confused with
 # the autoloads for the MH-E entry points, which are already in loaddefs.el.
 MH_E_DIR = $(lisp)/mh-e
@@ -1460,4 +1451,51 @@
 	$(emacs) -l $(lisp)/emacs-lisp/check-declare \
 	  --eval '(check-declare-directory "$(lisp)")'
 
+# Dependencies
+
+# CC Mode uses a compile time macro system which causes a compile time
+# dependency in cc-*.elc files on the macros in other cc-*.el and the
+# version string in cc-defs.el.
+$(lisp)/progmodes/cc-align.elc $(lisp)/progmodes/cc-awk.elc\
+ $(lisp)/progmodes/cc-cmds.elc $(lisp)/progmodes/cc-compat.elc\
+ $(lisp)/progmodes/cc-engine.elc $(lisp)/progmodes/cc-fonts.elc\
+ $(lisp)/progmodes/cc-langs.elc $(lisp)/progmodes/cc-menus.elc\
+ $(lisp)/progmodes/cc-mode.elc $(lisp)/progmodes/cc-styles.elc\
+ $(lisp)/progmodes/cc-subword.elc $(lisp)/progmodes/cc-vars.elc: \
+   $(lisp)/progmodes/cc-bytecomp.elc $(lisp)/progmodes/cc-defs.elc
+
+$(lisp)/progmodes/cc-align.elc: \
+   $(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc
+
+$(lisp)/progmodes/cc-cmds.elc: \
+   $(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc
+
+$(lisp)/progmodes/cc-compat.elc: \
+   $(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-styles.elc \
+   $(lisp)/progmodes/cc-engine.elc
+
+$(lisp)/progmodes/cc-defs.elc: $(lisp)/progmodes/cc-bytecomp.elc \
+   $(lisp)/emacs-lisp/cl.elc $(lisp)/emacs-lisp/regexp-opt.elc
+
+$(lisp)/progmodes/cc-engine.elc: $(lisp)/progmodes/cc-langs.elc \
+   $(lisp)/progmodes/cc-vars.elc
+
+$(lisp)/progmodes/cc-fonts.elc: $(lisp)/progmodes/cc-langs.elc \
+   $(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc \
+   $(lisp)/font-lock.elc
+
+$(lisp)/progmodes/cc-langs.elc: $(lisp)/progmodes/cc-vars.elc \
+   $(lisp)/emacs-lisp/cl.elc
+
+$(lisp)/progmodes/cc-mode.elc: $(lisp)/progmodes/cc-langs.elc \
+   $(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc \
+   $(lisp)/progmodes/cc-styles.elc $(lisp)/progmodes/cc-cmds.elc \
+   $(lisp)/progmodes/cc-align.elc $(lisp)/progmodes/cc-menus.elc
+
+$(lisp)/progmodes/cc-styles.elc: $(lisp)/progmodes/cc-vars.elc \
+   $(lisp)/progmodes/cc-align.elc
+
+$(lisp)/progmodes/cc-subword.elc: $(lisp)/progmodes/cc-cmds.elc
+
+$(lisp)/progmodes/cc-vars.elc: $(lisp)/custom.elc $(lisp)/widget.elc
 # Makefile ends here.