#! /bin/sh
# ======================================================================
#  $Id: makebinmakedependencies,v 1.4 2003/10/10 10:16:26 goiwai Exp $
#  $Name: CLDAQ-1-11-00 $
#  $Log: makebinmakedependencies,v $
#  Revision 1.4  2003/10/10 10:16:26  goiwai
#  ちょとだけ変更しました.
#
#  Revision 1.3  2003/10/06 13:31:43  goiwai
#  cldaq-config
#
#  Revision 1.2  2003/07/30 16:12:50  goiwai
#  ファイルにコミットログをつけることにしました.
#
# ======================================================================
tmpdir="$1"
shift
gmk="bindep.gmk"
gmk="$tmpdir/$gmk"
echo="echo -e"
if [ ! -d $tmpdir ]; then
  mkdir -p $tmpdir;
fi
if [ -e $gmk ]; then
  rm -f $gmk
fi
touch $gmk


for exe in $*; do
cat >> $gmk << EOF
# ----------------------------------------------------------------------
# begin of dependencies for $exe
\$(CLDAQ_BIN_DIR)/$exe: \$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/obj.last
	@if [ ! -d \$(CLDAQ_BIN_DIR) ]; then mkdir -p \$(CLDAQ_BIN_DIR); fi
	@\$(ECHO) Linking $exe using granular libraries ...
	@\$(CXX) \$(CXXFLAGS) \$(CPPFLAGS) \$(OUT_EXE)\$(CLDAQ_BIN_DIR)/$exe \$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/$exe.o \$(LDFLAGS) \$(LDLIBS)


ifeq (\$(CLDAQ_ONLY_EXE),0)
\$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/obj.last: lib \$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/$exe.o
else
\$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/obj.last: \$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/$exe.o
endif
	@touch \$@


\$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/$exe.o: $exe.cc
	@\$(ECHO) Compiling $exe.cc ...
	@\$(CXX) \$(CXXFLAGS) \$(CPPFLAGS) \$(APPFLAGS) -c \$(OUT_OBJ)\$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/$exe.o $exe.cc


\$(CLDAQ_TARGET_TMP_DIR)/$exe/exe/$exe.d: $exe.cc
	@if [ ! -d \$(CLDAQ_TARGET_TMP_DIR)/$exe/exe ]; then mkdir -p \$(CLDAQ_TARGET_TMP_DIR)/$exe/exe; fi
	@echo Making dependency for file \$< ...
	@(\$(ECHO) \$(CLDAQ_TARGET_TMP_DIR)/exe/\\\\c; \$(CXX) \$(GPPFLAGS) \$(CPPFLAGS) \$< ) | sed 's!\$(CLDAQ_TARGET_TMP_DIR)/exe/\$*.o!& \$@!' > \$@
# end of dependencies for $exe
# ----------------------------------------------------------------------




EOF
done

exit 0
