2018-06-25 09:05
浏览 29


I have a golang CLI program which generates a makefile to a specific project. While this works, there is an issue when the project already has a makefile. Of course I can check that in advance to avoid collusion, but how is it suggested to do it?

I'm not an expert in makefiles, but how can I create second makefile (maybe with the project name or something) that user can run via make (I guess with additional steps or info to the terminal)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dpnfxk251524
    dpnfxk251524 2018-06-25 09:24

    You can generate it as Makefile.project and document to be run as make -f Makefile.project

    点赞 评论
  • doulong2782
    doulong2782 2018-06-25 09:37

    You can give your Makefile whatever filename. Then make must be executed with parameter -f <your_filename> or --file=<your_filename>. See make manual on filenames.

    点赞 评论
  • duanbai5348
    duanbai5348 2018-06-25 11:56

    Which version of make are you using? Some versions run special makefiles before others. For example, GNU make looks for the following files and runs the first one it finds: GNUmakefile, Makefile, makefile.

    If you are using GNU make, then name your generated file GNUmakefile and add in the making any makefile already in the directory. That way, anyone running make in the directory will automatically run the generated makefike first.

    点赞 评论