Passing variable to child instance of make


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing variable to child instance of make
# 1  
Old 06-07-2011
Passing variable to child instance of make

hi,
I am trying to export a variable from the parent makefile to a child instance of my makefile within the same directory.

the relevant code in my parent makefile is:
Code:
libvar := $(notdir $(basename ../src/file1))
export libvar

.PHONY: library

library:
make -f makechild libvar=file1

in the child makefile, i.e. makechild, I have the following relevant code:
LVAR: =
fname := $(addprefix lib, $(LVAR))

but obviously I am missing something because echo $(fname) returns 'lib' (instead of libfile1)when I run the make command in the parent makefile.Smilie

can you pls. help me fix the code so I can export the value of libvar into LVAR

---------- Post updated at 11:10 PM ---------- Previous update was at 09:52 PM ----------

I just figured out I was making a dumb error,
I should keep the variable names the same in both the parent and child makefile.
so, in my child makefile, I renamed LVAR to libvar and it worked.
.....just in case anyone might be interested.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing key column from parent to child records

Hi Forum. I have this challenging issue that I'm hoping someone can help me. I have a file that contains 3 different types of segments (AM00, AM01, AM32) in a hierarchy structure and I want to be able to pass the column key from the parent record to the children records. AM00 - parent key:... (13 Replies)
Discussion started by: pchang
13 Replies

2. Shell Programming and Scripting

How make parent to wait from child process?

Hi all, I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens. could anyone please tell me how to make parent to wait in child process in shell script? thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies

3. IP Networking

Message passing from child to parent using pipes

Hi, I am trying my hand in networking programming in C, and got stuck in piping. I was following some tutorial and did the forking like : while (1) { newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) ... (4 Replies)
Discussion started by: abhi1988sri
4 Replies

4. Programming

how can i make that a process child send a signal?

I'm trying to do a program that makes activate an signal (SINGALARM) when the next child of a son appears but this not works. I have to caught the next child o the other (pid), to send a singnal which inform a menssage. It's anything worng in the code? thanks. the code: #include... (2 Replies)
Discussion started by: marmaster
2 Replies

5. Programming

Passing an instance of struct to functions in other src files

I am trying to work out the best syntax for a relatively simple operation. The goal is to declare an instance of a struct and pass it around to be populated and have the data manipulated. There is an extra wrinkle in that the functions are in different src files. The main is simple, #include... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

6. Programming

Pass parameter from a child make to a parent

Hello, I have the following problem: I have makefileproj and makefilemod in a build process for a complex project - from makefileproj I call the makefilemod. In makefilemod I generate a list containing objects eg,: "../../../25_Build/Results/Objects/FBL/Fls.o... (4 Replies)
Discussion started by: marina_lmv
4 Replies

7. Shell Programming and Scripting

Make cron wait for the child process

I am trying to find a list of files and writing it to a text file. Based on the machine performance the file writing will be slow at certain time. The code to find file and redirecting the output to text file is on a shell script /usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a... (4 Replies)
Discussion started by: nuthalapati
4 Replies

8. Shell Programming and Scripting

[PHP] endless loop mimics a cron. Make sure only one instance is running

Hi, PHP user here. I'm using an endless loop to perform to mimic a cron. The script does something every 20 minutes. It sleep()s in the meantime. I have various checks that ensure that only instance can run, including a "gentleman agreement" locked file. However, I'd like to make sure... (2 Replies)
Discussion started by: jjshell
2 Replies

9. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

10. Shell Programming and Scripting

Passing a variable from a child script back to the parent

Hi I have written a script using ftp to get files from one server and copy them to 2 dirrerent servers. I wish to call this script from a parent script that will check the number of files copied and run a check sum for each file. As the filenames for the files in the get portion of the script... (3 Replies)
Discussion started by: Andy82
3 Replies
Login or Register to Ask a Question
fork(2) 							System Calls Manual							   fork(2)

Name
       fork - create a new process

Syntax
       #include <sys/types.h>
       #include <unistd.h>

       pid = fork()
       pid_t pid;

Description
       The  system  call causes creation of a new process.  The new process (child process) is an exact copy of the calling process except for the
       following:

       o    The child process has a unique process ID.

       o    The child process has a different parent process ID (that is, the process ID of the parent process).

       o    The child process has its own copy of the parent's descriptors.  These descriptors reference the same underlying objects, so that, for
	    instance,  file  pointers  in file objects are shared between the child and the parent, so that a on a descriptor in the child process
	    can affect a subsequent read or write by the parent.  This descriptor copying is also used by the shell to	establish  standard  input
	    and output for newly created processes as well as to set up pipes.

       o    The child processes resource utilizations are set to 0.  For further information, see

Return Values
       Upon  successful  completion,  returns  a  value  of  0	to the child process and returns the process ID of the child process to the parent
       process.  Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set	to
       indicate the error.

Diagnostics
       The system call fails and no child process are created under the following conditions:

       [EAGAIN]       The system-imposed limit {PROC_MAX} on the total number of processes under execution would be exceeded.

       [EAGAIN]       The system-imposed limit {CHILD_MAX} on the total number of processes under execution by a single user would be exceeded.

       [ENOMEM]       There is insufficient swap space for the new process.

See Also
       execve(2), wait(2)

																	   fork(2)