Problem with Make

Problem with Make

Post by Arvind Kum » Thu, 06 Nov 2003 18:04:26



Hi,
   I am facing a problem in Makefile. I will try to explain it here.

#Makefile fragment

target1:
    TIME_STAMP = `date +%d_%b_%H:%M`
    NEW_DIR = ${LABEL}_${TIME_STAMP}
    run_job.pl
target2:
    extract_results

target3:
    analyze_results

#End of fragment

In my makefile, for one target, I create a new directory structure for
this particular run in target1. I also need to pass this this new
directory name to another TCL script (For which I want to use awk to
edit this TCL script). Then Perl script runs the job.
   Now, for next target, I need to analyze the results for the last
run. which implies that i need to save the directory name. The problem
I am facing is that..Since Makefile executes the commands in target in
new shell, storing the directory name in the variable is not visible
in the next target. Even, seting a environment variable does not help
because it does not set the environment variable in the parent shell.
<1> Is there anyway to set the environment variable in parent shell
from the Makefile?
<2> If I do not define the NEW_DIR in the target, Everytime, for all
targets NEW_DIR will get new value (because of the date command).

I'll really appreciate any help from you experts in this group.

Thanks in advance,
Arvind Kumar,
Sr. Design Engineer,
Sasken Communication Technologies, Ltd.
139/25 Amar Jyothi Layout,
Bangalore, India

 
 
 

Problem with Make

Post by Eric Moor » Thu, 06 Nov 2003 19:03:51


Quote:>    Now, for next target, I need to analyze the results for the last
> run. which implies that i need to save the directory name. The problem I
> am facing is that..Since Makefile executes the commands in target in new

You do not need to save the name. Just retrieve it. The directory still
exists, right? And it is the last one created? So `ls -tr | tail -1`
turns up the name again. Maybe you need an extra test to list only
directories. I leave that up to you.

Eric

 
 
 

Problem with Make

Post by wave+ » Wed, 19 Nov 2003 09:44:12



Quote:> Hi,
>    I am facing a problem in Makefile. I will try to explain it here.

> #Makefile fragment

> target1:
>     TIME_STAMP = `date +%d_%b_%H:%M`
>     NEW_DIR = ${LABEL}_${TIME_STAMP}
>     run_job.pl
> target2:
>     extract_results

> target3:
>     analyze_results

> #End of fragment

Isn't strictly shell related, but I see more than one issue here.
make executes each line in a 'separated' shell, so setting variables is
a bit useless that way.

Quote:>    Now, for next target, I need to analyze the results for the last
> run. which implies that i need to save the directory name. The problem
> I am facing is that..Since Makefile executes the commands in target in
> new shell, storing the directory name in the variable is not visible
> in the next target. Even, seting a environment variable does not help
> because it does not set the environment variable in the parent shell.

><1> Is there anyway to set the environment variable in parent shell
> from the Makefile?

Absolutely not.

Quote:><2> If I do not define the NEW_DIR in the target, Everytime, for all
> targets NEW_DIR will get new value (because of the date command).

Don't use SHELL variables, use make's. Here's your makefile rearranged:

# Makefile
TIME_STAMP != date +%d_%b_%H:%M
LABEL := hello
NEW_DIR := $(LABEL)_$(TIME_STAMP)
RUN_IT = TIME_STAMP=$(TIME_STAMP) NEW_DIR=$(NEW_DIR)

target1:
    $(RUN_IT) run_job.pl
target2:
    $(RUN_IT) run_job.pl
target3:
    $(RUN_IT) analyze_results
# End

This way the NEW_DIR and TIME_STAMP variables will be correctly exported
to $(your_command) and will be consistent within the same execution of make.

Anyway, if you interrupt make during the execution and re-execute it,
your filenames will change due to "date", so you may need to save this
data anyway.

--
wave++ (also known, in some places, as "Yuri D'Elia") http://www.yuv.info/
The email address is fake (thanks swen)! You know how to contact me anyway.

 
 
 

1. problem with making xpm

Dear all,

I am current with some games in linux with gtk+, I would like to add graphic
into my program, i have found that it is only supported xpm graphic format.
Am i right? Where can i download some software in order to make xpm graphic
format?

Thanks all.

2. Linux Admin

3. SLIP problem is making me sleep --- PLEEEAAAAAASE help

4. SMP woes

5. lilo problems in making bootable cd

6. Problem after upgrading kernel

7. Problems with making a PPP connection

8. Gnome/KDE/X question

9. byteorder.h problem in making tripwire1.2 on solaris 2.6

10. Problem in making X11R6

11. problems compiling/making NCSA httpd

12. lilo problems in making bootable cd

13. problem in making kernel v2.0.33