mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
/* Dependency generator for Makefile fragments.
|
2022-01-03 10:42:10 +01:00
|
|
|
Copyright (C) 2000-2022 Free Software Foundation, Inc.
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
Contributed by Zack Weinberg, Mar 2000
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
Free Software Foundation; either version 3, or (at your option) any
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2009-04-09 17:00:19 +02:00
|
|
|
along with this program; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>.
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
|
|
|
In other words, you are welcome to use, share and improve this program.
|
|
|
|
You are forbidden to forbid anyone else to use, share and improve
|
|
|
|
what you give them. Help stamp out software-hoarding! */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "mkdeps.h"
|
2020-11-03 13:59:48 +01:00
|
|
|
#include "internal.h"
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
/* Not set up to just include std::vector et al, here's a simple
|
|
|
|
implementation. */
|
|
|
|
|
2001-01-04 11:25:55 +01:00
|
|
|
/* Keep this structure local to this file, so clients don't find it
|
|
|
|
easy to start making assumptions. */
|
2019-07-09 18:36:00 +02:00
|
|
|
class mkdeps
|
2001-01-04 11:25:55 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
public:
|
|
|
|
/* T has trivial cctor & dtor. */
|
|
|
|
template <typename T>
|
|
|
|
class vec
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
T *ary;
|
|
|
|
unsigned num;
|
|
|
|
unsigned alloc;
|
|
|
|
|
|
|
|
public:
|
|
|
|
vec ()
|
|
|
|
: ary (NULL), num (0), alloc (0)
|
|
|
|
{}
|
|
|
|
~vec ()
|
|
|
|
{
|
|
|
|
XDELETEVEC (ary);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
unsigned size () const
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
return num;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
const T &operator[] (unsigned ix) const
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
return ary[ix];
|
|
|
|
}
|
2019-06-26 14:58:39 +02:00
|
|
|
T &operator[] (unsigned ix)
|
|
|
|
{
|
|
|
|
return ary[ix];
|
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
void push (const T &elt)
|
|
|
|
{
|
|
|
|
if (num == alloc)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
alloc = alloc ? alloc * 2 : 16;
|
|
|
|
ary = XRESIZEVEC (T, ary, alloc);
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
ary[num++] = elt;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
};
|
|
|
|
struct velt
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
size_t len;
|
|
|
|
};
|
|
|
|
|
|
|
|
mkdeps ()
|
2020-11-18 15:44:38 +01:00
|
|
|
: module_name (NULL), cmi_name (NULL), is_header_unit (false), quote_lwm (0)
|
2019-05-07 14:39:59 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
~mkdeps ()
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = targets.size (); i--;)
|
|
|
|
free (const_cast <char *> (targets[i]));
|
|
|
|
for (i = deps.size (); i--;)
|
|
|
|
free (const_cast <char *> (deps[i]));
|
|
|
|
for (i = vpath.size (); i--;)
|
|
|
|
XDELETEVEC (vpath[i].str);
|
2020-11-18 15:44:38 +01:00
|
|
|
for (i = modules.size (); i--;)
|
|
|
|
XDELETEVEC (modules[i]);
|
|
|
|
XDELETEVEC (module_name);
|
|
|
|
free (const_cast <char *> (cmi_name));
|
2019-05-07 14:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
vec<const char *> targets;
|
|
|
|
vec<const char *> deps;
|
|
|
|
vec<velt> vpath;
|
2020-11-18 15:44:38 +01:00
|
|
|
vec<const char *> modules;
|
2019-05-07 14:39:59 +02:00
|
|
|
|
|
|
|
public:
|
2020-11-18 15:44:38 +01:00
|
|
|
const char *module_name;
|
|
|
|
const char *cmi_name;
|
|
|
|
bool is_header_unit;
|
2019-05-07 14:39:59 +02:00
|
|
|
unsigned short quote_lwm;
|
|
|
|
};
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2020-11-17 15:45:18 +01:00
|
|
|
/* Apply Make quoting to STR, TRAIL. Note that it's not possible to
|
|
|
|
quote all such characters - e.g. \n, %, *, ?, [, \ (in some
|
2019-05-07 14:39:59 +02:00
|
|
|
contexts), and ~ are not properly handled. It isn't possible to
|
|
|
|
get this right in any current version of Make. (??? Still true?
|
|
|
|
Old comment referred to 3.76.1.) */
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2004-06-05 22:58:06 +02:00
|
|
|
static const char *
|
2020-11-17 15:45:18 +01:00
|
|
|
munge (const char *str, const char *trail = nullptr)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
static unsigned alloc;
|
|
|
|
static char *buf;
|
|
|
|
unsigned dst = 0;
|
|
|
|
|
2020-11-17 15:45:18 +01:00
|
|
|
for (; str; str = trail, trail = nullptr)
|
2004-06-05 22:58:06 +02:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
unsigned slashes = 0;
|
|
|
|
char c;
|
|
|
|
for (const char *probe = str; (c = *probe++);)
|
2004-06-05 22:58:06 +02:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
if (alloc < dst + 4 + slashes)
|
2004-06-05 22:58:06 +02:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
alloc = alloc * 2 + 32;
|
|
|
|
buf = XRESIZEVEC (char, buf, alloc);
|
|
|
|
}
|
2004-06-05 22:58:06 +02:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '\\':
|
|
|
|
slashes++;
|
|
|
|
break;
|
2004-06-05 22:58:06 +02:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
case '$':
|
|
|
|
buf[dst++] = '$';
|
|
|
|
goto def;
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
/* GNU make uses a weird quoting scheme for white space.
|
|
|
|
A space or tab preceded by 2N+1 backslashes
|
|
|
|
represents N backslashes followed by space; a space
|
|
|
|
or tab preceded by 2N backslashes represents N
|
|
|
|
backslashes at the end of a file name; and
|
|
|
|
backslashes in other contexts should not be
|
|
|
|
doubled. */
|
|
|
|
while (slashes--)
|
|
|
|
buf[dst++] = '\\';
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
|
|
|
case '#':
|
|
|
|
buf[dst++] = '\\';
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
|
|
|
default:
|
|
|
|
def:
|
|
|
|
slashes = 0;
|
2004-06-05 22:58:06 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
|
|
|
|
buf[dst++] = c;
|
2004-06-05 22:58:06 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
|
|
|
|
buf[dst] = 0;
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If T begins with any of the partial pathnames listed in d->vpathv,
|
|
|
|
then advance T to point beyond that pathname. */
|
|
|
|
static const char *
|
2019-07-09 20:32:49 +02:00
|
|
|
apply_vpath (class mkdeps *d, const char *t)
|
2019-05-07 14:39:59 +02:00
|
|
|
{
|
|
|
|
if (unsigned len = d->vpath.size ())
|
|
|
|
for (unsigned i = len; i--;)
|
|
|
|
{
|
|
|
|
if (!filename_ncmp (d->vpath[i].str, t, d->vpath[i].len))
|
|
|
|
{
|
|
|
|
const char *p = t + d->vpath[i].len;
|
|
|
|
if (!IS_DIR_SEPARATOR (*p))
|
|
|
|
goto not_this_one;
|
|
|
|
|
|
|
|
/* Do not simplify $(vpath)/../whatever. ??? Might not
|
|
|
|
be necessary. */
|
|
|
|
if (p[1] == '.' && p[2] == '.' && IS_DIR_SEPARATOR (p[3]))
|
|
|
|
goto not_this_one;
|
|
|
|
|
|
|
|
/* found a match */
|
|
|
|
t = t + d->vpath[i].len + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
not_this_one:;
|
|
|
|
}
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2004-06-05 22:58:06 +02:00
|
|
|
/* Remove leading ./ in any case. */
|
|
|
|
while (t[0] == '.' && IS_DIR_SEPARATOR (t[1]))
|
2007-01-30 16:50:00 +01:00
|
|
|
{
|
|
|
|
t += 2;
|
|
|
|
/* If we removed a leading ./, then also remove any /s after the
|
|
|
|
first. */
|
|
|
|
while (IS_DIR_SEPARATOR (t[0]))
|
|
|
|
++t;
|
|
|
|
}
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2004-06-05 22:58:06 +02:00
|
|
|
return t;
|
|
|
|
}
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2004-06-05 22:58:06 +02:00
|
|
|
/* Public routines. */
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-07-09 20:32:49 +02:00
|
|
|
class mkdeps *
|
2004-06-05 22:58:06 +02:00
|
|
|
deps_init (void)
|
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
return new mkdeps ();
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_free (class mkdeps *d)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
delete d;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
|
|
|
|
2001-01-05 08:50:24 +01:00
|
|
|
/* Adds a target T. We make a copy, so it need not be a permanent
|
|
|
|
string. QUOTE is true if the string should be quoted. */
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
void
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_add_target (class mkdeps *d, const char *t, int quote)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-06-26 14:58:39 +02:00
|
|
|
t = xstrdup (apply_vpath (d, t));
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
if (!quote)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-06-26 14:58:39 +02:00
|
|
|
/* Sometimes unquoted items are added after quoted ones.
|
|
|
|
Swap out the lowest quoted. */
|
|
|
|
if (d->quote_lwm != d->targets.size ())
|
|
|
|
{
|
|
|
|
const char *lowest = d->targets[d->quote_lwm];
|
|
|
|
d->targets[d->quote_lwm] = t;
|
|
|
|
t = lowest;
|
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
d->quote_lwm++;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
tree.h (INT_CST_LT, [...]): Remove unneeded casts.
* tree.h (INT_CST_LT, INT_CST_LT_UNSIGNED): Remove unneeded casts.
(struct tree_int_cst): int_cst_low is now unsigned HOST_WIDE_INT.
(attribute_hash_list, type_hash_canon): hashcode is now unsigned.
(type_hash_lookup, type_hash_add, type_hash_list): Likewise.
(min_precision): Result is unsignd.
(add_double, neg_double, mul_double): Low word is unsigned.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double): Likewise.
(tree_floor_log2, compare_tree_int): New functions.
(preserve_rtl_expr_temps): New declaration.
* c-common.c (declare_hidden_char_array): Use compare_tree_int.
(decl_attributes): Use tree_log2 to find alignment.
Check for TREE_INT_CST_HIGH for format args.
(min_precision): Now unsigned.
Use tree_floor_log2.
(truthvalue_conversion): Delete long-disabled code.
* c-decl.c (finish_struct): Clean up tests on field width.
(finish_function): Use compare_tree_int.
* c-pragma.c (handle_pragma_token): Use tree_log2 for alignment.
* c-typeck.c (comptypes): Use tree_int_cst_equal.
(default_conversion, digest_init): Use compare_tree_int.
(build_binary_op): Use integer_all_onesp and compare_tree_int.
Fix type errors in forming masks.
* calls.c (initialize_argument_information): Use compare_tree_int.
* dbxout.c (dbxout_type): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* except.c (expand_eh_region_start_tree): Use compare_tree_int.
* expr.c (is_zeros_p, case INTEGER_CST): Use integer_zerop.
(store_field): Use compare_tree_int.
(expand_expr, case CONSTRUCTOR): Use TYPE_SIZE_UNIT.
(expand_expr, case ARRAY_REF): Use compare_tree_int.
(do_jump, case BIT_AND_EXPR): Use tree_floor_log2.
(do_store_flag): Use compare_tree_int.
* fold-const.c (encode, decode): Low part is always unsigned.
(force_fit_type, add_double, neg_double, mul_double): Likewise.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double, int_const_binop): Likewise.
(fold_convert): Use compare_tree_int.
(operand_equal_p, case INTEGER_CST): Use tree_int_cst_equal.
(invert_truthvalue, case INTEGER_CST): Likewise.
(fold): Use compare_tree_int; add casts for unsigned TREE_INT_CST_LOW.
* mkdeps.c (deps_dummy_targets): Make I unsigned.
* rtl.h (add_double, neg_double, mul_double): Low words are unsigned.
(lshift_double, rshift_double, lrotate_double, rrotate_double):
Likewise.
* stmt.c (expand_decl): Use compare_tree_int and mode_for_size_tree.
(expand_end_case): Use compare_tree_int.
(estimate_case_costs): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* stor-layout.c (mode_for_size_tree): Use compare_tree_int.
(layout_decl): Likewise.
(layout_record, layout_union): Make sizes unsigned.
(layout_type, case VOID_TYPE): TYPE_SIZE must be bitsizetype.
(layout_type, case QUAL_UNION_TYPE): Use compare_tree_int.
* tree.c (struct type_hash): hashcode is unsigned.
(build_type_attribute_variant, type_hash_list): Likewise.
(type_hash_lookup, type_hash_add, type_hash_canon): Likewise.
(attribute_hash_list, build_array_type, build_method_type): Likewise.
(build_complex_type): Likewise.
(real_value_from_int_cst): Remove unneeded casts.
(integer_all_onesp): Add casts.
(tree_floor_log2, compare_tree_int): New functions.
(build_index_type): Use tree_int_cst_sgn.
* varasm.c (assemble_variable): Use compare_tree_int.
* ch/actions.c (chill_convert_for_assignment): INDEX is unsigned
HOST_WIDE_INT.
* ch/ch-tree.h (DECL_NESTING_LEVEL): Use TREE_INT_CST_HIGH
since unsigned.
* ch/except.c (chill_handle_on_labels): ALTERNATIVE is unsigned.
Use compare_tree_int.
(expand_goto_except_cleanup): Likewise.
* cp/class.c (dfs_modify_vtables): I is now unsigned.
(check_bitfield_decl): Use tree_int_cst_sgn and compare_tree_int.
(build_base_field): Add casts of TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/error.c (dump_expr): Cast TREE_INT_CST_HIGH to unsigned.
* cp/init.c (build_vec_init): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/method.c (build_overload_int): Cast TREE_INT_CST_HIGH to unsigned.
* cp/typeck.c (build_binary_op, case TRUNC_DIV_EXPR):
Call integer_all_onesp.
* cp/typeck2.c (process_init_constructor): Use compare_tree_int.
* f/com.c (ffecom_f2c_set_lio_code_): Use compare_tree_int.
(ffecom_sym_transform_, ffecom_transform_common_): Likewise.
(ffecom_transform_equiv_): Likewise.
* java/decl.c (emit_init_test_initialization): Mark KEY as unused.
* java/expr.c (build_newarray): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
(build_anewarray): Likewise.
* java/parse.y (patch_newarray): Likewise.
* java/parse.c: Regenerated.
From-SVN: r32383
2000-03-07 12:41:32 +01:00
|
|
|
|
2019-06-26 14:58:39 +02:00
|
|
|
d->targets.push (t);
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
|
|
|
|
2001-01-04 11:25:55 +01:00
|
|
|
/* Sets the default target if none has been given already. An empty
|
2001-01-05 08:50:24 +01:00
|
|
|
string as the default target in interpreted as stdin. The string
|
|
|
|
is quoted for MAKE. */
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
void
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_add_default_target (class mkdeps *d, const char *tgt)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2001-01-04 11:25:55 +01:00
|
|
|
/* Only if we have no targets. */
|
2019-05-07 14:39:59 +02:00
|
|
|
if (d->targets.size ())
|
2001-01-04 11:25:55 +01:00
|
|
|
return;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2001-01-04 11:25:55 +01:00
|
|
|
if (tgt[0] == '\0')
|
2020-01-16 10:41:44 +01:00
|
|
|
d->targets.push (xstrdup ("-"));
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
else
|
2001-01-04 11:25:55 +01:00
|
|
|
{
|
2001-04-19 22:28:05 +02:00
|
|
|
#ifndef TARGET_OBJECT_SUFFIX
|
|
|
|
# define TARGET_OBJECT_SUFFIX ".o"
|
2001-01-04 11:25:55 +01:00
|
|
|
#endif
|
2001-08-03 17:42:25 +02:00
|
|
|
const char *start = lbasename (tgt);
|
2005-05-28 17:52:48 +02:00
|
|
|
char *o = (char *) alloca (strlen (start)
|
|
|
|
+ strlen (TARGET_OBJECT_SUFFIX) + 1);
|
2001-02-12 15:06:22 +01:00
|
|
|
char *suffix;
|
2001-01-04 11:25:55 +01:00
|
|
|
|
2001-02-12 15:06:22 +01:00
|
|
|
strcpy (o, start);
|
2003-07-06 11:56:09 +02:00
|
|
|
|
2001-02-12 15:06:22 +01:00
|
|
|
suffix = strrchr (o, '.');
|
|
|
|
if (!suffix)
|
|
|
|
suffix = o + strlen (o);
|
2001-04-19 22:28:05 +02:00
|
|
|
strcpy (suffix, TARGET_OBJECT_SUFFIX);
|
2003-07-06 11:56:09 +02:00
|
|
|
|
2001-01-05 08:50:24 +01:00
|
|
|
deps_add_target (d, o, 1);
|
2001-01-04 11:25:55 +01:00
|
|
|
}
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_add_dep (class mkdeps *d, const char *t)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 20:13:57 +02:00
|
|
|
gcc_assert (*t);
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
t = apply_vpath (d, t);
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
d->deps.push (xstrdup (t));
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
|
|
|
|
2004-06-05 22:58:06 +02:00
|
|
|
void
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_add_vpath (class mkdeps *d, const char *vpath)
|
2004-06-05 22:58:06 +02:00
|
|
|
{
|
|
|
|
const char *elem, *p;
|
|
|
|
|
|
|
|
for (elem = vpath; *elem; elem = p)
|
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
for (p = elem; *p && *p != ':'; p++)
|
|
|
|
continue;
|
|
|
|
mkdeps::velt elt;
|
|
|
|
elt.len = p - elem;
|
|
|
|
char *str = XNEWVEC (char, elt.len + 1);
|
|
|
|
elt.str = str;
|
|
|
|
memcpy (str, elem, elt.len);
|
|
|
|
str[elt.len] = '\0';
|
2004-06-05 22:58:06 +02:00
|
|
|
if (*p == ':')
|
|
|
|
p++;
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
d->vpath.push (elt);
|
2004-06-05 22:58:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-18 15:44:38 +01:00
|
|
|
/* Add a new module target (there can only be one). M is the module
|
|
|
|
name. */
|
|
|
|
|
|
|
|
void
|
|
|
|
deps_add_module_target (struct mkdeps *d, const char *m,
|
|
|
|
const char *cmi, bool is_header_unit)
|
|
|
|
{
|
|
|
|
gcc_assert (!d->module_name);
|
|
|
|
|
|
|
|
d->module_name = xstrdup (m);
|
|
|
|
d->is_header_unit = is_header_unit;
|
|
|
|
d->cmi_name = xstrdup (cmi);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a new module dependency. M is the module name. */
|
|
|
|
|
|
|
|
void
|
|
|
|
deps_add_module_dep (struct mkdeps *d, const char *m)
|
|
|
|
{
|
|
|
|
d->modules.push (xstrdup (m));
|
|
|
|
}
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
/* Write NAME, with a leading space to FP, a Makefile. Advance COL as
|
|
|
|
appropriate, wrap at COLMAX, returning new column number. Iff
|
|
|
|
QUOTE apply quoting. Append TRAIL. */
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
static unsigned
|
|
|
|
make_write_name (const char *name, FILE *fp, unsigned col, unsigned colmax,
|
|
|
|
bool quote = true, const char *trail = NULL)
|
|
|
|
{
|
|
|
|
if (quote)
|
2020-11-17 15:45:18 +01:00
|
|
|
name = munge (name, trail);
|
2019-05-07 14:39:59 +02:00
|
|
|
unsigned size = strlen (name);
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
if (col)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
if (colmax && col + size> colmax)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
fputs (" \\\n", fp);
|
|
|
|
col = 0;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
col++;
|
|
|
|
fputs (" ", fp);
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
col += size;
|
|
|
|
fputs (name, fp);
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
return col;
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2003-07-06 11:56:09 +02:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
/* Write all the names in VEC via make_write_name. */
|
|
|
|
|
|
|
|
static unsigned
|
|
|
|
make_write_vec (const mkdeps::vec<const char *> &vec, FILE *fp,
|
|
|
|
unsigned col, unsigned colmax, unsigned quote_lwm = 0,
|
|
|
|
const char *trail = NULL)
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
for (unsigned ix = 0; ix != vec.size (); ix++)
|
|
|
|
col = make_write_name (vec[ix], fp, col, colmax, ix >= quote_lwm, trail);
|
|
|
|
return col;
|
|
|
|
}
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
/* Write the dependencies to a Makefile. If PHONY is true, add
|
|
|
|
.PHONY targets for all the dependencies too. */
|
|
|
|
|
|
|
|
static void
|
2020-11-03 13:59:48 +01:00
|
|
|
make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
|
2019-05-07 14:39:59 +02:00
|
|
|
{
|
2020-11-03 13:59:48 +01:00
|
|
|
const mkdeps *d = pfile->deps;
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
unsigned column = 0;
|
|
|
|
if (colmax && colmax < 34)
|
|
|
|
colmax = 34;
|
|
|
|
|
|
|
|
if (d->deps.size ())
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm);
|
2020-11-18 15:44:38 +01:00
|
|
|
if (CPP_OPTION (pfile, deps.modules) && d->cmi_name)
|
|
|
|
column = make_write_name (d->cmi_name, fp, column, colmax);
|
2019-05-07 14:39:59 +02:00
|
|
|
fputs (":", fp);
|
|
|
|
column++;
|
2019-07-03 10:34:20 +02:00
|
|
|
make_write_vec (d->deps, fp, column, colmax);
|
2019-05-07 14:39:59 +02:00
|
|
|
fputs ("\n", fp);
|
2020-11-03 13:59:48 +01:00
|
|
|
if (CPP_OPTION (pfile, deps.phony_targets))
|
2019-05-07 14:39:59 +02:00
|
|
|
for (unsigned i = 1; i < d->deps.size (); i++)
|
|
|
|
fprintf (fp, "%s:\n", munge (d->deps[i]));
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2020-11-18 15:44:38 +01:00
|
|
|
|
|
|
|
if (!CPP_OPTION (pfile, deps.modules))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (d->modules.size ())
|
|
|
|
{
|
|
|
|
column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm);
|
|
|
|
if (d->cmi_name)
|
|
|
|
column = make_write_name (d->cmi_name, fp, column, colmax);
|
|
|
|
fputs (":", fp);
|
|
|
|
column++;
|
|
|
|
column = make_write_vec (d->modules, fp, column, colmax, 0, ".c++m");
|
|
|
|
fputs ("\n", fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->module_name)
|
|
|
|
{
|
|
|
|
if (d->cmi_name)
|
|
|
|
{
|
|
|
|
/* module-name : cmi-name */
|
|
|
|
column = make_write_name (d->module_name, fp, 0, colmax,
|
|
|
|
true, ".c++m");
|
|
|
|
fputs (":", fp);
|
|
|
|
column++;
|
|
|
|
column = make_write_name (d->cmi_name, fp, column, colmax);
|
|
|
|
fputs ("\n", fp);
|
|
|
|
|
|
|
|
column = fprintf (fp, ".PHONY:");
|
|
|
|
column = make_write_name (d->module_name, fp, column, colmax,
|
|
|
|
true, ".c++m");
|
|
|
|
fputs ("\n", fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->cmi_name && !d->is_header_unit)
|
|
|
|
{
|
|
|
|
/* An order-only dependency.
|
|
|
|
cmi-name :| first-target
|
|
|
|
We can probably drop this this in favour of Make-4.3's grouped
|
|
|
|
targets '&:' */
|
|
|
|
column = make_write_name (d->cmi_name, fp, 0, colmax);
|
|
|
|
fputs (":|", fp);
|
|
|
|
column++;
|
|
|
|
column = make_write_name (d->targets[0], fp, column, colmax);
|
|
|
|
fputs ("\n", fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->modules.size ())
|
|
|
|
{
|
|
|
|
column = fprintf (fp, "CXX_IMPORTS +=");
|
|
|
|
make_write_vec (d->modules, fp, column, colmax, 0, ".c++m");
|
|
|
|
fputs ("\n", fp);
|
|
|
|
}
|
mkdeps.c, mkdeps.h: New files.
* mkdeps.c, mkdeps.h: New files.
* po/POTFILES.in: Add them.
* Makefile.in (LIBCPP_OBJS): Add mkdeps.o.
(cpplib.o, cppinit.o): Depend on mkdeps.h.
(mkdeps.o): New target.
* cppfiles.c: Delete deps_output.
* cppinit.c: Include mkdeps.h. Delete known_suffixes,
OBJECT_SUFFIX, and base_name.
(cpp_cleanup): Use deps_free. Free ihash->name when clearing
the include hash.
(initialize_dependency_output): Use deps_init,
deps_add_target, deps_calc_target, and deps_add_dep. Remove
all the unnecessary string bashing.
(cpp_finish): Use deps_write. Remove an unnecessary nesting
level.
* cpplib.c (do_include): Use deps_add_dep.
* cpplib.h (struct cpp_reader): Replace deps_buffer,
deps_allocated_size, deps_size, deps_column members with
single pointer to a struct deps. Delete prototype of
deps_output.
From-SVN: r32329
2000-03-04 20:42:04 +01:00
|
|
|
}
|
2003-01-10 03:22:34 +01:00
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
/* Write out dependencies according to the selected format (which is
|
|
|
|
only Make at the moment). */
|
2020-11-03 13:59:48 +01:00
|
|
|
/* Really we should be opening fp here. */
|
2019-05-07 14:39:59 +02:00
|
|
|
|
|
|
|
void
|
2020-11-03 13:59:48 +01:00
|
|
|
deps_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
|
2019-05-07 14:39:59 +02:00
|
|
|
{
|
2020-11-03 13:59:48 +01:00
|
|
|
make_write (pfile, fp, colmax);
|
2019-05-07 14:39:59 +02:00
|
|
|
}
|
|
|
|
|
2003-01-10 03:22:34 +01:00
|
|
|
/* Write out a deps buffer to a file, in a form that can be read back
|
|
|
|
with deps_restore. Returns nonzero on error, in which case the
|
|
|
|
error number will be in errno. */
|
|
|
|
|
|
|
|
int
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_save (class mkdeps *deps, FILE *f)
|
2003-01-10 03:22:34 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2019-05-07 14:39:59 +02:00
|
|
|
size_t size;
|
2003-01-10 03:22:34 +01:00
|
|
|
|
|
|
|
/* The cppreader structure contains makefile dependences. Write out this
|
|
|
|
structure. */
|
|
|
|
|
|
|
|
/* The number of dependences. */
|
2019-05-07 14:39:59 +02:00
|
|
|
size = deps->deps.size ();
|
|
|
|
if (fwrite (&size, sizeof (size), 1, f) != 1)
|
|
|
|
return -1;
|
|
|
|
|
2003-01-10 03:22:34 +01:00
|
|
|
/* The length of each dependence followed by the string. */
|
2019-05-07 14:39:59 +02:00
|
|
|
for (i = 0; i < deps->deps.size (); i++)
|
2003-01-10 03:22:34 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
size = strlen (deps->deps[i]);
|
|
|
|
if (fwrite (&size, sizeof (size), 1, f) != 1)
|
|
|
|
return -1;
|
|
|
|
if (fwrite (deps->deps[i], size, 1, f) != 1)
|
|
|
|
return -1;
|
2003-01-10 03:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read back dependency information written with deps_save into
|
2019-05-07 14:39:59 +02:00
|
|
|
the deps sizefer. The third argument may be NULL, in which case
|
2003-01-10 03:22:34 +01:00
|
|
|
the dependency information is just skipped, or it may be a filename,
|
|
|
|
in which case that filename is skipped. */
|
|
|
|
|
|
|
|
int
|
2019-07-09 20:32:49 +02:00
|
|
|
deps_restore (class mkdeps *deps, FILE *fd, const char *self)
|
2003-01-10 03:22:34 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
size_t size;
|
|
|
|
char *buf = NULL;
|
|
|
|
size_t buf_size = 0;
|
2003-01-10 03:22:34 +01:00
|
|
|
|
|
|
|
/* Number of dependences. */
|
2019-05-07 14:39:59 +02:00
|
|
|
if (fread (&size, sizeof (size), 1, fd) != 1)
|
2003-01-10 03:22:34 +01:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* The length of each dependence string, followed by the string. */
|
2019-05-07 14:39:59 +02:00
|
|
|
for (unsigned i = size; i--;)
|
2003-01-10 03:22:34 +01:00
|
|
|
{
|
|
|
|
/* Read in # bytes in string. */
|
2019-05-07 14:39:59 +02:00
|
|
|
if (fread (&size, sizeof (size), 1, fd) != 1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (size >= buf_size)
|
2003-01-10 03:22:34 +01:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
buf_size = size + 512;
|
2005-05-28 17:52:48 +02:00
|
|
|
buf = XRESIZEVEC (char, buf, buf_size);
|
2003-01-10 03:22:34 +01:00
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
if (fread (buf, 1, size, fd) != size)
|
2012-10-15 22:08:57 +02:00
|
|
|
{
|
2019-05-07 14:39:59 +02:00
|
|
|
XDELETEVEC (buf);
|
2012-10-15 22:08:57 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2019-05-07 14:39:59 +02:00
|
|
|
buf[size] = 0;
|
2003-01-10 03:22:34 +01:00
|
|
|
|
2003-07-06 11:56:09 +02:00
|
|
|
/* Generate makefile dependencies from .pch if -nopch-deps. */
|
2011-03-25 20:11:26 +01:00
|
|
|
if (self != NULL && filename_cmp (buf, self) != 0)
|
2003-01-10 03:22:34 +01:00
|
|
|
deps_add_dep (deps, buf);
|
|
|
|
}
|
|
|
|
|
2019-05-07 14:39:59 +02:00
|
|
|
XDELETEVEC (buf);
|
2003-01-10 03:22:34 +01:00
|
|
|
return 0;
|
|
|
|
}
|