OSDev.org

The Place to Start for Operating System Developers
It is currently Wed May 08, 2024 12:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Makefile Tool
PostPosted: Tue Jan 01, 2013 9:12 pm 
Offline
Member
Member
User avatar

Joined: Sat Apr 30, 2011 12:50 am
Posts: 308
Hello, my fellow OsDevers,

Today, I was peacefully working on my OS, when I decided to organize my code and have specific directories for different modules/system (like a folder for HAL or perhaps for API's, y'know)
And became really frustrated with makefile's and the gimmicks to make this work. Doing this manually wasn't a solution, too.

Well, then, in a matter of hours I wrote a tool (for Windows, but I assure you, it should work with Mono on Unix) that does just that - only with some features.

So, here I introduce you the Hydra Makefile Generator ( Somehow, I feel as though there is already a solution for this, and I just didn't search well enough - oh well), a console app that generates makefiles, which includes all the source files in the "source" directory (also it takes care of the dependencies from .h files). Probably the biggest feature is that it has a continuous mode, where it monitors the file-system and generates the makefile on the fly (also it monitors removed files, so if I delete ACPI.cpp it's object file will be removed as well).

It does make some assumptions that might be considered unacceptable, but they are easily fixed by modifying the source, which is - for your convenience - published under the BSD license.

It has out-of-the-box support for ASM,C,C++ but can easily be modified to include others as well.

Source is attached.

P.S. Wanna hear your guys' feedback, or at least know if this is useful.


Attachments:
Watcher.zip [27.07 KiB]
Downloaded 92 times


Last edited by Nessphoro on Tue Jan 01, 2013 11:09 pm, edited 2 times in total.
Top
 Profile  
 
 Post subject: Re: Makefile Tool
PostPosted: Tue Jan 01, 2013 9:33 pm 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
For source files within the same directory, you can do:
Code:
KERNEL_C :=$(wildcard path/*.c)
KERNEL_OBJ := $(patsubst %.c, %_c.o, $(KERNEL_C))


Note than plain old make (eg, shipped in FreeBSD) do not support :=, in that case use gmake or replace that with = (causing make to re-scan for each reference of variable)

For multiple sub-directory (like those drivers), I wrote a shell script to generate Makefile contain all targets
I can post the script if you are interested, it's just hundred of lines.


Top
 Profile  
 
 Post subject: Re: Makefile Tool
PostPosted: Tue Jan 01, 2013 9:37 pm 
Offline
Member
Member
User avatar

Joined: Sat Apr 30, 2011 12:50 am
Posts: 308
Ah, yes, I knew a shell solution was present - unfortunately I'm not into bash.


Top
 Profile  
 
 Post subject: Re: Makefile Tool
PostPosted: Tue Jan 01, 2013 9:49 pm 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
By the way these are my suggestion (which I do in my project):
1. Support temp path for object files(and .d files), for the reasons: cleaner for ls, cleaner for kdev/eclipse view, and healthier for SSD drive.
2. There are about twenty extra warning can be enabled on top of -Wall -Wextra
3. Generate debug symbols file


Top
 Profile  
 
 Post subject: Re: Makefile Tool
PostPosted: Tue Jan 01, 2013 9:52 pm 
Offline
Member
Member
User avatar

Joined: Sat Apr 30, 2011 12:50 am
Posts: 308
-ggdb was in the earlier version, dropped it - you can add it to the CC_FLAGS easily.

Edit: Added that option, along with the /tmp/ output.


Top
 Profile  
 
 Post subject: Re: Makefile Tool
PostPosted: Wed Jan 02, 2013 6:09 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
Quote:
Somehow, I feel as though there is already a solution for this, and I just didn't search well enough - oh well


www.cmake.org

combine that with Ninja and you have something very cool and fast.

_________________
Learn to read.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group