473,406 Members | 2,336 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,406 software developers and data experts.

Makefile

I am very sorry to post this one because I know it is out of topic but I
cannot find the proper news group. I understand that most senior C++
programmers know makefile very well. My question is GNU makefile support
command line argument?

I want to write a makefile so that when you invoke "make test", the makefile
will compile test like this:

$project = "command line argument, i.e., test";

$project : ($project).cpp
g++ -ggdb -o $project ($project).cpp

I cannot figure it out how I can get $project=test, the test is from command
line argument. I appreciate any help or direct me to the right new groups.

Thanks in advance!
Jul 22 '05 #1
4 3248
In article <yDlYc.3487$hq5.2435@trndny09>, newbiecpp
<ne*******@yahoo.com> wrote:
I am very sorry to post this one because I know it is out of topic but I
cannot find the proper news group. I understand that most senior C++
programmers know makefile very well. My question is GNU makefile support
command line argument?

I want to write a makefile so that when you invoke "make test", the makefile
will compile test like this:

$project = "command line argument, i.e., test";

$project : ($project).cpp
g++ -ggdb -o $project ($project).cpp

I cannot figure it out how I can get $project=test, the test is from command
line argument. I appreciate any help or direct me to the right new groups.


If your project is so simple, with just one source file to make the
executable. you don't even need a make file for that. You just type
'make test', and it will instruct the compiler to build executable
'test' from 'test.cc'.

For example:

~/Scrap $ ls
newton.caml test.cc
~/Scrap $ cat test.cc
int main()
{
}
~/Scrap $ make test
g++ test.cc -o test
~/Scrap $ ls
newton.caml test test.cc
~/Scrap $ rm test
~/Scrap $ make test CXXFLAGS=-g
g++ -g test.cc -o test
~/Scrap $

HTH

Alwyn
Jul 22 '05 #2
newbiecpp wrote:
I am very sorry to post this one because I know it is out of topic but
I cannot find the proper news group.
What about gnu.utils.help?
I understand that most senior C++ programmers know makefile very well.
My question is GNU makefile support command line argument?

I want to write a makefile so that when you invoke "make test", the
makefile will compile test like this:

$project = "command line argument, i.e., test";

$project : ($project).cpp
g++ -ggdb -o $project ($project).cpp

I cannot figure it out how I can get $project=test, the test is from
command line argument.
If you add a command line argument like "test", make will try to find a
target with that name and build it. So to do the above, you'd need to
create a wildcard target that does the right thing. Your above example
is even be built-in to gnu make. Just try the following Makefile:

CXX = g++
CXXFLAGS = -ggdb

On a "make test", it should just do what you asked for above.
I appreciate any help or direct me to the right new groups.


Done. (xpost & f'up to gnu.utils.help)

Jul 22 '05 #3
newbiecpp wrote:
I am very sorry to post this one because I know it is out of topic but I
cannot find the proper news group. I understand that most senior C++
programmers know makefile very well. My question is GNU makefile support
command line argument?

I want to write a makefile so that when you invoke "make test", the makefile
will compile test like this:

$project = "command line argument, i.e., test";

$project : ($project).cpp
g++ -ggdb -o $project ($project).cpp

I cannot figure it out how I can get $project=test, the test is from command
line argument. I appreciate any help or direct me to the right new groups.

Thanks in advance!


Why not set up a makefile variable for the project name and alter it as
you see fit? It may not be a solution involving command line arguments
but apparently it achieves the same thing.
Jul 22 '05 #4
newbiecpp wrote:
I am very sorry to post this one because I know it is out of topic but I
cannot find the proper news group. I understand that most senior C++
programmers know makefile very well. My question is GNU makefile support
command line argument?

I want to write a makefile so that when you invoke "make test", the makefile
will compile test like this:

$project = "command line argument, i.e., test";

$project : ($project).cpp
g++ -ggdb -o $project ($project).cpp

I cannot figure it out how I can get $project=test, the test is from command
line argument. I appreciate any help or direct me to the right new groups.

Thanks in advance!

This has more to do with understanding makefiles than C++ ( Hence
flagging the msg as o.t. ).

make test essentially means a target (test is the target).

Refer to the make utility manual to get this done.
--
Karthik.
------------ And now a word from our sponsor ----------------------
For a quality mail server, try SurgeMail, easy to install,
fast, efficient and reliable. Run a million users on a standard
PC running NT or Unix without running out of power, use the best!
---- See http://netwinsite.com/sponsor/sponsor_surgemail.htm ----
Jul 22 '05 #5

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

Similar topics

4
by: Bryan Olson | last post by:
Here's the problem: Suppose we use: import socket f = some_socket.makefile() Then: f.read() is efficient, but verbose, and incorrect (or at least does not play will with others);
1
by: Jamie Saker | last post by:
I think I'm overlooking something assumed in socket's makefile method. Googling several hours and digging thru the python reference didn't help - I think I'm overlooking an assumption between...
4
by: Sharp Tool | last post by:
Hi I have downloaded a program that is written in C++ that I would like to compile into a Win XP executable. The program contains a Makefile written for Unix/linux/cygwin. I would like to...
2
by: Juhan Voolaid | last post by:
Hello I need help with my makefile, so that when I compile my project the source code files would be separated from the object (*.o) files. So if I have: main.cpp and classes.cpp - the...
4
by: Jess | last post by:
Hello, I am now trying to use makefile to compile C++ programs. My makefile looks like: f1.o : f1.cpp h1.h h2.h g++ -c f1.cpp f2.o : f2.cpp h2.h h3.h g++ -c f2.cpp
8
by: xz | last post by:
I am a rookie of C++ and got so confused with the Makefile these days. Could anyone be so kind and give a little sample Makefile for the following particular example? Let's say I have the...
1
by: rpjanaka | last post by:
I am using an open source library called IGI_UDP for measure the available bandwidth of a link (http://www.cs.cmu.edu/%7Ehnn/igi/ ). with that library they have provided a "Makefile" which is not an...
5
by: M.Liang Liu | last post by:
I have a project with the following dirs: --------------------------------------------------------------------------------------- +src |-proj0 |-program1 |-program2 |-proj1 |-program1...
2
by: chutsu | last post by:
I'm basically a summer student working on a program called Rivet. (http://projects.hepforge.org/rivet/) And I'm trying to port it to BOINC so that the hosts can download the BOINC client and do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.