linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Error in Makefile for multiple files
@ 2005-08-29 15:08 Sagar Shinde
  2005-08-30  8:01 ` Steve Graegert
  0 siblings, 1 reply; 3+ messages in thread
From: Sagar Shinde @ 2005-08-29 15:08 UTC (permalink / raw)
  To: linux-c-programming

[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]


Hi all,

I have a module with 3 C files: smarthook.c restore.c backup.c

My Makefile code is:
-----------------------------------------------------
INCLUDEDIR = /usr/src/kernels/linux-2.6.12.1/include

CFLAGS = -D__KERNEL__ -DMODULE
CFLAGS += -I$(INCLUDEDIR)

TARGET = smarthook
OBJS = $(TARGET).o
SRC = smarthook.c backup.c restore.c

all: .depend $(TARGET).o

$(TARGET).o: $(SRC:.c=.o)
	$(LD) -r $^ -o $@

depend .depend dep:
	$(CC) $(CFLAGS) -M *.c > $@
-----------------------------------------------------

now though I am giving proper dependencies
 why am I not able to access global variables defined in one file
(smarthook.c)
 from other files, inspite of these variables being declared extern in other
files.

any suggestions?

Thanks in Advance.

Thanks n Regards,
Sagar Shinde









http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@patni.com and delete this mail. 
_____________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Error in Makefile for multiple files
  2005-08-29 15:08 Error in Makefile for multiple files Sagar Shinde
@ 2005-08-30  8:01 ` Steve Graegert
  2005-08-30 18:15   ` K Anandan
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Graegert @ 2005-08-30  8:01 UTC (permalink / raw)
  To: sagar.shinde; +Cc: linux-c-programming

On 8/29/05, Sagar Shinde <sagar.shinde@patni.com> wrote:
> 
> Hi all,
> 
> I have a module with 3 C files: smarthook.c restore.c backup.c
> 
> My Makefile code is:
> -----------------------------------------------------
> INCLUDEDIR = /usr/src/kernels/linux-2.6.12.1/include
> 
> CFLAGS = -D__KERNEL__ -DMODULE
> CFLAGS += -I$(INCLUDEDIR)
> 
> TARGET = smarthook
> OBJS = $(TARGET).o
> SRC = smarthook.c backup.c restore.c
> 
> all: .depend $(TARGET).o
> 
> $(TARGET).o: $(SRC:.c=.o)
>        $(LD) -r $^ -o $@
> 
> depend .depend dep:
>        $(CC) $(CFLAGS) -M *.c > $@
> -----------------------------------------------------
> 
> now though I am giving proper dependencies
>  why am I not able to access global variables defined in one file
> (smarthook.c)
>  from other files, inspite of these variables being declared extern in other
> files.

Although I am not a make guru I can't see something unusual in this
fairly simple makefile.  Does the module compile and link properly
without using a makefile, i.e. compiling and linking manually?  Is the
contents of .depend exactly what you expected after calling make?

Please, let us know if you have results you want to share.
 
Regards

	\Steve

--

Steve Graegert <graegerts@gmail.com>
Software Consultancy {C/C++ && Java && .NET}
Mobile: +49 (176)  21248869
Office: +49 (9131) 7126409

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Error in Makefile for multiple files
  2005-08-30  8:01 ` Steve Graegert
@ 2005-08-30 18:15   ` K Anandan
  0 siblings, 0 replies; 3+ messages in thread
From: K Anandan @ 2005-08-30 18:15 UTC (permalink / raw)
  To: linux-c-programming

Sagar Shinde

On Tue, 2005-08-30 at 04:01, Steve Graegert wrote:
> On 8/29/05, Sagar Shinde <sagar.shinde@patni.com> wrote:
> > 
> > Hi all,
> > 
> > I have a module with 3 C files: smarthook.c restore.c backup.c
> > 
> > My Makefile code is:
> > -----------------------------------------------------
> > INCLUDEDIR = /usr/src/kernels/linux-2.6.12.1/include
> > 
> > CFLAGS = -D__KERNEL__ -DMODULE
> > CFLAGS += -I$(INCLUDEDIR)
> > 
> > TARGET = smarthook
> > OBJS = $(TARGET).o
> > SRC = smarthook.c backup.c restore.c
> > 
> > all: .depend $(TARGET).o
Here you change 
all: .depend $(TARGET)

> > 
> > $(TARGET).o: $(SRC:.c=.o)
Here you change 
$(TARGET) : $(SRC:.c=.o)

> >        $(LD) -r $^ -o $@
> > 
> > depend .depend dep:
> >        $(CC) $(CFLAGS) -M *.c > $@
> > -----------------------------------------------------
> > 
> > now though I am giving proper dependencies
> >  why am I not able to access global variables defined in one file
> > (smarthook.c)
> >  from other files, inspite of these variables being declared extern in other
> > files.
> 
> Although I am not a make guru I can't see something unusual in this
> fairly simple makefile.  Does the module compile and link properly
> without using a makefile, i.e. compiling and linking manually?  Is the
> contents of .depend exactly what you expected after calling make?
> 
> Please, let us know if you have results you want to share.
>  
> Regards
> 
> 	\Steve
> 
> --
> 
> Steve Graegert <graegerts@gmail.com>
> Software Consultancy {C/C++ && Java && .NET}
> Mobile: +49 (176)  21248869
> Office: +49 (9131) 7126409
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 

Your program will work fine

Ananth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-30 18:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-29 15:08 Error in Makefile for multiple files Sagar Shinde
2005-08-30  8:01 ` Steve Graegert
2005-08-30 18:15   ` K Anandan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).