0

我正在使用 XP 命令行。

我有一个makefile 和一个运行makefile 的.bat。我还有一个我想在 makefile 中使用的环境变量。我找到了一些文档,但我很难看到如何在我的情况下使用它。我认为这很容易,但我只是错过了一些东西。

就我而言,我想让以下内容更通用。我想在makefile 外部指定borlandc(即BorlandDir)文件夹的位置。

我输入“mk”来运行make。

这是我的情况:

MK.BAT
------
echo off
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
echo The OS must be XP to run Borland C
PAUSE
goto:eof

:ver_XP
if '%BorlandDir%' == '' call setpath
%BorlandDir%\bin\make -s >this2
rem echo if you get "Bad command or file name" or it does not create emul.exe, run 'setpath'
echo if you get "Unable to execute command 'tlink.exe'", copy borlandc\bin\tlink.exe here
echo To make this debuggable, add -v
echo e.g., bcc -M -v -l3 -I%BorlandDir%\include -L%BorlandDir%\lib 1830.obj emul.obj iostuff.obj panel.obj
rem make -s
find /i /v "borland" <this2 >this1
find /i /v "available memory" <this1 >this
more <this
del ..\1830.exe 2> nul
move 1830.exe ..

SETPATH.BAT
-----------
set BorlandDir=..\borlandc
path=%path%;%BorlandDir%\bin

MAKEFILE
--------
COMPILE=bcc -a -3 -Od -v -c -ms -Oi -Iborlandc\include
ASSEMBLE=borlandc\bin\tasm -zi -ml -t -la

1830.exe: 1830.obj emul.obj iostuff.obj panel.obj
 echo link 1830.exe
 bcc -M -v -l3 -Lborlandc\lib 1830.obj emul.obj iostuff.obj panel.obj

1830.obj:       1830.c          \
                panel.h         \
                iostuff.h
 $(COMPILE) 1830.c

iostuff.obj:    iostuff.c       \
                panel.h         \
                api.h           \
                iostuff.h
 $(COMPILE) iostuff.c

panel.obj:      panel.c         \
                panel.h         \
                iostuff.h
 $(COMPILE) panel.c

emul.obj: emul.asm
 echo emul.asm:
 $(ASSEMBLE) emul.asm
4

0 回答 0