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)
You can generate it as Makefile.project
and document to be run as make -f Makefile.project
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.
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.