Script call from make???

Script call from make???

Post by Gerald Wa » Thu, 04 May 1995 04:00:00


I'm trying to call a shell script with make.  It's turning out
to be a nightmare.  Here's the first thing I did....

TARGET_DIR:sh=if [ "$(EXPL_TARGET_DIR)" -eq "Y"  ]; \
then \
    echo "../$(BASE_TARGET_DIR).$(TARGET_OS)"; \
else \
    echo "../../bin.$(TARGET_OS)"; \

I can't get any combination of the test command to work correctly.
It never matches anything.  I assume test may be trying to match
the literal string on the left.

Someone suggested I use a script.  Ok...

Makefile stays the same

#just testing...
echo evalTargetDir: Parm=$1, > /dev/console

if [ "$1" -eq "Y"  ];
    echo "../$(BASE_TARGET_DIR).$(TARGET_OS)"
    echo "../../bin.$(TARGET_OS)"

It calls the script, but no parameter is passed.  

I'm stumped.  Does anyone have any ideas?  The verbage on
shell routines from Make is scarce in both man and O'Reilly.




1. Making sure script executes (called from c program)

/ I'm using the system() call to fire off some shell scripts in an automated
/ process (Under Solaris 2.6 and gcc).  How can I tell if the process fired off
/ or if there were errors (e.g. the script called doesn't exist in the
/ directory?).  I've looked at the exec***() series of function calls as well,
/ but the man pages are cryptic.

system() should return a nonzero value of the call failed, zero if the
command completed okay. You'll have to delve into the details of system()
and wait() to understand the return value.

/ [sounds vaguely like fork()ing in my mind].

The overall design is

    create pipes as needed to replace stdin, stdout, stderr, and/or others
            close stdin, ... as needed
            dup pipes to stdin, ...
            close original of dup files
            close the parent side of the pipes
            do anything else you need with the environment
            exec the new program
            close the child side of the pipes
            optionally fdopen pipes into FILE*
            read and/or write the pipes
            wait for the child to complete

/ Am I totally wrong in trying to use either of these two functions to
call shell
/ scripts and being able to expect to find out what happened?  If so, what's the

system() and popen() can do most of whatever people want to do. They can't
do everything.

/ proper Unix (or even the proper Solaris) way to do this?
/ I know if you have an error log file going, the error will be picked up off
/ stderr(), but I need to be able to echo tell the [non-unix inclined] user
/ immediately.
/ "To Err is human,
/        to sort of foul things up you need a computer,
/             to really ruin your day use a Microsoft product"

CACS: Collective Against Consensual Sanity       v0.123
Now a text site map!
There is no sanctuary.   I am an Andrea Chen plush toy.

2. supported tv tuners?

3. Making library calls from a scripting language


5. Looking for site with pre-made scripts like a script that reports on disk space.

6. VESA graphics / assembly ...

7. Korn shell debug: scripts call scripts ...

8. Accessing a MySQL database in C(++)

9. Q: How can I have a shell script call another shell script...

10. Calling a script within a script

11. Question: Use a Perl Script to Make a Call to a Bourne Shell Script?

12. how to call csh scripts from inside other csh scripts

13. AIX 432 - ksh -x option when script calls another script