X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=Makefile;h=841b1a1351346c0d1df1b9e0abf3fe1dd8fc4ad0;hb=5b1797d26aff3a1b2f0cbe83583496b42abcd056;hp=3bcf15af51963024b09f54e02cfbbe6b74ad8c0c;hpb=4fc25bc641a5360245de29aac56e9450415f38e4;p=scherzo diff --git a/Makefile b/Makefile index 3bcf15a..841b1a1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,52 @@ -scherzo: scherzo.c - gcc -Wall -Wextra $$(pkg-config --cflags --libs gtk+-2.0) -o scherzo scherzo.c +all: scherzo +scherzo_srcs := \ + mnemon/mnemon.c \ + pitch.c \ + scherzo.c \ + scherzo-key.c \ + score.c + +scherzo_modules = $(scherzo_srcs:.c=.o) + +CFLAGS ?= -g +WARN_CFLAGS = -Wall -Wextra -Wmissing-declarations + +SCHERZO_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags) -I./mnemon `pkg-config --cflags gtk+-2.0 alsa` + +SCHERZO_LDFLAGS = $(LDFLAGS) `pkg-config --libs gtk+-2.0 alsa` -ltalloc -lm + +# 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: %.c Makefile + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CC) -M $(CPPFLAGS) $(SCHERZO_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \ + sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +DEPS := $(scherzo_srcs:%.c=.deps/%.d) +-include $(DEPS) + +%.o: %.c Makefile + $(call quiet,CC $(CFLAGS)) -c $(SCHERZO_CFLAGS) $< -o $@ + +scherzo: $(scherzo_modules) + $(call quiet,CC $(CFLAGS)) $^ $(SCHERZO_LDFLAGS) -o $@ + +CLEAN := $(CLEAN) scherzo $(scherzo_modules) + +.PHONY : clean clean: - rm -f scherzo + rm -f $(CLEAN); rm -rf .deps