moved items that a normal make doesn't create to distclean
[physics.git] / src / Makefile
index 915e4ed..885bc9e 100644 (file)
@@ -40,7 +40,7 @@ OBJS := ${SRCS:.cpp=.o}
 
 
 TARGET := ../run_physics
-DEPEND := depend.mk
+DEPENDS := ${SRCS:.cpp=.d}
 
 
 .PHONY: all
@@ -48,20 +48,23 @@ all: ${TARGET}
 
 ${TARGET}: ${OBJS}
        ${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
+       @echo ""
 
-.PHONY: depend
-depend: ${SRCS}
-       ${CXX} -MM $^ > ${DEPEND}
+# how to make a depend file from a source file
+%.d: %.cpp
+       @echo "DEP: $@"
+       @${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
+
+#@${CXX} -M ${CXXFLAGS} $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
 
 
 .PHONY: clean
 clean:
-       rm -f ${OBJS} ${TARGET} *~ prof gmon.out
+       rm -f ${OBJS} ${TARGET}
 
 .PHONY: distclean
 distclean: clean
-       rm -f tags depend.mk
-       touch depend.mk
+       rm -f ${DEPENDS} tags prof gmon.out
 
 tags: ${SRCS}
        ctags $^
@@ -84,4 +87,4 @@ prof: all
        gprof -b ${TARGET} > prof
        kprof -f prof
 
-include ${DEPEND}
+-include ${DEPENDS}