Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to selectively build software for different machines?

Status
Not open for further replies.

naseeam

Member
We have slave target board that is based on Freescale HCS12 Microcontroller. This target board is installed in our machines. Up to now, we have identical source files and common executable for all Three machines, Machine1, Machine2, and Machine3.

Attached makefile.mk is used to build common executable for all Three machines.

A software feature exclusive to Machine1 is being developed. Machine2 and Machine3 will not use this feature. This feature must not exist in Machine2 and Machine3.
Now, there needs to be one exectuable for Machine1 and different executable for Machine2 and Machine3. To achieve this, I'm thinking about modifying the build as follows:

Create makefile_machine1.mk. It'll define a compile time feature flag. Any source files specific to exclusive feature will be added in makefile_machine1.mk. All source code for this exclusive feature will have feature flag around it. Exectuable target also needs to be specified in this makefile. This makefile will include makefile.mk.

Create makefile_machine2_machine3.mk. It will be empty makefile, only including makefile.mk.

There will be One set of source files for all Three Machines. If we want to build for machine1, we'll run makefile_machine1.mk. The built executable will only be used by machine1.

To build for machine2 and machine3, makefile_machine2_machine3.mk will get invoked. This build executable will only be used by machine2 and machine3.

To build for all Three machines, both newly created makefiles will be invoked to create two separate executables.

Will this work? Is there a better solution? If yes, please provide it.

Thank you!
 

Attachments

  • makefile.txt
    9.4 KB · Views: 171
^ I was thinking about using defines with if-then compiler directives (that's how I do it), but doing it that way he has to open a file and change a number. If he can do it with makefiles then he won't have to open something and edit it each time.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top