Any suggestion on the best way to include all the paths for header files using GCC and Eclipse plugin for GNU GCC ARM?

Hello all..

I've developed all my life using IAR and I was willing to give a try on GNU GCC for ARM.

To start I have few folders and few files in a project which requires configuration to add the path for all header files using the -I key.

Is there a better, more automated way to include all the sub-directories under my src folder in the path list for the compiler to find all the header files?

My first though was to run a pre-compilation process that spits out a file with all the paths inside which I could some how add to the command line to be expanded when invoking the compiler.

Does anybody has found a solution for this problem?

Or knows how to expand a file with the paths when invoking the compiler?

Thanks you, Manoel

  • I assume you are talking about Makefile rules [1]

    If you want to search the sub directories under your src folder, you can try 

    VPATH = src:../headers  // specifies a path containing two directories, src and ../headers, which make searches in that order.

    If several vpath patterns match the prerequisite file’s name, then make processes each matching vpath directive one by one, searching all the directories mentioned in each directive. makehandles multiple vpath directives in the order in which they appear in the makefile; multiple directives with the same pattern are independent of each other.

    vpath %.c foo
    vpath %   blish
    vpath %.c bar

    will look for a file ending in ‘.c’ in foo, then blish, then bar

    If you want to add the path into the source file names, you can use the "addprefix" function of Makefile. [2]

    $(join list1,list2) can concatenate the path and file names.

    [1]: https://www.gnu.org/software/make/manual/html_node/Rules.html

    [2]: https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html#File-Name-Functions