1@echo off
2if "%1" == "/h" goto help
3if "%1" == "/?" goto help
4if "%1" == "-h" goto help
5set verbose=no
6set debug=no
7set ushell=ksh
8:parse
9if "%1" == "/v" goto verbose
10if "%1" == "-v" goto verbose
11if "%1" == "/d" goto gdebug
12if "%1" == "-d" goto gdebug
13if "%1" == "sh" goto usersh
14if exist os2 goto start
15echo You are in the wrong directory.  Change to source directory.
16echo Copy this file and run again or type os2\configure.
17goto end
18:verbose
19set verbose=yes
20shift
21goto parse
22:gdebug
23set debug=yes
24shift
25goto parse
26:usersh
27if %verbose% == yes echo Configuring for Bourne shell.
28set ushell=sh
29:start
30if exist conftest.c erase conftest.c
31if exist confdefs.h erase confdefs.h
32if %verbose% == yes echo Searching for sed
33:::::for %%i in (%path%) do if exist %%i\sed.exe goto s_success
34sed --version && goto s_success
35echo No sed in search path.  Copying Makefile for gcc. You will need
36echo to edit it if you are not using standard defaults.
37copy os2\Makefile Makefile
38goto copystuff
39:help
40echo Run os2\configure to set up for os/2 compilation.
41echo You must have current context in the source directory.
42echo usage: configure [[/v^|-v][/d^|-d]^|/h^|-h^|/?] [sh]
43echo        where /v means verbose output
44echo              /d means compile with symbols (debug)
45goto end
46:s_success
47if %verbose% == yes echo checking for compiler
48for %%i in (%path%) do if exist %%i\gcc.exe goto g_success
49gcc --version && goto g_success
50rem for the future we'll use sed processing
51for %%i in (%path%) do if exist %%i\bcc.exe goto b_success
52for %%i in (%path%) do if exist %%i\icc.exe goto i_success
53echo Compiler not found. Check your path
54goto end
55:b_success
56echo Borland C compiler found.  Configuration not complete for
57echo this compiler.  You may need to edit the Makefile
58set CC=bcc
59set CPP=cpp
60goto createstuff
61:i_success
62echo IBM C compiler found.  Configuration not complete for
63echo this compiler.  You may need to edit the Makefile.
64set CC=icc -q -Sm -Gm -Gt -Spl -D__STDC__
65set CPP=cpp
66goto createstuff
67:checkshell
68if %ushell% == sh goto fixshell
69goto copystuff
70:g_success
71echo GNU C compiler found.  This is the standard configuration.
72copy os2\Makefile Makefile
73if %debug% == no goto checkshell
74set CC=gcc -g
75set CPP=cpp
76:createstuff
77echo Creating files for you.
78echo s/@CC@/%CC%/> os2\make.tmp
79echo s/@CPP@/%CPP%/>> os2\make.tmp
80echo s/@LDFLAGS@/-O/>> os2\make.tmp
81if %ushell% == ksh goto skipsh
82:fixshell
83echo s!/bin/sh!ksh!>> os2\make.tmp
84echo s/@SHELL_PROG@/sh/>> os2\make.tmp
85:skipsh
86copy os2\make.tmp+os2\make.sed os2\make.tmp
87sed -f os2\make.tmp Makefile.in >  Makefile
88del os2\make.tmp
89:copystuff
90if %verbose% == yes echo Copying config.h and config.status files.
91copy os2\config.h config.h
92touch config.h
93copy os2\config.status config.status
94if %verbose% == yes echo Checking for os2.c and th.cmd.
95if not exist os2.c copy os2\os2.c os2.c
96if not exist th.cmd copy os2\th.cmd th.cmd
97if %ushell% == ksh goto end
98if %verbose% == yes echo Fixing config.h for building sh.
99echo #ifdef KSH>> config.h
100echo #undef KSH>> config.h
101echo #undef VI>> config.h
102echo #undef EMACS>> config.h
103echo #undef EDIT>> config.h
104echo #undef COMPLEX_HISTORY>> config.h
105echo #undef EASY_HISTORY>> config.h
106echo #undef HISTORY>> config.h
107echo #undef BRACE_EXPAND>>config.h
108echo #endif>> config.h
109:end
110
111
112