user1064372
user1064372

Reputation: 1

Makefile to build several files in different folders

I have been trying to use MSP GCC compiler. I have written a makefile for single file and able to compile and flash in the MSP430 device.

I don't know how to write makefile for many source files in different folder inter dependent with each other.

I am developing a serial deriver folder and file structure is as follows

serial_driver/App
serial_driver/App/inc/app.h
serial_driver/App/inc/app.c
serial_driver/controller
serial_driver/controller/inc/hardware.h
serial_driver/controller/inc/globaldef.h
serial_driver/controller/src/ctrl.c
serial_driver/UART
serial_driver/UART/inc/uart.h
serial_driver/UART/src/uart.c

Can any give some ideas to write make files for this project and how to expand in future bigger projects.

Thanks and Regards Ashok Kumar P

Upvotes: 0

Views: 542

Answers (2)

Sergio Campamá
Sergio Campamá

Reputation: 746

What I use is rake (Ruby make) instead of make (I HATE make, it's so frustrating and debugs like crap)

I have a sample rake system here, where I have small projects inside my workspace. Each project's Rakefile references a Rakefile.include file on the same level as the project folders, where all the magic happens. It's pretty well documented if you want to take a look at it. It's customized for the Launchpad, but can be changed to anything. There's also a complete guide to install the latest version of mspgcc.

The cool thing is that you can do

rake mcu=msp430g2553
rake install

And it will compile all the source files in your project (including subfolders and sub-subfolders and so on) for that specific version of the msp430, and install it on the Launchpad. (Installation on the Launchpad is done with mspdebug)

Upvotes: 0

M S
M S

Reputation: 4093

One option is to add makefile in each directory and from the parent makefile you can call each makefile with -C option.

for eg:

in App directory you can have your makefile and from the makefile in serial_driver

you can have a statememt

make -C ./App

this statement will execute the makefile in App directory

Similarly you can call all the makefiles in the sub directories in this manner.

Upvotes: 1

Related Questions