2004-02-08 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Sun, 8 Feb 2004 21:42:06 +0000 (21:42 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sun, 8 Feb 2004 21:42:06 +0000 (21:42 +0000)
* Makefile.in (OBS): Delete.
(INIT_FILES): Replace OBS with COMMON_OBS.
(COMMON_OBS): Move DEPFILES and YYOBJ to start of definition.
(init.c): Eliminate duplicates.  Merge two greps and a sed into a
single sed.  Make .c and .o patterns more robust.

gdb/ChangeLog
gdb/Makefile.in

index f5e55e46d2e57ab0766649d0f01869c7fc637ca9..75e0806cbc71497afc0de26f82b04c406ab4cf2f 100644 (file)
@@ -1,3 +1,11 @@
+2004-02-08  Andrew Cagney  <cagney@redhat.com>
+
+       * Makefile.in (init.c): Eliminate duplicates.  Combine two greps
+       and a sed into a single sed.  Make .c and .o patterns more robust.
+       (OBS): Delete.
+       (INIT_FILES): Replace OBS with COMMON_OBS.
+       (COMMON_OBS): Move DEPFILES and YYOBJ to start of definition.
+
 2004-02-08  Mark Kettenis  <kettenis@gnu.org>
 
        * sparc-nat.c (sparc_xfer_wcookie): Try to fetch the cookie using
index 369f65c984496553bdaee6ec8605e26b4d379619..211a62b472ef85bf7248b5640124bd2b3cb58b09 100644 (file)
@@ -863,7 +863,8 @@ TAGFILES_NO_SRCDIR = $(SFILES) $(HFILES_NO_SRCDIR) $(ALLDEPFILES) \
        $(SUBDIR_CLI_SRCS)
 TAGFILES_WITH_SRCDIR = $(HFILES_WITH_SRCDIR)
 
-COMMON_OBS = version.o \
+COMMON_OBS = $(DEPFILES) $(YYOBJ) \
+       version.o \
        annotate.o \
        auxv.o \
        bfd-target.o \
@@ -878,8 +879,8 @@ COMMON_OBS = version.o \
        main.o \
        macrotab.o macrocmd.o macroexp.o macroscope.o \
        event-loop.o event-top.o inf-loop.o completer.o \
-       gdbarch.o arch-utils.o gdbtypes.o osabi.o copying.o $(DEPFILES) \
-       memattr.o mem-break.o target.o parse.o language.o $(YYOBJ) buildsym.o \
+       gdbarch.o arch-utils.o gdbtypes.o osabi.o copying.o \
+       memattr.o mem-break.o target.o parse.o language.o buildsym.o \
        std-regs.o \
        signals.o \
        kod.o kod-cisco.o \
@@ -908,8 +909,6 @@ COMMON_OBS = version.o \
        reggroups.o \
        trad-frame.o
 
-OBS = $(COMMON_OBS)
-
 TSOBS = inflow.o
 
 SUBDIRS = @subdirs@
@@ -1002,21 +1001,21 @@ uninstall: force $(CONFIG_UNINSTALL)
 # Note that the set of files with init functions might change, or the names
 # of the functions might change, so this files needs to depend on all the
 # object files that will be linked into gdb.
-#
-# FIXME: There are 2 problems with this approach. First, if the INIT_FILES
-# list includes a file twice (because of some mistake somewhere else)
-# the _initialize_* function will be included twice in init.c. Second,
-# init.c may force unnecessary files to be linked in.
+
+# FIXME: There is a problem with this approach - init.c may force
+# unnecessary files to be linked in.
 
 # FIXME: cagney/2002-06-09: gdb/564: gdb/563: Force the order so that
-# the first call is to _initialize_gdbtypes.  This is a hack to ensure
-# that all the architecture dependant global builtin_type_* variables
-# are initialized before anything else (per-architecture code is
-# called in the same order that it is registered).  The ``correct
-# fix'' is to have all the builtin types made part of the architecture
-# and initialize them on-demand (using gdbarch_data) just like
-# everything else.  The catch is that other modules still take the
-# address of these builtin types forcing them to be variables, sigh!
+# the first call is to _initialize_gdbtypes (implemented by explicitly
+# putting that function's name first in the init.l-tmp file).  This is
+# a hack to ensure that all the architecture dependant global
+# builtin_type_* variables are initialized before anything else
+# (per-architecture code is called in the same order that it is
+# registered).  The ``correct fix'' is to have all the builtin types
+# made part of the architecture and initialize them on-demand (using
+# gdbarch_data) just like everything else.  The catch is that other
+# modules still take the address of these builtin types forcing them
+# to be variables, sigh!
 
 # NOTE: cagney/2003-03-18: The sed pattern ``s|^\([^ /]...'' is
 # anchored on the first column and excludes the ``/'' character so
@@ -1025,38 +1024,51 @@ uninstall: force $(CONFIG_UNINSTALL)
 # automatically adds the $(srcdir) prefixes when it encounters files
 # in sub-directories such as cli/ and mi/.
 
-INIT_FILES = $(OBS) $(TSOBS) $(CONFIG_SRCS)
+# NOTE: cagney/2004-02-08: The ``case "$$fs" in'' eliminates
+# duplicates.  Files in the gdb/ directory can end up appearing in
+# COMMON_OBS (as a .o file) and CONFIG_SRCS (as a .c file).
+
+INIT_FILES = $(COMMON_OBS) $(TSOBS) $(CONFIG_SRCS)
 init.c: $(INIT_FILES)
        @echo Making init.c
        @rm -f init.c-tmp init.l-tmp
+       @touch init.c-tmp
+       @echo gdbtypes > init.l-tmp
        @-echo $(INIT_FILES) | \
        tr ' ' '\012' | \
        sed \
-           -e '/^init.o/d' \
-           -e '/xdr_ld.o/d' \
-           -e '/xdr_ptrace.o/d' \
-           -e '/xdr_rdb.o/d' \
-           -e '/udr.o/d' \
-           -e '/udip2soc.o/d' \
-           -e '/udi2go32.o/d' \
-           -e '/version.o/d' \
-           -e '/^[a-z0-9A-Z_]*_[SU].o/d' \
-           -e '/[a-z0-9A-Z_]*-exp.tab.o/d' \
-           -e 's/\.o/.c/' \
+           -e '/^gdbtypes.[co]$$/d' \
+           -e '/^init.[co]$$/d' \
+           -e '/xdr_ld.[co]$$/d' \
+           -e '/xdr_ptrace.[co]$$/d' \
+           -e '/xdr_rdb.[co]$$/d' \
+           -e '/udr.[co]$$/d' \
+           -e '/udip2soc.[co]$$/d' \
+           -e '/udi2go32.[co]$$/d' \
+           -e '/version.[co]$$/d' \
+           -e '/^[a-z0-9A-Z_]*_[SU].[co]$$/d' \
+           -e '/[a-z0-9A-Z_]*-exp.tab.[co]$$/d' \
+           -e 's/\.[co]$$/.c/' \
            -e 's,signals\.c,signals/signals\.c,' \
            -e 's|^\([^  /][^     ]*\)|$(srcdir)/\1|g' | \
-       while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \
-       sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/\1/' | \
-       ( echo _initialize_gdbtypes ; grep -v '^_initialize_gdbtypes$$' ) > init.l-tmp
+       while read f; do \
+           sed -n -e 's/^_initialize_\([a-z_0-9A-Z]*\).*/\1/p' $$f 2>/dev/null; \
+       done | \
+       while read f; do \
+           case "$$fs" in \
+               "* $$f *") ;; \
+               *) echo $$f ; fs="$$fs $$f ";; \
+            esac; \
+       done >> init.l-tmp
        @echo '/* Do not modify this file.  */' >>init.c-tmp
        @echo '/* It is created automatically by the Makefile.  */'>>init.c-tmp
