Makefile
changeset 1435 16111425d676
parent 1434 e3f4a55b8bcc
child 1476 c1e4ba7193db
--- a/Makefile	Sun Mar 06 12:54:19 2005 +0000
+++ b/Makefile	Sun Mar 06 12:56:02 2005 +0000
@@ -687,14 +687,39 @@
 #
 
 # If we are verbose, we will show commands prefixed by $(Q) (which acts as
-# @ in the non-verbose mode)
+# @ in the non-verbose mode), and we will show the "real" cmds instead of
+# their quiet versions (which are used in the non-verbose mode).
 # Inspired by the Linux kernel build system.
 ifdef VERBOSE
 	Q =
+	quiet =
 else
 	Q = @
+	quiet = quiet_
 endif
 
+# Show the command (quiet or non-quiet version based on the assignment
+# just above) and then execute it.
+cmd = @$(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
+
+
+# The build commands themselves. Note that if you omit the quiet version,
+# nothing will be shown in the non-verbose mode.
+
+quiet_cmd_compile_link = '===> Compiling and Linking $@'
+      cmd_compile_link = $(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
+
+quiet_cmd_ttd_link = '===> Linking $@'
+      cmd_ttd_link = $(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@
+
+COMPILE_PARAMS=$(CFLAGS) $(CDEFS) -MD -c $< -o $@
+
+quiet_cmd_c_compile = '===> Compiling $<'
+      cmd_c_compile = $(CC) $(COMPILE_PARAMS)
+
+quiet_cmd_cxx_compile = '===> Compiling $<'
+      cmd_cxx_compile = $(CXX) $(COMPILE_PARAMS)
+
 
 ##############################################################################
 #
@@ -717,13 +742,11 @@
 	$(Q)./$(ENDIAN_CHECK) > $@
 
 $(ENDIAN_CHECK): endian_check.c
-	@echo '===> Compiling and Linking $@'
-	$(Q)$(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
+	$(call cmd,compile_link)
 
 
 $(TTD): table/strings.h $(OBJS) $(MAKE_CONFIG)
-	@echo '===> Linking $@'
-	$(Q)$(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@
+	$(call cmd,ttd_link)
 
 $(OSX): $(TTD)
 	$(Q)rm -fr "$(OSXAPP)"
@@ -749,8 +772,7 @@
 	$(warning If you see any bugs, include in your bug report that you use a 64 bit CPU)
 
 $(STRGEN): strgen/strgen.c endian.h
-	@echo '===> Compiling and Linking $@'
-	$(Q)$(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
+	$(call cmd,compile_link)
 
 table/strings.h: lang/english.txt $(STRGEN)
 	@echo '===> Generating $@'
@@ -935,13 +957,11 @@
 # therefore we do not need to watch deps.
 
 %.o: %.c $(MAKE_CONFIG) endian.h table/strings.h
-	@echo '===> Compiling $<'
-	$(Q)$(CC) $(CFLAGS) $(CDEFS) -MD -c $< -o $@
+	$(call cmd,c_compile)
 	@mv $(<:%.c=%.d) $(<:%.c=.deps/%.d)
 
 %.o: %.cpp  $(MAKE_CONFIG) endian.h table/strings.h
-	@echo '===> Compiling $<'
-	$(Q)$(CXX) $(CFLAGS) $(CDEFS) -MD -c $< -o $@
+	$(call cmd,cxx_compile)
 	@mv $(<:%.c=%.d) $(<:%.c=.deps/%.d)
 
 # Silence stale header dependencies
@@ -950,6 +970,6 @@
 
 
 info:
-	@echo 'CFLAGS  = $(CFLAGS) $(CDEFS)'
+	@echo 'CFLAGS  = $(CFLAGS)'
 	@echo 'LDFLAGS = $(LDFLAGS)'
 	@echo 'LIBS    = $(LIBS)'