473,671 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3275
In article <yDlYc.3487$hq5 .2435@trndny09> , newbiecpp
<ne*******@yaho o.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
11753
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
4647
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 Python and UNIX socket objects neither is explicitely discussing. I think my mknod In the makefile operation on socket (pydoc socket.socket.makefile... using AF_UNIX, allowing you to create a file object to correspond to a socket) I've got an sample...
4
2898
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 modify it, if neccessary, so that I can compile it using MS Visual C++ 6.0. Here is the code for the Makefile: //START
2
3016
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 filestructure should be like that: project_dir/ source_dir/ main.cpp
4
3952
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
3193
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 following files describing 4 classes (A, B, C1, C2) and a test program (test.cpp) which runs a test for classes C1 and C2. A.h A.cpp
1
5037
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 auto generated one. the following is the given Makefile, ***************************************************************** CC = gcc INCS = -I. CFLAGS = -g -Wall $(DEFS) $(INCS)
5
3298
by: M.Liang Liu | last post by:
I have a project with the following dirs: --------------------------------------------------------------------------------------- +src |-proj0 |-program1 |-program2 |-proj1 |-program1 |-program2 |-program3
2
2137
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 some calculation over a large clusters of computers. Me being an absolute beginner at programming, I don't know how to update the Makefile in Rivet! I edited the Makefile.am in the src directory to include the BOINC APIs and Libraries, but what do...
0
8472
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4221
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.