The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Makefile help tantric High Level Programming 4 04-13-2007 01:35 AM
Makefile NamrataGurav High Level Programming 7 10-07-2006 02:29 PM
makefile scmay UNIX for Dummies Questions & Answers 4 06-30-2005 02:39 AM
makefile help pieter023 Shell Programming and Scripting 1 06-06-2005 01:20 AM
makefile raagbansal UNIX for Advanced & Expert Users 1 12-22-2004 09:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-26-2002
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
problem with Makefile

Hi,

I have a makefile which looks like this

ProcessA :
commands

touch pro1

ProcessB : pro1
commands

touch pro2

ProcessC: pro3
commands


and after some runs, i wish only pro3 to run and I check that "pro1" and "pro2" are there in the directory, but still, if i give make Process3, it starts right from ProcessA and does all the steps.
Is there anything wrong?

Thanks,
Balaji
  #2 (permalink)  
Old 08-27-2002
qanda qanda is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 12
There are several things to note, keep in mind that the make utility and makefiles are extremely versatile and can become extremely complicated.

I'll start at the beginning with some basics, if need be I can go into more detail later.

make does not need a makefile! If you have a file called prog.c you can type
  #3 (permalink)  
Old 08-27-2002
qanda qanda is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 12
Sorry, browser went funny ?

As I was saying, if you have a file called prog.c you can type
make prog
make has its own build in rules and will know how to create prog from prog.c

A simple makefile consists of targets and dependencies with associated commands, in general: -

target: dependency
<tab>command

I can't tell from your posting what whitespace you have in your makefile, this is important as the dependency line must NOT begin with a tab, the command line MUST begin with a tab.

I think there may be a couple of problems with your makefile, here's one that I believe will do what you want: -

ProcessA:
@echo "ProcessA"
touch proc1

ProcessB:
@echo "ProcessB"
touch proc2

ProcessC:
@echo "ProcessC"
touch proc3

You'll notice there are no dependencies, in fact there are NULL dependencies, this means the target is always rebuilt

you can now use
make ProcessA
make ProcessB
make ProcessC

however if you use make on its own it will only build the first dependency. This can be modified to build everything and can include more advanced techniques to selectively build different sources.

Let me know if you want more info, if so tell me what sources you are building with a little more detail, ie C/C++ files, related headers, etc.

Hope it helps.
  #4 (permalink)  
Old 08-27-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,116
qanta, if you have difficulty posting, you can edit your post. But also, I think you missed what he wants to do.

sskb, the crux of your problem is that you are using a rule named "ProcessA" to make a file called "pro1". You need to name the rule after the file that it will create. The name of a rule is called a "target" for a reason. You can use secondary rules to create "aliases" if you really want to. And, qanta has a point about the first rule. You should always tary to ensure that just using the command "make" will try to do the most useful thing.

Here is my makefile that I think addresses all of this. And as qanta points out, what I will type as spaces should be just a tab character.
Code:
default: ProcessC

ProcessA: pro1
ProcessB: pro2
ProcessC: pro3

pro1:
       @echo making pro1
       touch pro1

pro2: pro1
       @echo making pro2
       touch pro2

pro3: pro2
       @echo making pro3
       touch pro3
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0