OS/2, eCS & ArcaOS - Technical > Programming

Passing env vars to an nmake process


Andreas Schnellbacher:
I'm using IBM nmake. During processing of the main makefile, I would like to import values set by an external .cmd, let's name it queryvar.cmd. These vars should be used in pathnames to call e.g. an OS/2 copy command.

--- Code: ---ALL:
#  queryvar.cmd should set DIR1
   copy $(DIR1)\sub1\file.1 G:\

--- End code ---

How can a value be passed from queryvar.cmd to the running nmake, so that it can be used as $(DIR1) in the example above?

It works well when setting env vars before calling nmake. But in this case nmake is already started. It won't matter for me if queryvar.cmd really sets env vars or just returns the value of one env var only.

Andreas Schnellbacher:
Found a solution with a temporary file:

queryvar.cmd was changed to write DIR1=Value to STDOUT. Then I call

--- Code: ---queryvar.cmd > tmpfile

--- End code ---

tmpfile is then included within a pseudo target.

Because !include is expanded by the preprocessor, tmpfile must exist when the preprocessor runs the !include line. That is achieved by using

--- Code: ---!if [queryvar.cmd > tmpfile]

--- End code ---

All together:

--- Code: ---ALL:
!ifndef DIR1
! if [queryvar.cmd > tmpfile]
! endif
! include tmpfile
   @echo DIR1 is defined after including tmpfile as: $(DIR1)

--- End code ---

(It's heavily simplified compared to my original, hopefully I didn't break it.)

Any more ideas?

Andi B.:
I'm sure I stumbled over the same problem a few times in the last > 20 years. Sorry I've no solution offhand. But please keep posting your results.

Guess you checked the wpstoolkit, xworkplace, xwlan ... makefiles before.

Andreas Schnellbacher:
Thanks. Yes, these nmake projects (by Christian and Ulrich) are usually my source. All specials of xwlan are included in nepmd, too. This is (after much reading and trying) my first notable change of a makefile.

I've added changeset 4764 to implement the temp. file technique. Related are changesets 4757 and 4758.


[0] Message Index

Go to full version