🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
4 messages
4 total messages Started by Ido Yehieli Thu, 03 Jan 2008 10:08
make: making the binary name dependent on the source file name.
#3709
Author: Ido Yehieli
Date: Thu, 03 Jan 2008 10:08
17 lines
1787 bytes
Hi,
    I have several source files in a directory (which are different
versions of the same program), and I want gnu make to compile each of
them and name the resulting binaries according to the source name.

for example, if i write:

====Begin Makefile====
somefile: somefile.*.o
	cc $? -o $@
====end of Makefile====

it will compile all my files but will of course only produce one
binary(somefile). I want it to produce a binary named somefile.* for
every somefile.*.c source file i have.

-Ido.
Re: make: making the binary name dependent on the source file name.
#3710
Author: Ralf Fassel
Date: Thu, 03 Jan 2008 14:32
11 lines
1233 bytes
* Ido Yehieli <Ido.Yehieli@gmail.com>
|     I have several source files in a directory (which are different
| versions of the same program), and I want gnu make to compile each of
| them and name the resulting binaries according to the source name.

  % cat Makefile
  all: somefile.*
  % gmake all
  
HTH
R'
Re: make: making the binary name dependent on the source file name.
#3711
Author: Ido Yehieli
Date: Thu, 03 Jan 2008 14:36
16 lines
1829 bytes
On Jan 3, 3:32 pm, Ralf Fassel <ralf...@gmx.de> wrote:
> * Ido Yehieli <Ido.Yehi...@gmail.com>
> |     I have several source files in a directory (which are different
> | versions of the same program), and I want gnu make to compile each of
> | them and name the resulting binaries according to the source name.
>
>   % cat Makefile
>   all: somefile.*
>   % gmake all
>
> HTH
> R'

make: Nothing to be done for `all'.

-ido
Re: make: making the binary name dependent on the source file name.
#3712
Author: Ralf Fassel
Date: Thu, 03 Jan 2008 20:24
16 lines
1426 bytes
* Ido Yehieli <Ido.Yehieli@gmail.com>
| make: Nothing to be done for `all'.

Yup.  You need to have the executables already present for that recipe
to work :-/

Replace the recipe with

  all: $(basename $(wildcard somefile.*.c))

This collects all somefile.*.c files, strips off the suffix and tries
to build the resulting targets (for .c, the corresponding rule is
built-in).

HTH
R'
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads