Skip to content

Commit

Permalink
Merge pull request #507 from vhda/main/make-simple-echo
Browse files Browse the repository at this point in the history
make: Simplify compiler echo string during make
  • Loading branch information
vhda committed Sep 21, 2015
2 parents 943467c + 42008d0 commit c13d9dd
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 24 deletions.
76 changes: 59 additions & 17 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,31 @@ DEST_READ_INC = $(incdir)/$(READ_INC)
DEST_CMAN = $(man1dir)/$(CMAN)
DEST_EMAN = $(man1dir)/$(EMAN)

#
# Silent/verbose commands
#
# when V is not set the output of commands is ommited or simplified
#
V ?= 0

SILENT = $(SILENT_$(V))
SILENT_0 = @
SILENT_1 =

V_CC = $(V_CC_$(V))
V_CC_0 = @echo [CC] $@;
V_CC_1 =

#
# primary rules
#
all: $(CTAGS_EXEC) $(READ_LIB) $(READ_CMD)

$(CTAGS_EXEC): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
$(V_CC) $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)

$(READ_CMD): readtags.c readtags.h
$(CC) -DREADTAGS_MAIN -I. -I$(srcdir) -I$(srcdir)/main $(DEFS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(srcdir)/readtags.c
$(V_CC) $(CC) -DREADTAGS_MAIN -I. -I$(srcdir) -I$(srcdir)/main $(DEFS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(srcdir)/readtags.c

$(OBJECTS): $(HEADERS) config.h Makefile

Expand All @@ -174,16 +189,16 @@ $(OBJECTS): $(HEADERS) config.h Makefile
# works with GNU make but should be harmless for other implementations.
%: Makefile
Makefile: Makefile.in config.status
./config.status --file $@
$(SILENT) ./config.status --file $@

config.h: config.h.in config.status
./config.status --header $@
$(SILENT) ./config.status --header $@

# Regenerate the build system whenever it changed
config.status: configure
./config.status --recheck
$(SILENT) ./config.status --recheck
configure: configure.ac
cd $(srcdir) && autoreconf -vi
$(SILENT) cd $(srcdir) && autoreconf -vi

#
# generic install rules
Expand Down Expand Up @@ -336,8 +351,9 @@ TAGS: $(CTAGS_EXEC)
./$(CTAGS_EXEC) -e $(srcdir)/*

clean: clean-units clean-gcov clean-tmain
rm -f $(OBJECTS) $(CTAGS_EXEC) tags TAGS $(READ_LIB)
rm -f $(SOURCES:.c=.gcno)
$(SILENT) echo Cleaning top level
$(SILENT) rm -f $(OBJECTS) $(CTAGS_EXEC) tags TAGS $(READ_LIB)
$(SILENT) rm -f $(SOURCES:.c=.gcno)

mostlyclean: clean

Expand All @@ -352,8 +368,8 @@ maintainerclean: distclean
# implicit rules
#
.c.$(OBJEXT):
dir="$$(dirname $@)"; [ -d "$$dir" ] || $(MKDIR_P) "$$dir"
$(CC) -I. -I$(srcdir) -I$(srcdir)/main $(DEFS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ -c $<
$(SILENT) dir="$$(dirname $@)"; [ -d "$$dir" ] || $(MKDIR_P) "$$dir"
$(V_CC) $(CC) -I. -I$(srcdir) -I$(srcdir)/main $(DEFS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ -c $<
$(addsuffix .$(OBJEXT),$(basename $(notdir $(REGEX_SOURCES)))): ALL_CPPFLAGS += \
-D_GNU_SOURCE -D__USE_GNU -Dbool=int -Dfalse=0 -Dtrue=1

Expand Down Expand Up @@ -385,7 +401,7 @@ ifdef TRAVIS
SHOW_DIFF_OUTPUT=--show-diff-output
endif

.PHONY: check units fuzz noise tmain tinst clean-units clean-tmain clean-gcov run-gcov codecheck
.PHONY: check units fuzz noise tmain tinst clean-units clean-tmain clean-gcov run-gcov codecheck help
check: tmain units

#
Expand Down Expand Up @@ -441,8 +457,9 @@ units: $(CTAGS_TEST)
$(SHELL) $${c} $(srcdir)/Units $${builddir}/Units

clean-units:
builddir=$$(pwd); \
$(SHELL) $(srcdir)/misc/units clean $${builddir}/Units
$(SILENT) echo Cleaning test units
$(SILENT) builddir=$$(pwd); \
$(SHELL) $(srcdir)/misc/units clean $${builddir}/Units

#
# Test main part, not parsers
Expand All @@ -462,8 +479,9 @@ tmain: $(CTAGS_TEST)
$(SHELL) $${c} $(srcdir)/Tmain $${builddir}/Tmain

clean-tmain:
builddir=$$(pwd); \
$(SHELL) $(srcdir)/misc/units clean-tmain $${builddir}/Tmain
$(SILENT) echo Cleaning main part tests
$(SILENT) builddir=$$(pwd); \
$(SHELL) $(srcdir)/misc/units clean-tmain $${builddir}/Tmain

#
# Test installation
Expand All @@ -490,7 +508,31 @@ run-gcov:
gcov $$(find -name '*.gcda')

clean-gcov:
rm -f $(SOURCES:.c=.gcda)
rm -f $(srcdir)/*.gcov
$(SILENT) echo Cleaning coverage reports
$(SILENT) rm -f $(SOURCES:.c=.gcda)
$(SILENT) rm -f $(srcdir)/*.gcov

#
# Help
#
help:
@echo "Compilation targets:"
@echo ""
@echo "make - Build $(CTAGS_PROG)"
@echo "make V=1 - Build $(CTAGS_PROG) - verbose output"
@echo "make -f mk_mingw.mak - Build $(CTAGS_PROG) using MinGW"
@echo "make -f mk_mingw.mak V=1 - Build $(CTAGS_PROG) using MinGW - verbose output"
@echo ""
@echo "Testing targets:"
@echo ""
@echo "make units - Run parser unit test cases"
@echo "make tmain - Run ctags main functionality test cases"
@echo "make fuzz - Verify that all parsers are able to properly process each available test unit"
@echo "make noise - TODO"
@echo
@echo "Arguments that can be used in testing targets:"
@echo "VG=1 - Run test cases with Valgrind memory profiler"
@echo "LANGUAGES=<language>[,<language>] - Only run test cases of the selected languages"
@echo "CATEGORIES=<category> - Only run tests available under folder Units/<category>.r"

# vi:set tabstop=8:
31 changes: 24 additions & 7 deletions mk_mingw.mak
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,37 @@ dctags.exe: SOURCES += debug.c

.SUFFIXES: .c.o

#
# Silent/verbose commands
#
# when V is not set the output of commands is ommited or simplified
#
V ?= 0

SILENT = $(SILENT_$(V))
SILENT_0 = @
SILENT_1 =

V_CC = $(V_CC_$(V))
V_CC_0 = @echo [CC] $@;
V_CC_1 =


.c.o:
$(CC) -c $(OPT) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
$(V_CC) $(CC) -c $(OPT) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<

ctags: ctags.exe
dctags: dctags.exe

ctags.exe dctags.exe: $(OBJECTS) $(HEADERS) $(REGEX_HEADERS) $(FNMATCH_HEADERS)
$(CC) $(OPT) $(CFLAGS) $(LDFLAGS) $(DEFINES) $(INCLUDES) -o $@ $(OBJECTS) $(LIBS)
$(V_CC) $(CC) $(OPT) $(CFLAGS) $(LDFLAGS) $(DEFINES) $(INCLUDES) -o $@ $(OBJECTS) $(LIBS)

readtags.exe: readtags.c
$(CC) $(OPT) $(CFLAGS) -DREADTAGS_MAIN $(DEFINES) $(INCLUDES) -o $@ $<
$(V_CC) $(CC) $(OPT) $(CFLAGS) -DREADTAGS_MAIN $(DEFINES) $(INCLUDES) -o $@ $<

clean:
- rm -f ctags.exe
- rm -f dctags.exe
- rm -f tags
- rm -f main/*.o parsers/*.o gnu_regex/*.o fnmatch/*.o
$(SILENT) echo Cleaning
$(SILENT) rm -f ctags.exe
$(SILENT) rm -f dctags.exe
$(SILENT) rm -f tags
$(SILENT) rm -f main/*.o parsers/*.o gnu_regex/*.o fnmatch/*.o

0 comments on commit c13d9dd

Please sign in to comment.