1@ECHO OFF
2REM **************************************************************************
3REM *
4REM * configure.bat for setting up compiling STLport under Windows
5REM * to see available options, call with option --help
6REM *
7REM * Copyright (C) 2004,2005 Michael Fink
8REM *
9REM **************************************************************************
10
11REM Attention! Batch file labels only have 8 significant characters!
12
13echo STLport Configuration Tool for Windows
14echo.
15
16REM no options at all?
17if NOT "%1xyz123" == "xyz123" goto init
18
19echo Please specify at least the compiler you are going to use,
20echo use "configure --help" to see the available ones.
21goto skp_comp
22
23:init
24
25REM initially create/overwrite config.mak
26echo # STLport Configuration Tool for Windows > build\Makefiles\nmake\config.mak
27echo # >> build\Makefiles\nmake\config.mak
28echo # config.mak generated with command line: >> build\Makefiles\nmake\config.mak
29echo # configure %1 %2 %3 %4 %5 %6 %7 %8 %9 >> build\Makefiles\nmake\config.mak
30echo # >> build\Makefiles\nmake\config.mak
31
32REM First parameter can only be help or compiler
33REM help option
34if "%1" == "-?" goto opt_help
35if "%1" == "-h" goto opt_help
36if "%1" == "/?" goto opt_help
37if "%1" == "/h" goto opt_help
38if "%1" == "--help" goto opt_help
39
40REM This is necessarily a compiler
41goto opt_comp
42
43REM
44REM option loop
45REM
46:loop
47
48REM platform option
49if "%1" == "-p" goto opt_plat
50if "%1" == "/p" goto opt_plat
51if "%1" == "--platform" goto opt_plat
52
53REM cross compiling
54if "%1" == "-x" goto opt_x
55if "%1" == "/x" goto opt_x
56if "%1" == "--cross" goto opt_x
57
58REM C runtime library
59if "%1" == "--with-static-rtl" goto opt_srtl
60if "%1" == "--with-dynamic-rtl" goto opt_drtl
61if "%1" == "--rtl-static" goto opt_srtl
62if "%1" == "--rtl-dynamic" goto opt_drtl
63
64REM boost support
65if "%1" == "--use-boost" goto opt_bst
66
67REM multithreading support
68if "%1" == "--not-thread-safe" goto opt_st
69if "%1" == "--without-thread" goto opt_st
70
71REM rtti support
72if "%1" == "--no-rtti" goto opt_rtti
73if "%1" == "--without-rtti" goto opt_rtti
74
75REM additional compiler options
76if "%1" == "--extra-cxxflag" goto opt_xtra
77
78REM library name customization
79if "%1" == "--lib-motif" goto opt_motf
80if "%1" == "--with-lib-motif" goto opt_motf
81
82REM build without STLport
83if "%1" == "--without-stlport" goto no_sport
84
85REM clean rule
86if "%1" == "--clean" goto opt_cln
87
88echo Unknown option: %1
89
90:cont_lp
91echo.
92shift
93
94REM no more options?
95if "%1xyz123" == "xyz123" goto end_loop
96
97goto loop
98
99
100REM **************************************************************************
101REM *
102REM * Help
103REM *
104REM **************************************************************************
105:opt_help
106echo The first parameter must be the compiler name, here are the available
107echo keywords:
108echo.
109echo    msvc6    Microsoft Visual C++ 6.0
110echo    msvc7    Microsoft Visual C++ .NET 2002
111echo    msvc71   Microsoft Visual C++ .NET 2003
112echo    msvc8    Microsoft Visual C++ 2005
113echo    msvc9    Microsoft Visual C++ 2008
114echo    icl      Intel C++ Compiler
115echo    evc3     Microsoft eMbedded Visual C++ 3 (*)
116echo    evc4     Microsoft eMbedded Visual C++ .NET (*)
117echo    evc8     Microsoft Visual C++ 2005 compiling for CE
118echo    evc9     Microsoft Visual C++ 2008 compiling for CE
119echo.
120echo  (*) For these compilers the target processor is determined automatically.
121echo      You must run the WCE*.BAT file you wish to build STLport for before
122echo      running configure.
123echo.
124echo Then the following options are available:
125echo.
126echo "-p <platform>" or "--platform <platform>"
127echo    Build STLport for the specified platform. Not all existing platforms are
128echo    available, only the ones that make a difference when building STLport are.
129echo    The following keywords are available:
130echo    win95    Windows 95 compatible
131echo    win98    Windows 98 and up to Windows XP excluded
132echo    winxp    Windows XP or later (default)
133echo.
134echo "-x"
135echo    Enables cross-compiling; the result is that all built files that are
136echo    normally put under "bin" and "lib" get extra subfolders depending on
137echo    the compiler name.
138echo.
139echo "--with-static-rtl"
140echo "--with-dynamic-rtl"
141echo    Enables usage of static (libc.lib family) or dynamic (msvcrt.lib family)
142echo    C/C++ runtime library when linking with STLport. If you want your appli/dll
143echo    to link statically with STLport but using the dynamic C runtime use
144echo    --with-dynamic-rtl; if you want to link dynamicaly with STLport but using the
145echo    static C runtime use --with-static-rtl. See README.options for details.
146echo    Don't forget to signal the link method when building your appli or dll, in
147echo    stlport/stl/config/host.h set the following macro depending on the configure
148echo    option:
149echo    "--with-static-rtl  -> _STLP_USE_DYNAMIC_LIB"
150echo    "--with-dynamic-rtl -> _STLP_USE_STATIC_LIB"
151echo.
152echo "--use-boost <boost install path>"
153echo    Request use of boost support (www.boost.org). For the moment only the boost
154echo    type_traits library is used to get type information and to implement some
155echo    specific workaround not directly implemented by STLport. To use the same
156echo    support when using STLport for your application don't forget to define
157echo    _STLP_USE_BOOST_SUPPORT in stlport/stl/config/user_config.h file.
158echo.
159echo "--without-thread"
160echo    Per default STLport libraries are built in order to be usable in a multithreaded
161echo    context. If you don't need this you can ask for a not thread safe version with
162echo    this option.
163echo.
164echo "--without-rtti"
165echo    Remove rtti (run time type information) support if available.
166echo.
167echo "--extra-cxxflag <additional compilation options>"
168echo    Use this option to add any compilation flag to the build system. For instance
169echo    it can be used to activate a specific processor optimization depending on your
170echo    processor. For Visual C++ .Net 2003, to activate pentium 3 optim you will use:
171echo    --extra-cxxflag /G7
172echo    If you have several options use several --extra-cxxflag options. For instance
173echo    to also force use of wchar_t as an intrinsic type:
174echo    --extra-cxxflag /G7 --extra-cxxflag /Zc:wchar_t
175echo.
176echo "--with-lib-motif <motif>"
177echo   Use this option to customize the generated library name. The motif will be used
178echo   in the last place before version information, separated by an underscore, ex:
179echo   stlportd_MOTIF.5.0.lib
180echo   stlportstld_static_MOTIF.5.1.lib
181echo   Do not forget to define _STLP_LIB_NAME_MOTIF macro in STLport configuration file
182echo   to the same value if you want to keep the auto link feature supported by some
183echo   compilers.
184echo.
185echo "--without-stlport"
186echo   Option specially targetting build of the unit tests project without STLport. This
187echo   is a good way to challenge the C++ Standard library implementation comming with
188echo   your compiler with STLport.
189echo.
190echo "--clean"
191echo    Removes the build configuration file.
192goto skp_comp
193
194REM **************************************************************************
195REM *
196REM * Compiler configuration
197REM *
198REM **************************************************************************
199:opt_comp
200
201if "%1" == "msvc6" goto oc_msvc6
202if "%1" == "msvc71" goto oc_msv71
203if "%1" == "msvc7" goto oc_msvc7
204if "%1" == "msvc8" goto oc_msvc8
205if "%1" == "msvc9" goto oc_msvc9
206if "%1" == "icl"   goto oc_icl
207
208if "%1" == "evc3" goto oc_evc3
209if "%1" == "evc4" goto oc_evc4
210if "%1" == "evc8" goto oc_evc8
211if "%1" == "evc9" goto oc_evc9
212
213if "%1" == "watcom" goto oc_wtm
214
215echo Unknown compiler: %1
216goto oc_end
217
218:oc_msvc6
219:oc_wtm
220echo Setting compiler: Microsoft Visual C++ 6.0
221echo COMPILER_NAME=vc6 >> build\Makefiles\nmake\config.mak
222set SELECTED_COMPILER_VERSION=60
223goto oc_msvc
224
225:oc_msvc7
226echo Setting compiler: Microsoft Visual C++ .NET 2002
227echo COMPILER_NAME=vc70 >> build\Makefiles\nmake\config.mak
228set SELECTED_COMPILER_VERSION=70
229goto oc_msvc
230
231:oc_msv71
232echo Setting compiler: Microsoft Visual C++ .NET 2003
233echo COMPILER_NAME=vc71 >> build\Makefiles\nmake\config.mak
234set SELECTED_COMPILER_VERSION=71
235goto oc_msvc
236
237:oc_msvc8
238echo Setting compiler: Microsoft Visual C++ 2005
239echo COMPILER_NAME=vc8 >> build\Makefiles\nmake\config.mak
240set SELECTED_COMPILER_VERSION=80
241goto oc_msvc
242
243:oc_msvc9
244echo Setting compiler: Microsoft Visual C++ 2008
245echo COMPILER_NAME=vc9 >> build\Makefiles\nmake\config.mak
246set SELECTED_COMPILER_VERSION=90
247goto oc_msvc
248
249:oc_msvc
250echo TARGET_OS=x86 >> build\Makefiles\nmake\config.mak
251set SELECTED_COMPILER=msvc
252echo !include msvc.mak > .\build\lib\Makefile
253echo !include msvc.mak > .\build\test\unit\Makefile
254echo !include msvc.mak > .\build\test\eh\Makefile
255goto oc_end
256
257:oc_icl
258echo Setting compiler: Intel C++ Compiler
259echo COMPILER_NAME=icl >> build\Makefiles\nmake\config.mak
260echo TARGET_OS=x86 >> build\Makefiles\nmake\config.mak
261set SELECTED_COMPILER=icl
262echo !include icl.mak > .\build\lib\Makefile
263echo !include icl.mak > .\build\test\unit\Makefile
264echo !include icl.mak > .\build\test\eh\Makefile
265goto oc_end
266
267:oc_evc3
268echo Setting compiler: Microsoft eMbedded Visual C++ 3
269echo COMPILER_NAME=evc3 >> build\Makefiles\nmake\config.mak
270rem TODO: branch on OSVERSION like below?
271echo CEVERSION=300 >> build\Makefiles\nmake\config.mak
272set SELECTED_COMPILER_VERSION=3
273goto oc_evc
274
275:oc_evc4
276echo Setting compiler: Microsoft eMbedded Visual C++ .NET
277echo COMPILER_NAME=evc4 >> build\Makefiles\nmake\config.mak
278if "%OSVERSION%"=="" (
279    echo OSVERSION not set, assuming target is CE 4.2
280    echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
281) else if "%OSVERSION%"=="WCE400" (
282    echo CEVERSION=400 >> build\Makefiles\nmake\config.mak
283) else if "%OSVERSION%"=="WCE420" (
284    echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
285) else if "%OSVERSION%"=="WCE500" (
286    echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
287) else (
288    echo Unknown value for OSVERSION.
289    exit /b 1
290)
291set SELECTED_COMPILER_VERSION=4
292goto oc_evc
293
294:oc_evc8
295echo Setting compiler: Microsoft Visual C++ .NET 2005 for Windows CE
296echo COMPILER_NAME=evc8 >> build\Makefiles\nmake\config.mak
297set SELECTED_COMPILER_VERSION=80
298if "%OSVERSION%"=="" (
299    echo OSVERSION not set, assuming target is CE 5.0
300    echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
301) else if "%OSVERSION%"=="WCE400" (
302    echo CEVERSION=400 >> build\Makefiles\nmake\config.mak
303) else if "%OSVERSION%"=="WCE420" (
304    echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
305) else if "%OSVERSION%"=="WCE500" (
306    echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
307) else (
308    echo Unknown value for OSVERSION.
309    exit /b 1
310)
311set PLATFORM_SPECIFIED=1
312set SELECTED_COMPILER=msvc
313echo !include evc.mak > .\build\lib\Makefile
314echo !include evc.mak > .\build\test\unit\Makefile
315echo !include evc.mak > .\build\test\eh\Makefile
316goto proc
317
318:oc_evc9
319echo Setting compiler: Microsoft Visual C++ .NET 2008 for Windows CE
320echo COMPILER_NAME=evc9 >> build\Makefiles\nmake\config.mak
321set SELECTED_COMPILER_VERSION=90
322if "%OSVERSION%"=="" (
323    echo OSVERSION not set, assuming target is CE 5.0
324    echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
325) else if "%OSVERSION%"=="WCE400" (
326    echo CEVERSION=400 >> build\Makefiles\nmake\config.mak
327) else if "%OSVERSION%"=="WCE420" (
328    echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
329) else if "%OSVERSION%"=="WCE500" (
330    echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
331) else (
332    echo Unknown value for OSVERSION.
333    exit /b 1
334)
335set PLATFORM_SPECIFIED=1
336set SELECTED_COMPILER=msvc
337echo !include evc.mak > .\build\lib\Makefile
338echo !include evc.mak > .\build\test\unit\Makefile
339echo !include evc.mak > .\build\test\eh\Makefile
340goto proc
341
342:oc_evc
343set PLATFORM_SPECIFIED=1
344set SELECTED_COMPILER=evc
345echo !include evc.mak > .\build\lib\Makefile
346echo !include evc.mak > .\build\test\unit\Makefile
347echo !include evc.mak > .\build\test\eh\Makefile
348goto proc
349
350:oc_end
351goto cont_lp
352
353
354REM **************************************************************************
355REM *
356REM * Target processor configuration (automatic)
357REM *
358REM **************************************************************************
359:proc
360
361if "%TARGETCPU%" == "ARM" goto pr_arm
362if "%TARGETCPU%" == "ARMV4" goto pr_arm
363if "%TARGETCPU%" == "ARMV4I" goto pr_arm
364if "%TARGETCPU%" == "ARMV4T" goto pr_arm
365
366if "%TARGETCPU%" == "X86" goto pr_x86
367REM Type from evc3 and/or PocketPC 2002 SDK reported here
368REM to correctly check the platform:
369if "%TARGETCPU%" == "X86EMnset CFG=none" goto pr_emul
370if "%TARGETCPU%" == "x86" goto pr_x86
371if "%TARGETCPU%" == "emulator" goto pr_emul
372
373if "%TARGETCPU%" == "R4100" goto pr_mips
374if "%TARGETCPU%" == "R4111" goto pr_mips
375if "%TARGETCPU%" == "R4300" goto pr_mips
376if "%TARGETCPU%" == "MIPS16" goto pr_mips
377if "%TARGETCPU%" == "MIPSII" goto pr_mips
378if "%TARGETCPU%" == "MIPSII_FP" goto pr_mips
379if "%TARGETCPU%" == "MIPSIV" goto pr_mips
380if "%TARGETCPU%" == "MIPSIV_FP" goto pr_mips
381
382if "%TARGETCPU%" == "SH3" goto pr_sh3
383if "%TARGETCPU%" == "SH4" goto pr_sh4
384
385:pr_err
386echo Unknown target CPU: %TARGETCPU%
387goto pr_end
388
389:pr_arm
390echo Target processor: ARM
391echo TARGET_PROC=arm >> build\Makefiles\nmake\config.mak
392echo TARGET_PROC_SUBTYPE=%TARGETCPU% >> build\Makefiles\nmake\config.mak
393goto pr_end
394
395:pr_x86
396echo Target processor: x86
397echo TARGET_PROC=x86 >> build\Makefiles\nmake\config.mak
398goto pr_end
399
400:pr_emul
401echo Target processor: Emulator
402echo TARGET_PROC=x86 >> build\Makefiles\nmake\config.mak
403echo TARGET_PROC_SUBTYPE=emulator >> build\Makefiles\nmake\config.mak
404goto pr_end
405
406:pr_mips
407echo Target processor: MIPS
408echo TARGET_PROC=mips >> build\Makefiles\nmake\config.mak
409echo TARGET_PROC_SUBTYPE=%TARGETCPU% >> build\Makefiles\nmake\config.mak
410
411goto pr_end
412
413:pr_sh3
414echo Target processor: %TARGETCPU%
415echo TARGET_PROC=sh3 >> build\Makefiles\nmake\config.mak
416goto pr_end
417
418:pr_sh4
419echo Target processor: %TARGETCPU%
420echo TARGET_PROC=sh4 >> build\Makefiles\nmake\config.mak
421goto pr_end
422
423:pr_end
424goto oc_end
425
426
427REM **************************************************************************
428REM *
429REM * Platform configuration
430REM *
431REM **************************************************************************
432:opt_plat
433
434if "%2" == "win95" goto op_win95
435if "%2" == "win98" goto op_win98
436if "%2" == "winxp" goto op_winxp
437
438echo Unknown platform: %2
439goto op_end
440
441:op_win95
442echo Setting platform: Windows 95
443echo WINVER=0x0400 >> build\Makefiles\nmake\config.mak
444set PLATFORM_SPECIFIED=1
445goto op_end
446
447:op_win98
448echo Setting platform: Windows 98
449echo WINVER=0x0410 >> build\Makefiles\nmake\config.mak
450set PLATFORM_SPECIFIED=1
451goto op_end
452
453:op_winxp
454echo Setting platform: Windows XP
455echo WINVER=0x0501 >> build\Makefiles\nmake\config.mak
456set PLATFORM_SPECIFIED=1
457goto op_end
458
459:op_end
460shift
461
462goto cont_lp
463
464
465REM **************************************************************************
466REM *
467REM * Cross Compiling option
468REM *
469REM **************************************************************************
470
471:opt_x
472echo Setting up for cross compiling.
473echo CROSS_COMPILING=1 >> build\Makefiles\nmake\config.mak
474goto cont_lp
475
476
477REM **************************************************************************
478REM *
479REM * C runtime library selection
480REM *
481REM **************************************************************************
482
483:opt_srtl
484if "%SELECTED_COMPILER%" == "msvc" goto or_sok
485goto or_err
486
487:opt_drtl
488if "%SELECTED_COMPILER%" == "msvc" goto or_dok
489goto or_err
490
491:or_err
492echo Error: Setting C runtime library for compiler other than microsoft ones!
493goto or_end
494
495:or_sok
496echo Selecting static C runtime library for STLport
497echo WITH_STATIC_RTL=1 >> build\Makefiles\nmake\config.mak
498goto or_end
499
500:or_dok
501echo Selecting dynamic C runtime library for STLport
502echo WITH_DYNAMIC_RTL=1 >> build\Makefiles\nmake\config.mak
503goto or_end
504
505:or_end
506goto cont_lp
507
508REM **************************************************************************
509REM *
510REM * boost support
511REM *
512REM **************************************************************************
513:opt_bst
514REM if (Exists("%2")) goto ob_ok
515REM if !("%2" == "") goto ob_ok
516goto ob_ok
517
518echo Error: Invalid boost intallation folder ("%2").
519goto ob_end
520
521:ob_ok
522echo Activating boost support using "%2" path
523echo STLP_BUILD_BOOST_PATH="%2" >> build\Makefiles\nmake\config.mak
524
525:ob_end
526shift
527
528goto cont_lp
529
530REM **************************************************************************
531REM *
532REM * Multithreading support
533REM *
534REM **************************************************************************
535:opt_st
536echo Removing thread safety support
537echo WITHOUT_THREAD=1 >> build\Makefiles\nmake\config.mak
538goto cont_lp
539
540REM **************************************************************************
541REM *
542REM * rtti support
543REM *
544REM **************************************************************************
545:opt_rtti
546echo Removing rtti support
547echo WITHOUT_RTTI=1 >> build\Makefiles\nmake\config.mak
548goto cont_lp
549
550REM **************************************************************************
551REM *
552REM * Extra compilation flags
553REM *
554REM **************************************************************************
555:opt_xtra
556echo Adding '%2' compilation option
557if "%ONE_OPTION_ADDED%" == "1" goto ox_n
558
559echo DEFS = %2 >> build\Makefiles\nmake\config.mak
560set ONE_OPTION_ADDED=1
561goto ox_end
562
563:ox_n
564echo DEFS = $(DEFS) %2 >> build\Makefiles\nmake\config.mak
565
566:ox_end
567shift
568goto cont_lp
569
570REM **************************************************************************
571REM *
572REM * Library name configuration
573REM *
574REM **************************************************************************
575:opt_motf
576echo Using '%2' in generated library names
577
578echo LIB_MOTIF = %2 >> build\Makefiles\nmake\config.mak
579
580shift
581goto cont_lp
582
583REM **************************************************************************
584REM *
585REM * Build without STLport
586REM *
587REM **************************************************************************
588:no_sport
589echo Configured to build without STLport
590
591echo WITHOUT_STLPORT=1 >> build\Makefiles\nmake\config.mak
592
593shift
594goto cont_lp
595
596REM **************************************************************************
597REM *
598REM * Clean
599REM *
600REM **************************************************************************
601:opt_cln
602del build\Makefiles\nmake\config.mak
603echo STLport configuration file removed.
604goto skp_comp
605
606REM **************************************************************************
607REM *
608REM * End loop
609REM *
610REM **************************************************************************
611
612:end_loop
613
614if "%PLATFORM_SPECIFIED%" == "1" goto comp
615echo Setting platform: Windows XP
616echo.
617echo WINVER=0x0501 >> build\Makefiles\nmake\config.mak
618
619:comp
620echo Done configuring STLport.
621echo.
622echo Go to build/lib folder and type "nmake clean install" to build  and
623echo install STLport to the "lib" and "bin" folders.
624echo Go to build/test/unit folder and type nmake clean install to
625echo build unit tests and install them in bin folder. 
626echo.
627
628:skp_comp
629set SELECTED_COMPILER=
630set SELECTED_COMPILER_VERSION=
631set ONE_OPTION_ADDED=
632set PLATFORM_SPECIFIED=
633