vc_gen.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. #! /usr/bin/env bash
  2. # copyright John Maddock 2005
  3. # Use, modification and distribution are subject to the
  4. # Boost Software License, Version 1.0. (See accompanying file
  5. # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. libname=""
  7. src=""
  8. header=""
  9. all_dep=""
  10. # current makefile:
  11. out=""
  12. # temporary file:
  13. tout=""
  14. # install target temp file:
  15. iout=""
  16. # debug flag:
  17. debug="no"
  18. # compile options:
  19. opts=""
  20. # main output sub-directory:
  21. subdir=""
  22. # extra debug /RTc options:
  23. debug_extra=""
  24. function vc6_gen_lib()
  25. {
  26. all_dep="$all_dep $libname""_dir ./$subdir/$libname.lib ./$subdir/$libname.exe"
  27. echo " copy $subdir\\$libname.lib "'"$'"(MSVCDIR)\\lib"'"' >> $iout
  28. if test $debug == "yes"; then
  29. echo " copy $subdir\\$libname.pdb "'"$'"(MSVCDIR)\\lib"'"' >> $iout
  30. fi
  31. #
  32. # set up section comments:
  33. cat >> $tout << EOF
  34. ########################################################
  35. #
  36. # section for $libname.lib
  37. #
  38. ########################################################
  39. EOF
  40. #
  41. # process source files:
  42. all_obj=""
  43. for file in $src
  44. do
  45. obj=`echo "$file" | sed 's/\(.*\)cpp/\1obj/g'`
  46. obj="$subdir/$libname/$obj"
  47. all_obj="$all_obj $obj"
  48. echo "$obj: $file \$(ALL_HEADER)" >> $tout
  49. echo " cl /c \$(INCLUDES) $opts \$(CXXFLAGS) -Y- -Fo./$subdir/$libname/ -Fd$subdir/$libname.pdb $file" >> $tout
  50. echo "" >> $tout
  51. done
  52. #
  53. # now for the directories for this library:
  54. echo "$libname"_dir : >> $tout
  55. echo " @if not exist \"$subdir\\$libname\\\$(NULL)\" mkdir $subdir\\$libname" >> $tout
  56. echo "" >> $tout
  57. #
  58. # now for the clean options for this library:
  59. all_clean="$all_clean $libname""_clean"
  60. echo "$libname"_clean : >> $tout
  61. echo " del $subdir\\$libname\\"'*.obj' >> $tout
  62. echo " del $subdir\\$libname\\"'*.idb' >> $tout
  63. echo " del $subdir\\$libname\\"'*.exp' >> $tout
  64. echo " del $subdir\\$libname\\"'*.pch' >> $tout
  65. echo "" >> $tout
  66. #
  67. # now for the main target for this library:
  68. echo ./$subdir/$libname.lib : $all_obj >> $tout
  69. echo " link -lib /nologo /out:$subdir/$libname.lib \$(XSFLAGS) $all_obj" >> $tout
  70. echo "" >> $tout
  71. # now the test program:
  72. echo ./$subdir/$libname.exe : main.cpp ./$subdir/$libname.lib >> $tout
  73. echo " cl \$(INCLUDES) $opts /DBOOST_LIB_DIAGNOSTIC=1 \$(CXXFLAGS) -o ./$subdir/$libname.exe main.cpp /link /LIBPATH:./$subdir" >> $tout
  74. echo " $subdir"'\'"$libname.exe" >> $tout
  75. echo "" >> $tout
  76. }
  77. function vc6_gen_dll()
  78. {
  79. all_dep="$all_dep $libname""_dir ./$subdir/$libname.lib ./$subdir/$libname.exe"
  80. echo " copy $subdir\\$libname.lib "'"$'"(MSVCDIR)\\lib"'"' >> $iout
  81. echo " copy $subdir\\$libname.dll "'"$'"(MSVCDIR)\\bin"'"' >> $iout
  82. if test $debug == "yes"; then
  83. echo " copy $subdir\\$libname.pdb "'"$'"(MSVCDIR)\\lib"'"' >> $iout
  84. fi
  85. #
  86. # set up section comments:
  87. cat >> $tout << EOF
  88. ########################################################
  89. #
  90. # section for $libname.lib
  91. #
  92. ########################################################
  93. EOF
  94. #
  95. # process source files:
  96. all_obj=""
  97. for file in $src
  98. do
  99. obj=`echo "$file" | sed 's/\(.*\)cpp/\1obj/g'`
  100. obj="$subdir/$libname/$obj"
  101. all_obj="$all_obj $obj"
  102. echo "$obj: $file \$(ALL_HEADER)" >> $tout
  103. echo " cl /c \$(INCLUDES) $opts \$(CXXFLAGS) -Y- -Fo./$subdir/$libname/ -Fd$subdir/$libname.pdb $file" >> $tout
  104. echo "" >> $tout
  105. done
  106. #
  107. # now for the directories for this library:
  108. echo "$libname"_dir : >> $tout
  109. echo " @if not exist \"$subdir\\$libname\\\$(NULL)\" mkdir $subdir\\$libname" >> $tout
  110. echo "" >> $tout
  111. #
  112. # now for the clean options for this library:
  113. all_clean="$all_clean $libname""_clean"
  114. echo "$libname"_clean : >> $tout
  115. echo " del $subdir\\$libname\\"'*.obj' >> $tout
  116. echo " del $subdir\\$libname\\"'*.idb' >> $tout
  117. echo " del $subdir\\$libname\\"'*.exp' >> $tout
  118. echo " del $subdir\\$libname\\"'*.pch' >> $tout
  119. echo "" >> $tout
  120. #
  121. # now for the main target for this library:
  122. echo ./$subdir/$libname.lib : $all_obj >> $tout
  123. echo " link kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:\"$subdir/$libname.pdb\" /debug /machine:I386 /out:\"$subdir/$libname.dll\" /implib:\"$subdir/$libname.lib\" /LIBPATH:\$(STLPORT_PATH)\\lib \$(XLFLAGS) $all_obj" >> $tout
  124. echo "" >> $tout
  125. # now the test program:
  126. echo ./$subdir/$libname.exe : main.cpp ./$subdir/$libname.lib >> $tout
  127. echo " cl \$(INCLUDES) $opts /DBOOST_LIB_DIAGNOSTIC=1 \$(CXXFLAGS) -o ./$subdir/$libname.exe main.cpp /link /LIBPATH:./$subdir" >> $tout
  128. echo " $subdir"'\'"$libname.exe" >> $tout
  129. echo "" >> $tout
  130. }
  131. is_stlport="no"
  132. function vc6_gen()
  133. {
  134. debug="no"
  135. tout="temp"
  136. iout="temp_install"
  137. all_dep="main_dir"
  138. all_clean=""
  139. echo > $out
  140. echo > $tout
  141. rm -f $iout
  142. libname="liblink_test-${subdir}-s-${boost_version}"
  143. opts='/nologo /ML /W3 /GX /O2 /GB /GF /Gy /I..\..\..\..\ /DWIN32 /DNDEBUG /D_MBCS /D_LIB /FD'
  144. vc6_gen_lib
  145. libname="liblink_test-${subdir}-mt-s-${boost_version}"
  146. opts='/nologo /MT /W3 /GX /O2 /GB /GF /Gy /I..\..\..\..\ /D_MT /DWIN32 /DNDEBUG /D_MBCS /D_LIB /FD '
  147. vc6_gen_lib
  148. debug="yes"
  149. libname="liblink_test-${subdir}-sgd-${boost_version}"
  150. opts='/nologo /MLd /W3 /Gm /GX /Zi /Od /I..\..\..\..\ /DWIN32 /D_DEBUG /D_MBCS /D_LIB /FD '"$debug_extra"' '
  151. vc6_gen_lib
  152. libname="liblink_test-${subdir}-mt-sgd-${boost_version}"
  153. opts='/nologo /MTd /W3 /Gm /GX /Zi /Od /I..\..\..\..\ /DWIN32 /D_MT /D_DEBUG /D_MBCS /D_LIB /FD '"$debug_extra"' '
  154. vc6_gen_lib
  155. libname="link_test-${subdir}-mt-gd-${boost_version}"
  156. opts='/nologo /MDd /W3 /Gm /GX /Zi /Od /I..\..\..\..\ /D_DEBUG /DBOOST_DYN_LINK /DWIN32 /D_WINDOWS /D_MBCS /DUSRDLL /FD '"$debug_extra"' '
  157. vc6_gen_dll
  158. debug="no"
  159. opts='/nologo /MD /W3 /GX /O2 /GB /GF /Gy /I..\..\..\..\ /DBOOST_DYN_LINK /DNDEBUG /DWIN32 /D_WINDOWS /D_MBCS /D_USRDLL /FD '
  160. libname="link_test-${subdir}-mt-${boost_version}"
  161. vc6_gen_dll
  162. debug="no"
  163. opts='/nologo /MD /W3 /GX /O2 /GB /GF /Gy /I..\..\..\..\ /DBOOST_REGEX_STATIC_LINK /DNDEBUG /DWIN32 /D_WINDOWS /D_MBCS /D_USRDLL /FD '
  164. libname="liblink_test-${subdir}-mt-${boost_version}"
  165. vc6_gen_lib
  166. debug="yes"
  167. libname="liblink_test-${subdir}-mt-gd-${boost_version}"
  168. opts='/nologo /MDd /W3 /Gm /GX /Zi /Od /I..\..\..\..\ /DBOOST_REGEX_STATIC_LINK /D_DEBUG /DWIN32 /D_WINDOWS /D_MBCS /DUSRDLL /FD '"$debug_extra"' '
  169. vc6_gen_lib
  170. cat > $out << EOF
  171. # copyright John Maddock 2005
  172. # Use, modification and distribution are subject to the
  173. # Boost Software License, Version 1.0. (See accompanying file
  174. # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  175. #
  176. # auto generated makefile for VC6 compiler
  177. #
  178. # usage:
  179. # make
  180. # brings libraries up to date
  181. # make install
  182. # brings libraries up to date and copies binaries to your VC6 /lib and /bin directories (recomended)
  183. #
  184. #
  185. # Add additional compiler options here:
  186. #
  187. CXXFLAGS=
  188. #
  189. # Add additional include directories here:
  190. #
  191. INCLUDES=
  192. #
  193. # add additional linker flags here:
  194. #
  195. XLFLAGS=
  196. #
  197. # add additional static-library creation flags here:
  198. #
  199. XSFLAGS=
  200. !IF "\$(OS)" == "Windows_NT"
  201. NULL=
  202. !ELSE
  203. NULL=nul
  204. !ENDIF
  205. !IF "\$(MSVCDIR)" == ""
  206. !ERROR Variable MSVCDIR not set.
  207. !ENDIF
  208. EOF
  209. echo "" >> $out
  210. echo "ALL_HEADER=$header" >> $out
  211. echo "" >> $out
  212. echo "all : $all_dep" >> $out
  213. echo >> $out
  214. echo "clean : $all_clean" >> $out
  215. echo >> $out
  216. echo "install : all" >> $out
  217. cat $iout >> $out
  218. echo >> $out
  219. echo main_dir : >> $out
  220. echo " @if not exist \"$subdir\\\$(NULL)\" mkdir $subdir" >> $out
  221. echo "" >> $out
  222. cat $tout >> $out
  223. }
  224. function vc6_stlp_gen()
  225. {
  226. debug="no"
  227. tout="temp"
  228. iout="temp_install"
  229. all_dep="main_dir"
  230. all_clean=""
  231. echo > $out
  232. echo > $tout
  233. rm -f $iout
  234. libname="liblink_test-${subdir}-mt-s-${boost_version}"
  235. opts='/nologo /MT /W3 /GX /O2 /GB /GF /Gy /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /D_MT /DWIN32 /DNDEBUG /D_MBCS /D_LIB '
  236. vc6_gen_lib
  237. debug="true"
  238. libname="liblink_test-${subdir}-mt-sgd-${boost_version}"
  239. opts='/nologo /MTd /W3 /Gm /GX /Zi /Od /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /DWIN32 /D_MT /D_DEBUG /D_MBCS /D_LIB '"$debug_extra"' '
  240. vc6_gen_lib
  241. libname="link_test-${subdir}-mt-gd-${boost_version}"
  242. opts='/nologo /MDd /W3 /Gm /GX /Zi /Od /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /DBOOST_DYN_LINK /D_DEBUG /DWIN32 /D_WINDOWS /D_MBCS /DUSRDLL '"$debug_extra"' '
  243. vc6_gen_dll
  244. debug="no"
  245. opts='/nologo /MD /W3 /GX /O2 /GB /GF /I$(STLPORT_PATH)\stlport /Gy /I..\..\..\..\ /DBOOST_DYN_LINK /DNDEBUG /DWIN32 /D_WINDOWS /D_MBCS /D_USRDLL '
  246. libname="link_test-${subdir}-mt-${boost_version}"
  247. vc6_gen_dll
  248. debug="no"
  249. opts='/nologo /MD /W3 /GX /O2 /GB /GF /Gy /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /DBOOST_REGEX_STATIC_LINK /DNDEBUG /DWIN32 /D_WINDOWS /D_MBCS /D_USRDLL '
  250. libname="liblink_test-${subdir}-mt-${boost_version}"
  251. vc6_gen_lib
  252. debug="true"
  253. libname="liblink_test-${subdir}-mt-gd-${boost_version}"
  254. opts='/nologo /MDd /W3 /Gm /GX /Zi /Od /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /DBOOST_REGEX_STATIC_LINK /D_DEBUG /DWIN32 /D_WINDOWS /D_MBCS /DUSRDLL '"$debug_extra"' '
  255. vc6_gen_lib
  256. # debug STLPort mode:
  257. # not yet supported by bjam?
  258. debug="yes"
  259. opts='/nologo /MDd /W3 /Gm /GX /Zi /Od /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /DBOOST_DYN_LINK /D__STL_DEBUG /D_STLP_DEBUG /D_DEBUG /DWIN32 /D_WINDOWS /D_MBCS /DUSRDLL '"$debug_extra"' '
  260. libname="link_test-${subdir}-mt-pgd-${boost_version}"
  261. vc6_gen_dll
  262. libname="liblink_test-${subdir}-mt-spgd-${boost_version}"
  263. opts='/nologo /MTd /W3 /Gm /GX /Zi /Od /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /D__STL_DEBUG /D_STLP_DEBUG /DWIN32 /D_MT /D_DEBUG /D_MBCS /D_LIB '"$debug_extra"' '
  264. vc6_gen_lib
  265. opts='/nologo /MDd /W3 /Gm /GX /Zi /Od /I$(STLPORT_PATH)\stlport /I..\..\..\..\ /DBOOST_REGEX_STATIC_LINK /D__STL_DEBUG /D_STLP_DEBUG /D_DEBUG /DWIN32 /D_WINDOWS /D_MBCS /DUSRDLL '"$debug_extra"' '
  266. libname="liblink_test-${subdir}-mt-pgd-${boost_version}"
  267. vc6_gen_lib
  268. cat > $out << EOF
  269. # copyright John Maddock 2005
  270. # Use, modification and distribution are subject to the
  271. # Boost Software License, Version 1.0. (See accompanying file
  272. # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  273. #
  274. # auto generated makefile for VC6+STLPort
  275. #
  276. # usage:
  277. # make
  278. # brings libraries up to date
  279. # make install
  280. # brings libraries up to date and copies binaries to your VC6 /lib and /bin directories (recomended)
  281. #
  282. #
  283. # Add additional compiler options here:
  284. #
  285. CXXFLAGS=
  286. #
  287. # Add additional include directories here:
  288. #
  289. INCLUDES=
  290. #
  291. # add additional linker flags here:
  292. #
  293. XLFLAGS=
  294. #
  295. # add additional static-library creation flags here:
  296. #
  297. XSFLAGS=
  298. !IF "\$(OS)" == "Windows_NT"
  299. NULL=
  300. !ELSE
  301. NULL=nul
  302. !ENDIF
  303. !IF "\$(MSVCDIR)" == ""
  304. !ERROR Variable MSVCDIR not set.
  305. !ENDIF
  306. !IF "\$(STLPORT_PATH)" == ""
  307. !ERROR Variable STLPORT_PATH not set.
  308. !ENDIF
  309. EOF
  310. echo "" >> $out
  311. echo "ALL_HEADER=$header" >> $out
  312. echo "" >> $out
  313. echo "all : $all_dep" >> $out
  314. echo >> $out
  315. echo "clean : $all_clean" >> $out
  316. echo >> $out
  317. echo "install : stlport_check all" >> $out
  318. cat $iout >> $out
  319. echo >> $out
  320. echo main_dir : >> $out
  321. echo " @if not exist \"$subdir\\\$(NULL)\" mkdir $subdir" >> $out
  322. echo "" >> $out
  323. echo 'stlport_check : $(STLPORT_PATH)\stlport\string' >> $out
  324. echo " echo" >> $out
  325. echo "" >> $out
  326. cat $tout >> $out
  327. }
  328. . common.sh
  329. #
  330. # generate vc6 makefile:
  331. debug_extra="/GX"
  332. out="vc6.mak"
  333. subdir="vc6"
  334. vc6_gen
  335. #
  336. # generate vc6-stlport makefile:
  337. is_stlport="yes"
  338. out="vc6-stlport.mak"
  339. no_single="yes"
  340. subdir="vc6-stlport"
  341. vc6_stlp_gen
  342. #
  343. # generate vc7 makefile:
  344. debug_extra="/GX /RTC1"
  345. is_stlport="no"
  346. out="vc7.mak"
  347. no_single="no"
  348. subdir="vc7"
  349. vc6_gen
  350. #
  351. # generate vc7-stlport makefile:
  352. is_stlport="yes"
  353. out="vc7-stlport.mak"
  354. no_single="yes"
  355. subdir="vc7-stlport"
  356. vc6_stlp_gen
  357. #
  358. # generate vc71 makefile:
  359. is_stlport="no"
  360. out="vc71.mak"
  361. no_single="no"
  362. subdir="vc71"
  363. vc6_gen
  364. #
  365. # generate vc71-stlport makefile:
  366. is_stlport="yes"
  367. out="vc71-stlport.mak"
  368. no_single="yes"
  369. subdir="vc71-stlport"
  370. vc6_stlp_gen
  371. #
  372. # remove tmep files;
  373. rm -f $tout $iout