multiple makefiles in one directory

后端 未结 4 1649
一个人的身影
一个人的身影 2020-12-13 03:28

I have a makefile in a directory of mine which builds scripts with certain environment variables set. What if I want to create another makefile in the same directory with di

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 04:25

    You can do something like this rather than using multiple makefiles for the same purpose. You can pass the environment or set a flag to the same makefile. For eg:

    
    
        ifeq ($(ENV),ENV1)
         ENV_VAR = THIS
        else
         ENV_VAR = THAT
        endif
    
        default : test
    
        .PHONY : test
        test:
                @echo $(ENV_VAR)
    
    
    

    Then you can simply run the make command with arguments

    
    
        make ENV=ENV1
    
    
    

提交回复
热议问题