[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU enhancement -- $(xargs cmd, list)

From: Reid Madsen
Subject: Re: GNU enhancement -- $(xargs cmd, list)
Date: Mon, 6 Nov 2000 14:29:19 -0600 (CST)

Well, I've got a prototype up and running and IMHO it's quite cool.

All changes are in function.c.  The net of the changes are:

* Added support for:

        $(xargs command, list)

  which is expanded to:

        cat <tmpfile> | xargs command; rm -f <tmpfile>

* Added 'func_xargs' as shown below:

    static int xargs_file_count = 0;

    static char *
    func_xargs(o, argv, funcname)
            char *o;
            char **argv;
            const char* funcname;
        char buff[256];
        char filename[256];
        FILE* fd;

        sprintf (filename, "/tmp/gnumake.%d.%d.xargs", getpid(), 
        fd = fopen(filename, "w");
        fprintf(fd, "%s\n", argv[1]);

        sprintf (buff, "cat %s | xargs ", filename);
        o = variable_buffer_output(o, buff, strlen(buff));
        o = variable_buffer_output(o, argv[0], strlen(argv[0]));
        sprintf (buff, "; rm -f %s", filename);
        o = variable_buffer_output(o, buff, strlen(buff));
        return o;

This works perfectly!  Well at least it works perfectly within my limited
understanding of GNUmake.

Additional considerations:

* On machines with dynamic command lines (i.e., Solaris), the $(xargs)
  function should just expand to:

        command list

  No need for xargs in those cases.
* Allowing user definition of the XARGS command and options.  Something like:

        XARGS = myxargs
        XARGS_OPTIONS = -blah -blah...

  with the defaults being:

        XARGS = xargs
        XARGS_OPTIONS = 

Let me know if you want to integrate this.  Personally, I see this as a very
useful extension to GNUmake.


Reid Madsen

Reid Madsen                             address@hidden                      
Senior Member, Tech. Staff              (972) 536-3261 (Desk)
I2 Technologies                         (214) 850-9613 (Cellular)
Making incrementally (without 'clean') since May 18, 2000.
Long live incremental make!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]