-2

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)

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

3 Answers3

3

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

rajeshnair
  • 1,587
  • 16
  • 32
3

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.

buff
  • 2,063
  • 10
  • 16
0

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.

shawnhcorey
  • 3,545
  • 1
  • 15
  • 17