0

I'm using XP command line.

I have a makefile and a .bat that runs the makefile. I also have an environment variable that I would like to use within the makefile. I have found some documentation but I am having a hard time seeing how to use it in my case. I think it is easy but I'm just missing something.

In my case I want to make the below more general. I want to specify the location of the borlandc (i.e. BorlandDir) folder externally to the makefile.

I type "mk" to run the make.

Here is my case:

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
eddyq
  • 879
  • 1
  • 13
  • 25
  • Environment variables can be referenced like any other variable, have you tried using `$(BorlandDir)` in the makefile? – user657267 Aug 11 '16 at 01:08
  • The is one of the things I already tried. But it didn't work. Here is how it turned out: --- from the set command: BORLANDDIR=..\borlandc --- The makefile: bcc -M -v -l3 -L$(BorlandDir)\lib 1830.obj emul.obj iostuff.obj panel.obj --- The makefile output: bcc -a -3 -Od -v -c -ms -Oi -I\include 1830.c – eddyq Aug 11 '16 at 15:53
  • That looks like the content of your `COMPILE` variable, did you update that as well? – user657267 Aug 11 '16 at 22:14
  • Hmm, I used a find and replace but maybe I made a mistake there. I'll check. – eddyq Aug 12 '16 at 17:06
  • @user3389362 post a smallest amount of code that reproduces your problem - why do you want us to work to isolate your problem - you should do it, in many cases, you will then find the answer yourself, if not, post the minimal failure case here – Mark Galeck Aug 15 '16 at 18:59

0 Answers0