Skip to content
Open
33 changes: 29 additions & 4 deletions doc/make.texi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@include version.texi
@set EDITION 0.75

@settitle GNU @code{make}
@settitle GNU @code{[re]make}
@setchapternewpage odd
@c Combine the variable and function indices:
@syncodeindex vr fn
Expand All @@ -17,7 +17,7 @@
@c %**end of header

@copying
This file documents the GNU @code{make} utility, which determines
This file documents the GNU @code{[re]make} utility, which determines
automatically which pieces of a large program need to be recompiled,
and issues the commands to recompile them.

Expand Down Expand Up @@ -1154,9 +1154,10 @@ var := oneword

@c following paragraph rewritten to avoid overfull hbox
By default, when @code{make} looks for the makefile, it tries the
following names, in order: @file{GNUmakefile}, @file{makefile}
following names, in order: @file{GNUremakefile}, @file{GNUmakefile}, @file{makefile}
and @file{Makefile}.@refill
@findex Makefile
@findex GNUremakefile
@findex GNUmakefile
@findex makefile

Expand Down Expand Up @@ -7626,9 +7627,33 @@ separators (@code{/}). Note that, in contrast to @code{realpath}
function, @code{abspath} does not resolve symlinks and does not require
the file names to refer to an existing file or directory. Use the
@code{wildcard} function to test for existence.

@item $(this_line)
@findex this_line
@cindex this_line, function
The invocation @code{$(this_line)} expands to the current line
number. It is inspired by the @code{__LINE__} magical macro of the C
programming language.


@item $(this_file)
@findex this_file
@cindex this_file, function
The invocation @code{$(this_file)} expands to the current filename,
e.g. to @code{Makefile}. It is inspired by the @code{__FILE__}
magical macro of the C programming language.


@item $(this_counter)
@findex this_counter
@cindex this_counter, function
The invocation @code{$(this_counter)} expands to a unique, incremented,
counter (in decimal). It is inspired by the @code{__COUNTER__} magical
macro of the C programming language understood by GCC.

@end table

@node Conditional Functions, Foreach Function, File Name Functions, Functions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting an in build because this @node line is missing:

make
Making all in lib
make[1]: Entering directory '/tmp/remake/lib'


make.texi:12429: @xref reference to nonexistent node `Conditional Functions'
make.texi:12435: @xref reference to nonexistent node `Conditional Functions'
make.texi:12442: @xref reference to nonexistent node `Conditional Functions'
make.texi:7030: @menu reference to nonexistent node `Conditional Functions'
make.texi:278: @detailmenu reference to nonexistent node `Conditional Functions'
make.texi:7455: Next reference to nonexistent `Conditional Functions'
make.texi:7708: Prev reference to nonexistent `Conditional Functions'
Makefile:918: *** [make.info] error 1


Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you help (perhaps by patching the pull request). I am not familiar witrh texinfo. But you could use the C code and improve/correct the documentation. Thanks. Basile Starynkevitch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - #116 started. (I thought when you open a PR there's a button that allows maintainers to add more commits. I didn't see that here so a new PR was started).

I don't see though that the this_ functions do anything. See that PR for details.


@section Functions for Conditionals
@findex if
@cindex conditional expansion
Expand Down
68 changes: 67 additions & 1 deletion src/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,65 @@ func_value (char *o, char **argv, const char *funcname UNUSED)
return o;
}

///// added by <basile@starynkevitch.net>


/**
$(this_file)

Always expands to the current Makefile path. Inspired by the __FILE__ macro of C.
**/

static char *
func_this_file (char *o UNUSED, char **argv UNUSED, const char *funcname UNUSED)
{
if (reading_file) {
return xstrdup(reading_file->filenm);
}
else
return xstrdup("?");
}


/**
$(this_line)

Always expands to the current line number. Inspired by the __LINE__ macro of C.
**/

static char *
func_this_line (char *o UNUSED, char **argv UNUSED, const char *funcname UNUSED)
{
if (reading_file) {
char linumbuf[32];
memset (linumbuf, 0, sizeof(linumbuf));
snprintf(linumbuf, sizeof(linumbuf), "%lu", reading_file->lineno);
return xstrdup(linumbuf);
}
else
return xstrdup("0");
}


/**
$(this_counter)

Always expands to a unique, incremented, counter. Inspired by the __COUNTER__ macro of GCC.
**/

static char *
func_this_counter (char *o UNUSED, char **argv UNUSED, const char *funcname UNUSED)
{
static long counter;
char cntbuf[32];
memset (cntbuf, 0, sizeof(cntbuf));
counter++;
snprintf (cntbuf, sizeof(cntbuf), "%ld", counter);
return xstrdup(cntbuf);
}
///// end of functions added by <basile@starynkevitch.net>


/*
\r is replaced on UNIX as well. Is this desirable?
*/
Expand Down Expand Up @@ -2210,6 +2269,10 @@ static struct function_table_entry function_table_init[] =
FT_ENTRY ("eval", 0, 1, 1, func_eval),
FT_ENTRY ("file", 1, 2, 1, func_file),
FT_ENTRY ("debugger", 0, 1, 1, func_debugger),
/// three functions added by <basile@starynkevitch.net>
FT_ENTRY ("this_file", 0, 0, 0, func_this_file),
FT_ENTRY ("this_line", 0, 0, 0, func_this_line),
FT_ENTRY ("this_counter", 0, 0, 0, func_this_counter),
#ifdef EXPERIMENTAL
FT_ENTRY ("eq", 2, 2, 1, func_eq),
FT_ENTRY ("not", 0, 1, 1, func_not),
Expand All @@ -2236,7 +2299,10 @@ expand_builtin_function (char *o, int argc, char **argv,
but so far no internal ones do, so just test it for all functions here
rather than in each one. We can change it later if necessary. */

if (!argc && !entry_p->alloc_fn)
if (!argc
/// the functions named this_* by <basile@starynkevitch.net> take no arguments...
&& strncmp(entry_p->name, "this", sizeof("this")-1)
&& !entry_p->alloc_fn)
return o;

if (!entry_p->fptr.func_ptr)
Expand Down
2 changes: 1 addition & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ read_all_makefiles (const char **makefiles)
{
PATH_VAR (current_directory);
static const char *default_makefiles[] =
{ "GNUmakefile", "makefile", "Makefile", 0 };
{ "GNUremakefile", "GNUmakefile", "makefile", "Makefile", 0 };
const char **p;

while (1) {
Expand Down