From 7a8e9d4ddbe121bf2cafb095e9ecf262bc074133 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 3 Mar 2008 13:04:08 +0000 Subject: Add a gitignore make target. --- mk/depend.mk | 1 + mk/gitignore.mk | 15 +++++++++++++++ mk/lib.mk | 3 +++ mk/prog.mk | 5 ++++- mk/scripts.mk | 2 ++ mk/subdir.mk | 2 ++ 6 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 mk/gitignore.mk (limited to 'mk') diff --git a/mk/depend.mk b/mk/depend.mk index a4d717ae..3d72cac1 100644 --- a/mk/depend.mk +++ b/mk/depend.mk @@ -4,6 +4,7 @@ # Copyright 2008 Roy Marples CLEANFILES+= .depend +IGNOREFILES+= .depend .depend: ${SRCS} ${CC} ${CFLAGS} -MM ${SRCS} > .depend diff --git a/mk/gitignore.mk b/mk/gitignore.mk new file mode 100644 index 00000000..34d3539e --- /dev/null +++ b/mk/gitignore.mk @@ -0,0 +1,15 @@ +# rules to make .gitignore files +# Copyright 2008 Roy Marples + +IGNOREFILES+= ${CLEANFILES} + +.gitignore: + for obj in ${IGNOREFILES}; do \ + if ! test -r .gitignore; then \ + echo "$${obj}" > .gitignore || exit $$?; \ + elif ! grep -q "^$${obj}$$" .gitignore; then \ + echo "$${obj}" >> .gitignore || exit $$?; \ + fi; \ + done + +gitignore: .gitignore diff --git a/mk/lib.mk b/mk/lib.mk index 825af96d..a649c2ca 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -11,6 +11,8 @@ OBJS+= ${SRCS:.c=.o} SOBJS+= ${OBJS:.o=.So} _LIBS= lib${LIB}.a ${SHLIB_NAME} +CLEANFILES+= ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} + .SUFFIXES: .So .c.So: @@ -50,3 +52,4 @@ clean: include ${MK}/sys.mk include ${MK}/depend.mk +include ${MK}/gitignore.mk diff --git a/mk/prog.mk b/mk/prog.mk index a52681f2..46bfb56b 100644 --- a/mk/prog.mk +++ b/mk/prog.mk @@ -20,12 +20,15 @@ LDFLAGS+= ${_DYNLINK}$(shell ${_DYNLINK_SH}) LDFLAGS+= -Wl,-rpath=${PREFIX}/${LIBNAME} -L${PREFIX}/${LIBNAME} LDFLAGS+= ${PROGLDFLAGS} +CLEANFILES+= ${OBJS} ${PROG} + all: depend ${PROG} ${PROG}: ${SCRIPTS} ${OBJS} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} clean: - rm -f ${OBJS} ${PROG} ${CLEANFILES} + rm -f ${CLEANFILES} include ${MK}/depend.mk +include ${MK}/gitignore.mk diff --git a/mk/scripts.mk b/mk/scripts.mk index 34536f85..81fae3d2 100644 --- a/mk/scripts.mk +++ b/mk/scripts.mk @@ -41,3 +41,5 @@ install: all realinstall ${INSTALLAFTER} CLEANFILES+= ${OBJS} clean: if test -n "${CLEANFILES}"; then rm -f ${CLEANFILES}; fi + +include ${MK}/gitignore.mk diff --git a/mk/subdir.mk b/mk/subdir.mk index d3074ca1..6d9031d2 100644 --- a/mk/subdir.mk +++ b/mk/subdir.mk @@ -37,3 +37,5 @@ realinstall: install: realinstall ${INSTALLAFTER} depend: ${_SUBDIR} +gitignore: + ${_SUBDIR} -- cgit v1.2.3