我有以下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专业人士会怎么做呢?
发布于 2010-07-18 16:29:08
all: hello.exe hellogtk.exe hellogtktng.exe
%.exe: %.cs
gmcs -pkg:gtk-sharp-2.0 $<
clean:
rm -f *.exe发布于 2010-07-18 17:10:14
Here's how you can add flags to specific targets.
# 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 listhttps://stackoverflow.com/questions/3274810
复制相似问题