make: making the binary name dependent on the source file name.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > make: making the binary name dependent on the source file name.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    make: making the binary name dependent on the source file name.  
Ido Yehieli


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-03-08 12:32 PM

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.





[ Post a follow-up to this message ]



    Re: make: making the binary name dependent on the source file name.  
Ralf Fassel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-03-08 06:23 PM

* 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'





[ Post a follow-up to this message ]



    Re: make: making the binary name dependent on the source file name.  
Ido Yehieli


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-03-08 06:23 PM

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





[ Post a follow-up to this message ]



    Re: make: making the binary name dependent on the source file name.  
Ralf Fassel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

* 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'





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:35 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register