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!
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!