PHONY target is not working


 
Thread Tools Search this Thread
Top Forums Programming PHONY target is not working
# 1  
Old 06-29-2010
PHONY target is not working

Hi,

I am trying to write one makefile with phony target "clean" ...it is working fine when there is no file exist by name "clean", while it create a new file "clean" , PHONY clean is not working.

.
Code:
PHONY : clean
clean:
        rm -f hello.txt bye.txt
        @echo "Files are deleted"

when i run this clean like
Code:
$make clean
`clean' is up to date.

(is is showing this message when a file by name clean exist in my local dir)

Can you please advise me ??

Thanks
Amit

Last edited by pludi; 06-29-2010 at 06:42 AM.. Reason: code tags, please...
# 2  
Old 06-29-2010
Obviously you have the right idea that you want to create a phony target, since any file 'clean' would show as up to date since it has no dependancies.

Your code does not work however because the built-in name for phony targets is actually .PHONY not PHONY. I tested the following to work on a Debian system using GNU make:

Code:
 
.PHONY: clean
clean:
     rm -f hello.txt bye.txt
     @echo "Files are deleted"


Last edited by paradox242; 06-29-2010 at 12:39 PM..
# 3  
Old 06-29-2010
I'd also note that not all versions of make support phony targets. GNU make definitely does though.
# 4  
Old 06-30-2010
Yes, i also came to know that .PHONY target is dependent on make version on OS type, so some times it may show such type of behaviour.

thanks for your help

Amit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

After adding new iscsi target port, still the session state of that target port is showing offline

Hi, I wanted to configure new iscsi port on HPUX system, i added the target port address and configured it, once done, went to array side and searched for that host iqn number , but was nt able to find the same, came to host, then when i ran "iscsiutil -pVS" command it gave me below result ... (0 Replies)
Discussion started by: Vinay Kumar D
0 Replies

2. Shell Programming and Scripting

Target string with gsub

Hey guys, I am learning awk and came across gsub and testing the target string to do substitution, what am i missing? Thanks in advance. echo "this is a summer" | awk '{gsub(/er/, "x", "summer"); print}' this is a summer The following works: but i don't understand the why the above... (3 Replies)
Discussion started by: Apollo
3 Replies

3. Programming

multiple Library target

Hi there, I am new to programming on unix and have been handed a legacy system. THe makefile is relatively complicated but i have moslyt figured it out. One issue i cannot figure out is the fact that i now need to create a second output exe. (ie multiple LIRARY_TARGETS with one makefile.) can... (2 Replies)
Discussion started by: anthony.x.moss@
2 Replies

4. HP-UX

Polling target on Serviceguard

Hi Guys, we are planning to enable polling target on our SG in reference to this link MC/ServiceGuard: Subnet Goes Down when one of the Cluster Node is Down - HP Customer Care (United States - English) since our server is already in production can we apply the changes with ex. "cmapplyconf... (1 Reply)
Discussion started by: batas
1 Replies

5. HP-UX

swinstall not working with target

Hi, I have installed a software using the command(swinstall -s /Softwares/Game.pkg AngryDog.nwr-cbin @/z_temp). During installation I didn't find any error, also I can find a folder structure(opt/angrydog...) getting created under "/z_temp" and all files are present. But software is not working.... (1 Reply)
Discussion started by: Thunderbird288
1 Replies

6. Shell Programming and Scripting

target string to delete

Hi all, I have a text file with a lot of records. In each records I have tags like this: =952 \\$aBNCS-CH\\$bBNCS-CH\\$h1989\\$oBNCS-CH0000001\\$pBNCS-CH0000001\\$yJNL =952 \\$aBNCS-C.UNIV\\$bBNCS-C.UNIV\\$h1974-77.\\$oBNCS-C.UNIV0000001\\$pBNCS-C.UNIV0000001\\$yJNL =952... (4 Replies)
Discussion started by: ldiaz2106
4 Replies

7. Shell Programming and Scripting

MakeFile Backup Target

Goal: I'm trying to create a PHONY target inside my Makefile so that when I run the command "make backup", It will move all the files that end in "~" into the specified backup folder. Here is my code currently, and I'll explain the problem after: .PHONY: backup backup: @mkdir -p... (2 Replies)
Discussion started by: Xploit
2 Replies

8. Shell Programming and Scripting

Sometimes my until loop misses it's target

Hello all, I wrote a quick function (alarm) in my bash_profile (in cygwin) for practice. It uses until loops to wait for a specified time, and once that time passes triggers a play on a mp3. Most of the time it works, however sometimes it seems like it's looping through too slowly and will miss... (1 Reply)
Discussion started by: DeCoTwc
1 Replies

9. Solaris

Controller target disk?

Hi, I am a newbie to Solaris. I want to know how to find out the controller target and disk number on a SunFire V890 box that has 6X72GB disks. The probe-scsi output is as shown below: /pci@8,600000/SUNW,qlc@2 LiD HA LUN --- Port WWN --- ----- Disk description ----- 0 0 0 ... (1 Reply)
Discussion started by: sudhir_shet
1 Replies

10. UNIX for Dummies Questions & Answers

vi, c/source/target g?

hi in vi, i have a file and i wanted to replace all wnix to unix. is the below correct. c/wnix/unix g... i have tried , and the above is not right... help? (7 Replies)
Discussion started by: yls177
7 Replies
Login or Register to Ask a Question