简体   繁体   English

MakeFile 用于 C++ 项目

[英]MakeFile for C++ project

I wrote my own makefile -Which will be used to compile my C++ project-我写了我自己的 makefile - 这将用于编译我的 C++ 项目 -

But I had some issues with it:但我有一些问题:

  1. I need to delete all temporary files;我需要删除所有临时文件; objects, executables and those for UNIX对象、可执行文件和 UNIX

    I did the first two like this;我做了前两个这样; but how may I implement the latter?但我该如何实施后者?

    clean:干净的:

     rm -f $(OBJS) $(EXEC)
  2. I need to zip all files in a test.zip folder using tar command in the folder where makefile is -including it-), how may I do that?我需要 zip 测试中的所有文件test.zip文件夹在 makefile 所在的文件夹中使用 tar 命令 - 包括它 -),我该怎么做?

    tar:柏油:

You want to delete all "temporary files", but a temporary file is a file that people don't intend to keep very long.您想删除所有“临时文件”,但临时文件是人们不打算保留很长时间的文件。 There is no way for a tool like Make to know people's intentions without being told.像 Make 这样的工具无法在不被告知的情况下了解人们的意图。

To create a zipped archive of Makefile and test.zip/ from the command line, you can use a command like:要从命令行创建Makefiletest.zip/的压缩存档,您可以使用如下命令:

tar -czvf archive.tgz Makefile test.zip

You can put that in a rule in the makefile like this:您可以将其放在 makefile 中的规则中,如下所示:

archive.tgz:
    tar -czvf archive.tgz Makefile test.zip

Further refinements are possible, once you have this much working correctly.一旦你有这么多的工作正常,进一步的改进是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM