473,383 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Makefiles with multiple targets

I'm compiling a project that I want to have multiple targets
(basically debug and optimized). I would like to just be able to type
'make debug' or 'make optimized' and have the makefile compile the
fields into separate directories.

i.e. if I do make debug, all .o files and the executable should go
into the debug directory (compiled with -g on).
Similarly for the optimized version.

I'm a novice at makefiles, I basically hack at them until they do what
I want them to. Could someone post a sample makefile that could do
this?
This is a simple project with all files in one directory - about 25 c
source files.

Thanks.
Nov 13 '05 #1
2 9360

"A. Gupta" <ak*****@eudoramail.com> wrote in message
news:8e**************************@posting.google.c om...
I'm compiling a project that I want to have multiple targets
(basically debug and optimized). I would like to just be able to type
'make debug' or 'make optimized' and have the makefile compile the
fields into separate directories.

i.e. if I do make debug, all .o files and the executable should go
into the debug directory (compiled with -g on).
Similarly for the optimized version.

I'm a novice at makefiles, I basically hack at them until they do what
I want them to. Could someone post a sample makefile that could do
this?
This is a simple project with all files in one directory - about 25 c
source files.


'make' utilites aren't topical here, but:

<OT>
Just create separate makefiles named e.g. 'release' and 'debug'
which specify the desired operations, 'sources', and 'targets',
for each and give the appropriate file name as 'make's argument.
(Assuming of course that your 'make' can use such a filename
argument (all that I've used can).

Also, many 'make' utilites let you use a '#define'-like
feature that lets it do conditional execution, which would
enable you to put everything in one 'make' file. All 'make's
are not equal, so consult the documentation for yours.
</OT>
-Mike
Nov 13 '05 #2

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Tp******************@newsread1.news.pas.earth link.net...

"A. Gupta" <ak*****@eudoramail.com> wrote in message
news:8e**************************@posting.google.c om...
I'm compiling a project that I want to have multiple targets
(basically debug and optimized). I would like to just be able to type
'make debug' or 'make optimized' and have the makefile compile the
fields into separate directories.

i.e. if I do make debug, all .o files and the executable should go
into the debug directory (compiled with -g on).
Similarly for the optimized version.

I'm a novice at makefiles, I basically hack at them until they do what
I want them to. Could someone post a sample makefile that could do
this?
This is a simple project with all files in one directory - about 25 c
source files.


'make' utilites aren't topical here, but:

<OT>
Just create separate makefiles named e.g. 'release' and 'debug'
which specify the desired operations, 'sources', and 'targets',
for each and give the appropriate file name as 'make's argument.
(Assuming of course that your 'make' can use such a filename
argument (all that I've used can).

Also, many 'make' utilites let you use a '#define'-like
feature that lets it do conditional execution, which would
enable you to put everything in one 'make' file. All 'make's
are not equal, so consult the documentation for yours.
</OT>
-Mike


I usually just have the makefile call itself recusively with the desired
directory path, such as:

debug:
$(MAKE) DIR_PATH=blah\blah\blah EXTRA_FLAGS="-g -O0"

optimized:
$(MAKE) DIR_PATH=blah\blah\blah EXTRA_FLAGS="-O2"

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Max | last post by:
I know this isn't directly related to C++, but thought I'd ask anyway. I've already read about 10 tutorials on makefiles, still have this problem and hoping someone here could help me out. I'm...
5
by: djake | last post by:
Someone can explain me what are makefiles useful for? Couldn't i write shell script instead of makefiles? (*.sh in unix; *.cmd in win32) Moreover i really doesn't understand what dependencies are...
8
by: DB2 Novice | last post by:
I am trying to use DB2 Control Centre (version 8.2) to load one flat file into multiple tables. However, I don't see the options in Control Centre that allows that. Anyone knows how to do this?...
10
by: JS | last post by:
I have two Makefiles in two different directories. How do I know which of these Makefiles make will use and is there some way to specify which Makefile that should be run.
3
by: mmashaie | last post by:
Hi, I'm trying to compile a makefile. On my command line, I type make and I get the below message; I don't understand why I get that. I am using Borland C++ version 2: C:\Maryam\clarke> make...
19
by: milkyway | last post by:
Hello, I am running under Suse Linux and am putting together some code written in C. I am not clear on how to create makefiles and was wondering if there were any "makefile tools" out there. If...
2
by: Ayoa | last post by:
I am working on some web based custom reports and i want to open multiple browser at the click of a button. So for example if i have 2 guids in my arraylist, i want to open 2 windows. protected...
22
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I already understand how program compilation works (i.e. the preprocessor produces individual translation units which get compiled separately, and then the linker links the object files together),...
3
by: tvnaidu | last post by:
porting windows static libs and dll into linux static lib abd shared lib, any tool to convert vcproj files to Linux makefiles? porting windows static libs and dll into linux static lib abd shared...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.