有一個實用程序帶有增強功能,名爲bcp
,它可以掃描您的源代碼並提取從boost源中使用的任何boost文件頭文件。我已經設置了一個腳本,將其抽取到我們的源代碼樹中,以便我們可以打包我們需要的源代碼和我們的代碼。它還會將boost源文件複製到我們使用的幾個boost庫中,這些庫不僅僅是頭文件,而是直接編譯到我們的應用程序中。
這樣做一次,然後任何使用代碼的人甚至不需要知道它依賴於boost。這是我們使用的。它也將建立bjam和bcp,如果它們尚未建立。
#!/bin/sh
BOOST_SRC=.../boost_1_43_0
DEST_DIR=../src/boost
TOOLSET=
if (test `uname` = "Darwin") then
TOOLSET="--toolset=darwin"
fi
# make bcp if necessary
if (! test -x $BOOST_SRC/dist/bin/bcp) then
if (test -x $BOOST_SRC/tools/jam/*/bin.*/bjam) then
BJAM=$BOOST_SRC/tools/jam/*/bin.*/bjam
else
echo "### Building bjam"
pushd $BOOST_SRC/tools/jam
./build_dist.sh
popd
if (test -x $BOOST_SRC/tools/jam/*/bin.*/bjam) then
BJAM=$BOOST_SRC/tools/jam/*/bin.*/bjam
fi
fi
echo "BJAM: $BJAM"
pushd $BOOST_SRC/tools/bcp
echo "### Building bcp"
echo "$BJAM $TOOLSET"
$BJAM $TOOLSET
if [ $? == "0" ]; then
exit 1;
fi
popd
fi
if (! test -x $BOOST_SRC/dist/bin/bcp) then
echo "### Couldn't find bpc"
exit 1;
fi
mkdir -p $DEST_DIR
echo "### Copying boost source"
MAKEFILEAM=$DEST_DIR/libs/Makefile.am
rm $MAKEFILEAM
# Signals
# copy source libraries
mkdir -p $DEST_DIR/libs/signals/src
cp $BOOST_SRC/libs/signals/src/* $DEST_DIR/libs/signals/src/.
echo -n "boost_sources += " >> $MAKEFILEAM
for f in `ls $DEST_DIR/libs/signals/src | fgrep .cpp`; do
echo -n "boost/libs/signals/src/$f " >> $MAKEFILEAM
done
echo >> $MAKEFILEAM
echo "### Extracting boost includes"
$BOOST_SRC/dist/bin/bcp --scan --boost=$BOOST_SRC ../src/*/*.[Ch] ../src/boost/libs/*/src/*.cpp ../src/smart_assert/smart_assert/priv/fwd/*.hpp $DEST_DIR
if [ $? != "0" ]; then
echo "### bcp failed"
rm -rf $DEST_DIR
exit 1;
fi
你想走多遠這條路?那麼他們可能沒有安裝的其他庫呢?您可能想要查看某種包管理器或自動編譯機制(可能是shar壓縮文件?)。 – KeithB 2010-05-20 21:12:09