makefile ---querry


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers makefile ---querry
# 1  
Old 03-13-2008
makefile ---querry

my querry is about writing makefiles:-

i have gone through some sample make file and noticed that while writing the commands for a particular target..

some times two lines are written with a backslash like

LD_LIBRARY_PATH="/usr/openwin/lib"; export LD_LIBRARY_PATH; \
TK_LIBRARY=$(TK_DIR)/lib/tk8.4; export TK_LIBRARY; \
TCL_LIBRARY=$(TCL_DIR)/lib/tcl8.4; export TCL_LIBRARY; \
PATH=$(TK_DIR)/bin:$(TCL_DIR)/bin:${PATH}; export PATH; \
CFLAGS="$(ALL_INCLUDE)"; export CFLAGS; \
LDFLAGS="$(ALL_LLIB) $(ALL_RLIB)"; export LDFLAGS && \
CC=$(HOST_CC) CXX=$(HOST_CXX) MAKE=$(GMAKE) \
$(SRC_DIR)/configure \
--prefix=$(DEST_DIR



....can please any one explain me whats the significance of using "\" and the "&&"
in the command section of the makefile....does something special happens internally when execution starts

thanks & regards
malay
# 2  
Old 03-13-2008
The \ is just a line continuation character, used to break a long line, for readability.
# 3  
Old 03-13-2008
It's not just cosmetic however. make treats each command line as if it were executed in its own shell. Thus
Code:
cd output
rm *

will not work in make as you would expect. But
Code:
cd output;rm *

will work, as both commands are on a single line, which can be split up by using a backslash, like
Code:
cd output; \
rm *

(Note that you still need the semicolon at the end of the line to be continued, as well as the backslash)
# 4  
Old 03-13-2008
As noted above, the backslash just lets you wrap a long command line.

You have to be sure that the backslash is the final character in that line -- even a single blank space will screw it up -- that set of commands will then be perceived as two separate lines.

The && operator is used to execute additional commands after other commands, but only if the earlier one(s) are successful. The || (double-pipe) operator is the opposite -- the following only executes if the first one fails.

Example:

Code:
thing1 && thing2 && thing3 && thing4

If thing1 works, then thing2 will execute. If thing2 works, thing3 will execute, and so on. But if any one of them fails, that's the end of the road.

Code:
thing1 || otherthing

In this case, thing1 will be executed. If it works, that's the end of the road. If it fails, then otherthing will be executed.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

2. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

3. Solaris

solaris native binary ...querry

In a solaris 8 machine the native binaries are mainly kept under /bin and /usr/bin but some binaries i found in /usr/xpg4/bin please can anyone tell me in a little detail what is the reason to keep the binaries in different locations i mean /bin /usr/bin /usr/xpg4/bin ... (1 Reply)
Discussion started by: mobydick
1 Replies

4. Shell Programming and Scripting

text parsing querry

$ A=/t1/bin/f410pdb oIFS=$IFS IFS=/ $ set -- $A $ IFS=$oIFS $ echo $2 t1 $ echo $3 bin $ echo $4 f410pdb can any one please explain me what is done with IFS and how it is working internally ...i am interested to know in depth (2 Replies)
Discussion started by: mobydick
2 Replies

5. UNIX for Dummies Questions & Answers

Querry LDAP data

from aix server, is it a way to extract data from windows LDAP. i will need to extract only firstname, lastname and login either xml or csv format ? i can use ldifde command to extract above information, but i have to do it from windows server. (1 Reply)
Discussion started by: tjmannonline
1 Replies

6. UNIX for Dummies Questions & Answers

querry about xargs command

what is the real use of xargs command ..? ls -tr |xargs -I{} rm -f {} ....can any one tell me what is the significance of {} curly brackets in this command (1 Reply)
Discussion started by: mobydick
1 Replies

7. UNIX for Dummies Questions & Answers

querry about ftp problem

hello , i want to know about a situation suppose i want to ftp to a system i try to login through root login root password ...will it fail i am getting ftp:500 command not recognized in a similar situation as soon as i am entering my email... (0 Replies)
Discussion started by: mobydick
0 Replies

8. UNIX for Dummies Questions & Answers

gcc compiler ---querry

i am newbie my querry is if i am having a gcc compiler which has been a native build with a particular version of binutilities..then when i will use this compiler to build other packages ..then in the linking stage which linker it will use if i do not set my path. ...will it uses by default... (0 Replies)
Discussion started by: mobydick
0 Replies

9. Shell Programming and Scripting

parsing output from SQL querry

Hi all I have this output in a variable called ...yes $OUTPUT :-) original...huh these are tablespaces in an Oracle db how do I get this into another variable in two columns so I can do a check on the numbers (space left) SYSTEM 290; USERS 19; UNDOTBS1 1863; DATA 5982; SYSTEM 290; USERS... (7 Replies)
Discussion started by: ludvig
7 Replies

10. HP-UX

querry on du

hi all, To summerize disk usage in human readable format we have "du -h" in linux,which gives the disk usage in MBs. do we have something similar in HP-UX ? thanks, amit (4 Replies)
Discussion started by: amit4g
4 Replies
Login or Register to Ask a Question