Wednesday, August 13, 2008

fun with gnu make utility

This idea is inspired from gnu's humor collections. there is a quote looks like this on that site:
%make love
Make: Don't no how to make `love'. Stop.

It's only a joke and doesn't implemented on every linux distro as far as I now. You wouldn't get a message like that when you type a command 'make love' on a console. But in forum, my friend post a message which almost as same as that joke when he type the command 'make love' in freebsd version 7.0. A message looks like this:
$ make love
Not war.

Because I don't have freebsd 7.0 installed on my lovely pc to see the fact, I start a challenge which mean It should be adopted too in slackware 12.1 that already installed. I check into source file of GNU Make utility on slackware installation dvd, which version is 3.81 as same as the last sources package in its official site. And also, it's the same version that included in freebsd 7.0 when I check on freebsd site repositories.

I'm curious which part of this utility has been modified by freebsd developer. Instead of trying to find out in freebsd version of gnu make, I try to find it from scratch which means from its original source. After consume so much time, I found it in 'remake.c' file. Exactly in complain function from that file. Here's a full modified source from that function:
/* Show a message stating the target failed to build. */
static void complain (const struct file *file)
{
const char *msg_noparent
= _("%sNo rule to make target `%s'%s");
const char *msg_parent
= _("%sNo rule to make target `%s', needed by `%s'%s");

if (!keep_going_flag)
{
if (file->parent == 0)
{
if (strcmp(file->name,"love")==0)
{
fprintf (stdout,"Have fun! :^)\n");
exit(1);
}
else
fatal (NILF, msg_noparent, "", file->name, "");
}
fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
}

if (file->parent == 0)
error (NILF, msg_noparent, "*** ", file->name, ".");
else
error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
}


What I modify is just to generate an output like this:

mine@unique:~$ make love
Have fun! :^)


I think this is not the only one trick to generate a message like that, but it work as I want. Now, FreeBSD 7.0 not the only one which can do it. Slackware 12.1 too! ;-)

-Simplicity is yours-

No comments:

Post a Comment