#!/bin/bash

# Use this to remove dependencies like  /usr/*  and  */contrib*  and  */qt*

# Usage example:
# cd OpenMS; dependencies-strip; ...

# Now "make" will traverse the directories much faster,
# because it doesn't look at many files that are not going to change anyway.
# E.g. the remaining dependencies are about 27% of original in source/TEST.

echo 'Stripping depend.make files:  remove dependencies like   /usr/*  */contrib*  */qt* '

for file in $(find . -name depend.make); do
	echo processing file  $file;
	sed -i 's+\(^.*CMakeFiles/[^ \]*\.o: /[^ \]*/contrib.*/\([^/]*\)$\)+\# \2+g; s+\(^.*CMakeFiles/[^ \]*\.o: /usr/.*/\([^/]*\)$\)+\# \2+g; s+\(^.*CMakeFiles/[^ \]*\.o: /[^ \]*/qt.*/\([^/]*\)$\)+\# \2+g; ' $file;
done;

#------------------------
# OLD STUFF BELOW!  FOR NOW WE LEAVE A COMMENT BUT THIS MAY CHANGE ONCE WE ARE SURE IT WORKS.  THEN WE SHOULD COMPRESS THE RESULTING EMPTY LINES AS WELL.  (CLEMENS 2009-03-09)
#
# This "sed" script does the following:
# 1. replace all files in /usr (system files) or from the contrib package by whitespace
# and after that,
# 2. delete all lines that contain only whitespace until a "\" at the very end
#
#find . -name depend.make | xargs sed -i 's:[^ \]*/contrib[^/]*/[^ \]*::g; s:/usr/[^ \]*::g; /^[    ]*\\$/ D'
#------------------------

echo "...done."


