473,385 Members | 1,379 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,385 software developers and data experts.

[Makefile]How can I deal with multi-dirs?

I have a project with the following dirs:
---------------------------------------------------------------------------------------
+src
|-proj0
|-program1
|-program2
|-proj1
|-program1
|-program2
|-program3
|-program4
|-proj3
|-program1
|-program2
|-program3
....
|-proj9
-Makefile
+include
-README
+lib
|-lib1
|-lib2
---------------------------------------------------------------------------------------
There are 10 project-dirs here in src, named proj0-proj9. Each project
has several program_dirs which containing some .c files
All .h files are under include in the top dir, the same as src.

I would like to write a makefile, which can help me compile all the .c
files and generate an executable file for each *program*. Considering
there are several independent programs in each project, the work
should be done within a single makefile at the top dir.

How can I deal all the programs under each project in a single top-
level makefile?

Thanks!
Apr 1 '08 #1
5 3285
fnegroni wrote:
In this case, if each project is standalone, each needs a Makefile and
then you might want a script to run all the makefiles in sequence.
I do believe that the best way is to simply rely on an automatic makefile
generator. For example, automake does a wonderful job at this multi-dir
project stuff.

But yes, it's OT.
Rui Maciel
Apr 1 '08 #2
fnegroni wrote:
In this case, if each project is standalone, each needs a Makefile and
then you might want a script to run all the makefiles in sequence.
I do believe that the best way is to simply rely on an automatic makefile
generator. For example, automake does a wonderful job at this multi-dir
project stuff.

But yes, it's OT.
Rui Maciel
Apr 1 '08 #3
On Apr 1, 4:09*pm, Antoninus Twink <nos...@nospam.invalidwrote:
On *1 Apr 2008 at 12:20, fnegroni wrote:
I believe recursive makefiles have serious flaws and should be
avoided.

I believe you've read some stupid polemic about recursive Makefiles
having serious flaws, and have bought into it hook line and sinker.
Maybe.
In this case, if each project is standalone, each needs a Makefile and
then you might want a script to run all the makefiles in sequence.

A "script", eh? But definitely not a top-level Makefile?
A Makefile to do what a script can do perfectly well? Why?
How does a top level makefile improve the situation. Surely it is the
individual makefile that knows whether a target needs recompiling or
not. Why would a top level Makefile do a better job than a script?
>
Also, a better source code file structuring also helps: I would place
all source files together in the same directory. After all, if they
are interrelated, what would be the advantage in splitting them about?
But that's my opinion. Yours may differ.

It sounds like the OP's project consists of one or more libraries, and
then some number of independent executables that link against these
libraries. Separating the source files for each executable into its own
directory seems perfectly reasonable to me.
Sure, but then why having recursive makefiles? If each project is
standalone, whether a library or executable, each Makefile is self
contained. Certainly not split.
If the different sources for the *same* executable were split across
directories, then a recursive makefile would save the use of relative
paths, but that's where IMHO it would be better to consolidate all
source directories for the same tool into one.
If one module is shared across two executable, shouldn't that be a
static library? I thought that's what they were meant for.
Apr 1 '08 #4
fnegroni wrote:
Antoninus Twink <nos...@nospam.invalidwrote:
.... snip ...
>
>I believe you've read some stupid polemic about recursive Makefiles
having serious flaws, and have bought into it hook line and sinker.

Maybe.
Twink is a pure troll. Ignoring and plonking is recommended.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Apr 1 '08 #5

"M.Liang Liu" wrote:
I have a project with the following dirs:
----------------------------------------------------
+src
|-proj0
|-program1
|-program2
|-proj1
|-program1
|-program2
|-program3
|-program4
|-proj3
|-program1
|-program2
|-program3
....
|-proj9
-Makefile
+include
-README
+lib
|-lib1
|-lib2
---------------------------------------------------
There are 10 project-dirs here in src, named proj0-proj9. Each project
has several program_dirs which containing some .c files
All .h files are under include in the top dir, the same as src.

I would like to write a makefile, which can help me compile all the .c
files and generate an executable file for each *program*. Considering
there are several independent programs in each project, the work
should be done within a single makefile at the top dir.

How can I deal all the programs under each project in a single top-
level makefile?
<OT>
Don't do that. That's called "micromanaging", and is just as
idiotic when done by make as when done to you by your boss.

Instead, if you have 37 "programs" in 5 "projects" in 1 "workspace",
write 43 makefiles, one for each node in your tree, and one at top
level. The top-level makefile calls the "project" level makefiles,
and they in-turn call the "program" level makefiles.

Advantages:
1. Each makefile is very small and simple and easy to write and
maintain.
2. Changes made at any one node necessitate updating (at most)
the 1 makefile for that node.

This is true regardless of programming language. For more help,
ask about this in "comp.programming", "comp.unix.programmer",
and "gnu.utils.help".

Save the "comp.lang.*" groups for questions about their particular
LANGUAGES. (That's what the "lang" in "comp.lang.*" stands for.)
</OT>

--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
www dott well dott com slant user slant lonewolf slant
Apr 6 '08 #6

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

Similar topics

1
by: Alex Hunsley | last post by:
I am trying to install the DBD::mysql perl module. However, it claims I need mysql.h: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /home/alex/.cpan/Metadata Database was...
10
by: jiing | last post by:
I am reading a binary file *.dat, (8-bit unsigned char) Now I want to transfer the value in it as decimal, how can I do ? Thanks in advance. ifstream fin("usb1_8192_out.dat", ios::binary |...
9
by: silversurfer | last post by:
Hello world, I was just wondering why the clear-line in my Makefile does not work: main:main.o $(ADDOBJS) clear @g++ -o main $(LDFLAGS) $+ As far as I understood it, it should be possible to...
1
by: akira32.comp.lang.c++ | last post by:
How do I run this project(http://www.acm.org/tog/resources/SPD/spd3_14.zip)? By which software? I use VC++.Net 2005 now,Could I transform it to .Net's Project? The SPD distribution contains the...
0
by: Osiris | last post by:
My experiences with BOOST on Windows XP and Visual C++ 2005 I'm new to Python. I built software in more than ten other computer languages. I'm not sure if that is not a handicap, when reading...
9
by: raju2000myin | last post by:
i wrote one makefile but it shows multiple definition error how can i resolve that problem it is urgent to me please help to me............. ramesh............
7
by: HT-Lab | last post by:
Hi All, Not strictly a C++ question but I am sure this is a common compile issue :-) I have a generic makefile (see below) that I would like update such that if I make some changes to a header...
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...
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...
3
by: singhPrabhat | last post by:
I want to compile source files which is in different directory than Makefile. How can I do this? GCC=gcc DEFs=-DCUSTOMERCENTRAL_V11 -DUNIX -DLINUX -DOPENSSL -D_REENTRANT CCWebConfiguration.o:...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.