How to write makefile for including header file from multiple directories?

Viewed 18

I have the below project directory structure,

|-root
     |-mylib
            |-_inc
                 |-legacy
                   |-header1.h
                   |-header2.h
                 |-version4
                   |-header1.h
                   |-header2.h
                 |-lib.h         //lib.h has to access headers from /legacy and /version4
                                 //Ex: #include "legacy/header1.h" and #include 
                                 //"version4/header1.h"  
                 |-header2.h
                 |-header3.h
            |-_src
                 |-mylib.c     
            Makefile_lib.mk
    |-myApp
            |-_inc
                 |-app_header.h
            |-_src
                 |-app_src.c
            Makefile_app.mk
    Makefile

Usecase: -> mylib is a static library and has to be used as a dependency to myApp. myApp shall be using API's from mylib after linking it and including a header lib.h. -> I am getting error while compiling myApp saying <legacy/header1.h> : No such file directory. -> I am new to Makefile, can someone guide me how would Makefile , Makefile_app.mk and Makefile_lib.mk look like ?

#Makefile_lib.mk
_src_dirs_ := $(_cur_module_path_)/_src

_lib_name_ := mylib

_lib_objs_ :=  $($(_build_)_OBJ_OUTDIR)/mylib$(_obj_ext_)       \

#Makefile_app.mk

INCLUDE=-I/../mylib/_inc/ 

_src_dirs_ := $(_cur_module_path_)

_bin_name_ := myapp$(_bin_ext_)

_bin_objs_ := $($(_build_)_OBJ_OUTDIR)/myapp$(_obj_ext_)

_bin_libs_ :=                                                             \
     $($(_build_)_LIB_OUTDIR)/$(_lib_prefix_)mylib$(_lib_ext_)               \






  
0 Answers
Related