-       @echo '#include "defs.h"' >>init.c-tmp
-       @echo '#include "call-cmds.h"' >>init.c-tmp
-       @sed -e 's/\(.*\)/extern initialize_file_ftype \1;/' <init.l-tmp >>init.c-tmp
+       @echo '#include "defs.h"      /* For initialize_file_ftype.  */' >>init.c-tmp
+       @echo '#include "call-cmds.h" /* For initialize_all_files.  */' >>init.c-tmp
+       @sed -e 's/\(.*\)/extern initialize_file_ftype _initialize_\1;/' <init.l-tmp >>init.c-tmp
        @echo 'void' >>init.c-tmp
        @echo 'initialize_all_files (void)' >>init.c-tmp
        @echo '{' >>init.c-tmp
-       @sed -e 's/\(.*\)/  \1 ();/' <init.l-tmp >>init.c-tmp
+       @sed -e 's/\(.*\)/  _initialize_\1 ();/' <init.l-tmp >>init.c-tmp
        @echo '}' >>init.c-tmp
        @rm init.l-tmp
        @mv init.c-tmp init.c
@@ -1079,7 +1091,7 @@ nlm:      force
 # against that.
 #
 # init.o is very important.  It pulls in the rest of GDB.
-LIBGDB_OBS= $(OBS) $(TSOBS) $(ADD_FILES) init.o
+LIBGDB_OBS= $(COMMON_OBS) $(TSOBS) $(ADD_FILES) init.o
 libgdb.a: $(LIBGDB_OBS)
        -rm -f libgdb.a
        $(AR) q libgdb.a $(LIBGDB_OBS)
This page took 0.030065 seconds and 4 git commands to generate.