I have many build scripts to compile, can I use single variable to pass CFLAGS info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tvnaidu
    Contributor
    • Oct 2009
    • 365

    #1

    I have many build scripts to compile, can I use single variable to pass CFLAGS info

    Currently I have 15 module folders, each module had C code, also Makefile in each folder, also build script to create shared lib for each module. Each of this Makefile had CFLAGS defined inside, basically -g option enabled in all Makefile, there is a separate line ion each Makefile for CFLAGS, but at the root, I have single build_all script which calls each build script to compile each module and create each shared lib. can I pass this CFLAGS info from top, to bottom to all the scripts, this way I can have define CFLAGS at one placem this way I can control -g option, any idea how can I do that?.

    each Makefile had line like this, I want to define this CFLAGS at once instead in each Makefile and propage this from top when I call "build_all" to create all.

    CFLAGS= -Wall -g -O2
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Just put the flags definition on the command line instead of in the make file

    make "CFLAGS= -Wall -g -O2"

    Comment

    • tvnaidu
      Contributor
      • Oct 2009
      • 365

      #3
      Thanks.
      I have to pass CFLAGS like this for 15 Makefiles, instead can I export at at one place like below, this way I can have CFLAGS defined at one place, later when I compile for production, I can takeout -g option at one place instead 15 places for 15 Makefiles. I can do like this inside build script?.

      export CFLAGS="-Wall -g -O2"
      cd util
      make $CFLAGS
      cd trace
      make $CFLAGS

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Yes .

        Comment

        Working...