From 88ecdb2637f7de4b90d11a5df09be7fda3bf2b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Thu, 15 Sep 2005 12:02:54 +0000 Subject: automatic dependency generation on-the-fly sources generation (iemmatrix.c mtx_*.c) svn path=/trunk/externals/iem/iemmatrix/; revision=3563 --- src/Makefile.in | 30 +++++++++++++++++++++--------- src/configure.ac | 8 ++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Makefile.in b/src/Makefile.in index fd138d3..290efb9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -8,6 +8,7 @@ INSTALL_DOC=$(PREFIX)/@REFERENCEPATH@$(LIBNAME) EXT = @EXT@ DEFS = @DFLAGS@ IFLAGS = -I. @INCLUDES@ $(INCLUDES) +MAKEDEP_FLAGS = @MAKEDEP_FLAGS@ CC = @CC@ LD = @LD@ @@ -24,27 +25,37 @@ TARNAME = $(LIBNAME)-@IEMMATRIX_VERSION@.tgz CFLAGS = $(DEFS) $(IFLAGS) $(WFLAGS) @CFLAGS@ LIBS = @LIBS@ -include Make.source -TARGETS = $(SOURCES:.c=.o) +SOURCES=$(sort $(filter %.c, $(wildcard mtx_*.c))) iemmatrix.c +TARGETS = $(SOURCES:.c=.o) all: $(LIBNAME) + echo targets $(TARGETS) cp $(LIBNAME).$(EXT) .. $(LIBNAME): $(TARGETS) $(LD) $(LFLAGS) -o $(LIBNAME).$(EXT) *.o $(LIBS) $(STRIP) @STRIPFLAGS@ $(LIBNAME).$(EXT) +## dependencies: as proposed by the GNU-make documentation +## see http://www.gnu.org/software/make/manual/html_node/make_47.html#SEC51 +-include $(SOURCES:.c=.d) +%.d: %.c + @set -e; rm -f $@; \ + $(CXX) $(MAKEDEP_FLAGS) $(CFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + clean: -rm -f *.$(EXT) *.o cleaner: clean - -rm -f *~ _* config.* + -rm -f *~ _* config.* *.d *.d.* cleanest: cleaner - -rm -f Makefile ../*.$(EXT) Make.source + -rm -f Makefile ../*.$(EXT) -distclean: cleanest newmakefile +distclean: cleanest install: install-bin install-doc @@ -65,7 +76,8 @@ newmakefile: echo "current:">Makefile echo " ./configure && make">>Makefile -source: - echo "SOURCES = \\"> Make.source - echo `ls mtx_*.c $(LIBNAME).c` >> Make.source - echo >> Make.source +Makefile: Makefile.in configure + ./configure + +configure: configure.ac + autoconf diff --git a/src/configure.ac b/src/configure.ac index 97ce924..0cc015b 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -64,6 +64,14 @@ dnl Checks for library functions. AC_FUNC_MMAP AC_CHECK_FUNCS(select socket strerror) + +### make-depend flags +if test "x$ac_cv_c_compiler_gnu" = "xyes"; then + AC_SUBST(MAKEDEP_FLAGS, "-MM") +else + AC_SUBST(MAKEDEP_FLAGS, "-M") +fi + dnl check for "-mms-bitfields" cflag dnl why is there no generic compiler-check for a given flag ? dnl it would make things so easy: AC_CHECK_FLAG([-mms-bitfields],,) -- cgit v1.2.1