Skip to content

Commit

Permalink
Add initial work for generating .gitignore on the fly.
Browse files Browse the repository at this point in the history
Needs polishing.

Signed-off-by: Garrett Cooper <[email protected]>
  • Loading branch information
Garrett Cooper committed Dec 17, 2010
1 parent c6fd0e4 commit bb557c6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#
# Top-level Makefile for LTP. See INSTALL for more info.
#
# Copyright (C) 2009, Cisco Systems Inc.
# Copyright (C) 2009-2010, Cisco Systems Inc.
# Copyright (C) 2010-2011, Linux Test Project.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -29,6 +30,7 @@ top_srcdir ?= $(CURDIR)

include $(top_srcdir)/include/mk/env_pre.mk
include $(top_srcdir)/include/mk/automake.mk
include $(top_srcdir)/include/mk/gitignore.mk

.SUFFIXES:
.SUFFIXES: .am .default .h .in .m4 .mk
Expand Down
2 changes: 1 addition & 1 deletion include/mk/env_pre.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ srcdir := .
endif

# autotools, *clean, and help don't require config.mk, features.mk, etc...
ifeq ($(filter autotools %clean help,$(MAKECMDGOALS)),)
ifeq ($(filter autotools %clean .gitignore gitignore.% help,$(MAKECMDGOALS)),)

include $(abs_top_builddir)/include/mk/config.mk
include $(abs_top_builddir)/include/mk/features.mk
Expand Down
51 changes: 51 additions & 0 deletions include/mk/gitignore.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# gitignore generation include Makefile.
#
# Copyright (C) 2011, Linux Test Project.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Garrett Cooper, January 2011
#

CLEAN_TARGETS+= gitignore_clean

BEFORE:= .gitignore-before

AFTER:= .gitignore-after

IGNORE_DIR_EXPR:= egrep -v "^$$(echo "$(AUTOCONFED_SUBDIRS)" | tr " " "|")"

# NOTE: The underscore is used in place of a dash to avoid implicit rule
# evaluation in top-level Makefile.
.PHONY: gitignore_clean
gitignore_clean:
$(RM) -f $(BEFORE) $(AFTER)

$(BEFORE):
$(MAKE) distclean
$(MAKE) ac-maintainer-clean
find . | $(IGNORE_DIR_EXPR) > $@

$(AFTER):
$(MAKE) autotools
./configure --prefix=/dev/null
$(MAKE) all
find . | $(IGNORE_DIR_EXPR) > $@
# Set everything in autoconf land back to a sane state.
$(MAKE) distclean

.gitignore: | $(BEFORE) $(AFTER)
diff -u $(BEFORE) $(AFTER) | grep '^+' | sed -e 's,^\+,,g' > $@
3 changes: 2 additions & 1 deletion testcases/realtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ include $(top_srcdir)/include/mk/env_pre.mk
#
# NOTE (garrcoop): this criterium should be in-sync with include/mk/env_pre.mk
# (minus help as that's only invoked in the top-level Makefile).
ifeq ($(filter autotools %clean,$(MAKECMDGOALS)),)
ifeq ($(filter autotools %clean .gitignore gitignore.%,$(MAKECMDGOALS)),)
include $(abs_srcdir)/config.mk
endif
include $(top_srcdir)/include/mk/gitignore.mk

LIBDIR := lib
FILTER_OUT_DIRS := $(LIBDIR) m4
Expand Down

0 comments on commit bb557c6

Please sign in to comment.