如何缩短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 我刚

我有以下生成文件:

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 pros将如何执行此操作?

all:hello.exe hellogtk.exe hellogtktng.exe
all: hello.exe hellogtk.exe hellogtktng.exe

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

clean:
 rm -f *.exe
%.exe:%.cs gmcs-pkg:gtk-sharp-2.0$< 清洁: rm-f*.exe

#标志的空变量(并非严格必需,
#未定义的变量(扩展为空字符串)
GMCSFLAGS=
#如果不指定参数,则创建第一个目标
全部:hello.exe hellogtk.exe hellogtktng.exe
#向特定文件添加标志
hellogtk.exe hellogtktng.exe:GCMSFLAGS=-pkg:gtk-sharp-2.0
#将.cs转换为.exe的模式规则
#查找依赖项时,百分比符号被替换
%.exe:%.cs
gmcs$(GMCSFLAGS)$<
#$()展开变量,$<是列表中的第一个依赖项

哇,谢谢你,它很管用!你能给我指一下这方面的文件吗?它看起来很吓人。我是否正确理解我将使用gtk-sharp-2.0编译hello.cs(gtk-sharp-2.0不需要它)?我可以这样做吗?(它不是那样工作的)hello.exe:%.cs gmcs$@theone,更具体地说,sectionWow,这太棒了!它与我的原始Makefile完全相同!
# An empty variable for flags (Not strictly neccessary, 
# undefined variables expand to an empty string)
GMCSFLAGS =

# The first target is made if you don't specify arguments
all: hello.exe hellogtk.exe hellogtktng.exe

# Add flags to specific files
hellogtk.exe hellogtktng.exe: GCMSFLAGS = -pkg:gtk-sharp-2.0

# A pattern rule to transform .cs to .exe
# The percent sign is substituted when looking for dependancies
%.exe:%.cs
    gmcs $(GMCSFLAGS) $<
# $() expands a variable, $< is the first dependancy in the list