]> git.cworth.org Git - scherzo/blobdiff - Makefile
Start drawing something
[scherzo] / Makefile
index 3bcf15af51963024b09f54e02cfbbe6b74ad8c0c..3df2349670582e7e7aa607abbe0556beea729aab 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,48 @@
-scherzo: scherzo.c
-       gcc -Wall -Wextra $$(pkg-config --cflags --libs gtk+-2.0) -o scherzo scherzo.c
+all: scherzo
 
+scherzo_srcs =         \
+       scherzo.c       \
+       score.c
+
+scherzo_modules = $(scherzo_srcs:.c=.o)
+
+WARN_CFLAGS = -Wall -Wextra
+
+SCHERZO_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags) `pkg-config --cflags gtk+-2.0`
+
+SCHERZO_LDFLAGS = $(LDFLAGS) `pkg-config --libs gtk+-2.0`
+
+# The user has not set any verbosity, default to quiet mode and inform the
+# user how to enable verbose compiles.
+ifeq ($(V),)
+quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
+quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
+endif
+# The user has explicitly enabled quiet compilation.
+ifeq ($(V),0)
+quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
+endif
+# Otherwise, print the full command line.
+quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
+
+.deps/%.d: %.cpp $(global_deps)
+       @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
+       $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
+       sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
+       rm -f $@.$$$$
+
+DEPS := $(DEPS:%.cpp=.deps/%.d)
+-include $(DEPS)
+
+%.o: %.c $(global_deps)
+       $(call quiet,CC $(CFLAGS)) -c $(SCHERZO_CFLAGS) $< -o $@
+
+scherzo: $(scherzo_modules)
+       $(call quiet,CC $(CFLAGS)) $^ $(SCHERZO_LDFLAGS) -o $@
+
+CLEAN := $(CLEAN) scherzo $(chorale_modules)
+
+.PHONY : clean
 clean:
-       rm -f scherzo
+       rm -f $(CLEAN); rm -rf .deps