0

Lets say my folder structure is something like this ..

+-- Application
|
+-- MICRO_CONTROLLER_1
|
+-- MICRO_CONTROLLER_2
|
+-- MICRO_CONTROLLER_3

and i have a compile switch ( SELECT_MICRO) set to #define SELECT_MICRO == MICRO_CONTROLLER_1 , then my project should build application with driver files in MICRO_CONTROLLER_1 , similarly if #define SELECT_MICRO == MICRO_CONTROLLER_2 , then application should build application with driver files in MICRO_CONTROLLER_2

Please let me know if there template to achieve the above.

user1474918
  • 113
  • 1
  • 6

3 Answers3

1

You can export that particular path of the folder you want to build and supply the path to the executable. You can get further info. in this thread.

How I could add dir to $PATH in Makefile?

Or simply maintain different Makefiles to make different builds and use make -f to run that particular makefile.

I hope this is what you finally want to perform.

Community
  • 1
  • 1
Adit Ya
  • 731
  • 1
  • 8
  • 19
0

Typically you would define your pre-processor definitions to tell the pre-processor to include only, for instance, MICRO_CONTROLLER_1 blocks of code and ignore everything else.

Something like the following should suffice:

#if defined(MICRO_CONTROLLER_1)
// Block of code that is only available to MICRO_CONTROLLER_1
#elif defined(MICRO_CONTROLLER_2)
// ...
// All other microcontrollers you are supporting would follow this structure.
#endif

Then you would need to define MICRO_CONTROLLER_1. If you're using an IDE for development, there is typically a project option for pre-processor directives. This is where you would define MICRO_CONTROLLER_1. You could then create different "configurations" - one for each of the microcontrollers you are targeting.

bblincoe
  • 2,393
  • 2
  • 20
  • 34
0

This can only work if the directories have only include files. #define is a preprocessor directive. If the directories have source files, you need to solve it at the build system layer, not the preprocessor layer.

Assuming it's just include files, you'd just #include SELECT_MICRO # "Interface.h"

MSalters
  • 173,980
  • 10
  • 155
  • 350