makefile - 如何使 Makefile 更短?

标签 makefile

我有以下 Makefile:

all: hello.exe hellogtk.exe hellogtktng.cs

hello.exe: hello.cs
 gmcs hello.cs

hellogtk.exe: hellogtk.cs
 gmcs -pkg:gtk-sharp-2.0 hellogtk.cs

hellogtktng.exe: hellogtktng.cs
 gmcs -pkg:gtk-sharp-2.0 hellogtktng.cs

clean:
 rm -f *.exe

我才刚刚开始学习如何编写Makefile,我觉得这一切都有些重复。 Makefile 专业人士将如何做这件事?

最佳答案

all: hello.exe hellogtk.exe hellogtktng.exe

%.exe: %.cs
 gmcs -pkg:gtk-sharp-2.0 $<

clean:
 rm -f *.exe

关于makefile - 如何使 Makefile 更短?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3274810/

相关文章:

makefile - 测试 NMake 中的文件是否存在

linux - "Exec format error"运行由 g++ 创建的二进制文件

c++ - .o 生成具有不同规则的 Makefile

c++ - 从 Fortran 调用 C++(链接问题?)

c - 使用 Makefile 链接多个文件

C: undefined reference `dlopen`/`dlsym` 尽管添加了 `-ldl` 标志

linux - 为什么可以在这里工作?

visual-studio-2010 - mingw 可以构建一个 Visual Studio-2010 项目吗?

c++ - 如何将 libproxy-dev 链接到现有的 cmake 项目(C++)?

c++ - 如何将独立的 c 应用程序组合成 c++ 应用程序?