🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42455

Re: Gnu make MACROS and shell return values?

#42455
From: Paul D. Smith
Date: Mon, 04 Dec 1995 00:00
57 lines
3041 bytes
%% Regarding Gnu make MACROS and shell return values?;
%% stei0302@cs.fredonia.edu (Jon N. Steiger) writes:

    jns>    I apologize if this is not the right newsgroup to post this
    jns> to... If it isn't, could someone please let me know where I
    jns> should?

If you can't find a gnu.* newsgroup that addresses the package by name,
the catch-all group for all other GNU products is
gnu.utils.bug... that's where GNU make questions/bugs/comments should go
in general to get the right audience.

    jns>   Could someone tell me how I can execute a (unix) program or
    jns> sh script and have the stdout of that program go into a
    jns> variable (macro?) in GNU make?

From the GNU make manual (under Functions):

  File: make.info,  Node: Shell Function,  Up: Functions

  The `shell' Function
  ====================

  [...]

     The `shell' function performs the same function that backquotes
  (``') perform in most shells: it does "command expansion".  This means
  that it takes an argument that is a shell command and returns the
  output of the command.  The only processing `make' does on the result,
  before substituting it into the surrounding text, is to convert
  newlines to spaces.

     The commands run by calls to the `shell' function are run when the
  function calls are expanded.  In most cases, this is when the makefile
  is read in.  The exception is that function calls in the commands of
  the rules are expanded when the commands are run, and this applies to
  `shell' function calls like all others.

     Here are some examples of the use of the `shell' function:

       contents := $(shell cat foo)

  sets `contents' to the contents of the file `foo', with a space (rather
  than a newline) separating each line.

       files := $(shell echo *.c)

  sets `files' to the expansion of `*.c'.  Unless `make' is using a very
  strange shell, this has the same result as `$(wildcard *.c)'.

-------------------------------------------------------------------------------
 Paul D. Smith <psmith@baynetworks.com>         Network Management Development
 Senior Software Engineer                                   Bay Networks, Inc.
-----------------------------------------------==<http://www.baynetworks.com/>-
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
     These are my opinions--Bay Networks takes no responsibility for them.
Technical Details
Message-ID: <9512041557.AA14892@lemming.engeast>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <DIyCrA.GKn@cs.fredonia.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,59958804fa82f56a
X-Google-Attributes: gid11318c,public
From: psmith@baynetworks.COM (Paul D. Smith)
Subject: Re: Gnu make MACROS and shell return values?
Date: 1995/12/04
Message-ID: <9512041557.AA14892@lemming.engeast>
X-Deja-AN: 120864067
distribution: gnu
sender: daemon@cis.ohio-state.edu
references: <DIyCrA.GKn@cs.fredonia.edu>
organization: GNUs Not Usenet
reply-to: psmith@baynetworks.com
newsgroups: gnu.gcc.help