473,513 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question on Makefile

62 New Member
Hi can any one explain me the reason.

For any Makefile there will be assosiated rules file, may be in same directory or in other directory. What is the need for this rules file.

Is it that commands in the makefile will gets executed depending on the rules.
or
If we have dependencies for the tagets in the Makefile, than the commands used to generate the target will be present in rules file.

we can write the command for dependencies in the make file itself.
than what is the need of rules file.

Please explain me I having lot of confusion with this rules file.


regards

srikar
Oct 12 '06 #1
4 1928
Banfa
9,065 Recognized Expert Moderator Expert
Generally the rules files just contains default rules that may be useful, for instance that an obj file is created from a c file by calling the compiler.

There is no absolute need for the rules file it just generally makes things easier by putting all the common stuff into a single file leaving the make file to just declare the actual dependecies for the specific project.
Oct 12 '06 #2
srikar
62 New Member
Generally the rules files just contains default rules that may be useful, for instance that an obj file is created from a c file by calling the compiler.

There is no absolute need for the rules file it just generally makes things easier by putting all the common stuff into a single file leaving the make file to just declare the actual dependecies for the specific project.
Thanks Banfa, For the immediate response.
But I am still having some queries in my mind.

In my project I am having a Makefile and in this file , site.rules file is being
included, I am having some dependencies and assosiated commands in the site.rules. Is it that if the target corresponding to this dependecy is not mentioned in the Makefile than will that Target will get generated or not.
please clarify me.
the target I am having in rules file is

$(BIN_DIR)/lex.yy.$(OBJ_EXT) : $(BIN_DIR)/lex.yy.c
ifdef ARCH_nt
@cd $(BIN_DIR); \
$(CC) -c $(CPPFLAGS) -I../../src $(CFLAGS) $(notdir $<) $(CC_OUT_OPTION)$(notdir $@)
else
@$(CC) -c $(CPPFLAGS) $(CFLAGS) $< $(CC_OUT_OPTION)$@
endif
I am working on amd64 machine.
once again Thank you Banfa
regards
srikar
Oct 12 '06 #3
Banfa
9,065 Recognized Expert Moderator Expert
I would say that this defines a rule that compiles lex.yy.c.

However if in your make file you do not state that your makefiles main target (whatever that is) is dependent on lex.yy.$(OBJ_EXT) then this rule will never come into play.

Make files are heirarchical, there is the main target (which is the target given on the command line or if non target given on the command line either the first or the last target in the file depending on which make engine you are using) and only files which are dependents or sub-dependents of the main target will have their rules executed.

where a sub-dependent is a dependent of either a dependent or another sub-dependant.
Oct 12 '06 #4
srikar
62 New Member
Thank you Banfa
Oct 13 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4461
by: Efrat Regev | last post by:
Hello, I'd like to ask a question concerning a python script in a makefile. Suppose I have a C++ project (sorry for raising this in a Python newsgroup), with some makefile for it. Before...
1
3311
by: Miguel PS | last post by:
I have created a lib with BBc++ makefile ... I created a program in IDE that uses that lib. By the way, the only mode to compile succesfully my program is exporting a Makefile with Project |...
2
3007
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...
1
358
by: Carson | last post by:
Hi, I have a problem with Makefile. I have a piece of c code, which is stored in my unix account. I wrote a Makefile for that particular compilation (using gcc), and it works fine. But...
4
3942
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
3184
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
5021
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
3292
by: M.Liang Liu | last post by:
I have a project with the following dirs: --------------------------------------------------------------------------------------- +src |-proj0 |-program1 |-program2 |-proj1 |-program1...
9
1575
by: bowlderyu | last post by:
Hello, all. I meet a question about compiling files. Eg., I have three files named myfile.h, myfile.c and the main.c file, and there is a function, ex, void myfun(...). If I put myfun(...) in...
0
7265
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
7388
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,...
1
7111
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
7539
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
5692
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,...
0
3240
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...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.