1#! /bin/bash
2#
3# This manages the generation of the Visual Studio build files for Windows.
4
5if test x"$COINDIR" = x""; then
6  echo "error: COINDIR must be set before running this script"
7  exit
8fi
9
10if ! perl -e 'exit 0' 2>/dev/null ; then
11  echo "You need to have perl installed to run this script"
12  exit
13fi
14
15project_name=coin
16project=${project_name}$(fgrep -i "${project_name}_MAJOR_VERSION=" ../../configure | cut -d= -f2)
17
18function cleansolution() {
19  name=$1;
20  rm -f ${name}.dsw ${name}.sln;
21}
22
23function cleanproject() {
24  name=$1;
25  rm -f ${name}.dsp ${name}.vcproj;
26}
27
28proper=true;
29
30cleansolution ${project}
31cleanproject ${project}
32cleanproject ${project}_install
33cleanproject ${project}_uninstall
34cleanproject ${project}_docs
35
36rm -f install-headers.bat uninstall-headers.bat;
37
38build_pwd=`pwd`;
39build="`cygpath -w $build_pwd | sed -e 's/\\\\/\\\\\\\\/g'`";
40build_pwd="`pwd | sed -e 's/\\//\\\\\\\\/g'`\\\\";
41
42source_pwd=`cd ../..; pwd`;
43source="`cygpath -w $source_pwd | sed -e 's/\\\\/\\\\\\\\/g'`";
44source_pwd="`(cd ../..; pwd) | sed -e 's/\\//\\\\\\\\/g'`";
45
46if $proper; then
47  ../../configure --with-msvcrt=mtd --with-suffix=d \
48    --enable-3ds-import \
49    --enable-debug --enable-symbols \
50    htmldir=../html || exit 1;
51  mv src/config.h src/config-debug.h;
52
53  ../../configure --enable-msvcdsp --with-msvcrt=mt \
54    --enable-3ds-import \
55    --disable-debug --disable-symbols --enable-optimization \
56    || exit 1;
57  mv src/config.h src/config-release.h;
58
59  cp ../misc/config-wrapper.h src/config.h;
60else
61  ./config.status --file=cfg/gendsp.pl;
62fi
63
64make || exit 1
65
66if $proper; then
67  sed \
68    -e "s/$build/./g" \
69    -e "s/$build_pwd//g" \
70    -e "s/$source/..\\\\../g" \
71    -e "s/$source_pwd/..\\\\../g" \
72    -e 's/$/\r/g' \
73    <${project}.dsp >new.dsp
74
75  mv new.dsp ${project}.dsp
76
77  sed \
78    -e "s/$build/./g" \
79    -e "s/$build_pwd//g" \
80    -e "s/$source/..\\\\../g" \
81    -e "s/$source_pwd/..\\\\../g" \
82    -e 's/$/\r/g' \
83    <install-headers.bat >new.bat
84  rm -f install-headers.bat
85  mv -f new.bat ../misc/install-headers.bat
86
87  sed \
88    -e "s/$build/./g" \
89    -e "s/$build_pwd//g" \
90    -e "s/$source/..\\\\../g" \
91    -e "s/$source_pwd/..\\\\../g" \
92    -e 's/$/\r/g' \
93    <uninstall-headers.bat >new.bat
94  rm -f uninstall-headers.bat
95  mv -f new.bat ../misc/uninstall-headers.bat
96fi
97
98make docs/coin.doxygen
99mv docs/coin.doxygen docs/doxygen.bak
100sed \
101  -e "s/$build/./g" \
102  -e "s/$build_pwd//g" \
103  -e "s/$source/..\\\\../g" \
104  -e "s/$source_pwd/..\\\\../g" \
105  -e "s/GENERATE_HTML.*=.*NO/GENERATE_HTML = YES/g" \
106  -e "s/HTML_OUTPUT.*=.*/HTML_OUTPUT = ..\\\\html/g" \
107  -e "s/GENERATE_TAGFILE.*=.*/GENERATE_TAGFILE = ..\\\\html\\\\coin.tag/g" \
108  -e 's/$/\r/g' \
109  <docs/doxygen.bak >docs/${project}.doxygen
110rm docs/doxygen.bak
111
112echo "Done."
113echo "Make sure the ${project}.dsp file does not contain any absolute paths."
114echo "Here are some indicator tests."
115echo ""
116
117set -x
118grep -i "\\(c:\\|@\\)" ${project}.dsp /dev/null
119grep -i "cygdrive" ${project}.dsp /dev/null
120grep "hg" ${project}.dsp /dev/null
121sort ../misc/install-headers.bat | uniq -c | grep -v " 1 "
122grep "SOURCE=" ${project}.dsp | sort | uniq -c | grep -v " 1 "
123set +x
124
125echo ""
126echo "If everything seems OK, upgrade the project files (if necessary) with"
127echo "  devenv.exe (for msvc7 and msvc8), or"
128echo "  VCExpress.exe (for msvc9)."
129echo ""
130