Re: GTK+ (embarrassing) Makefile question...



I think I just got it.  When I add 2 things on same rule line
/your way/ it seems to only "catch" files that have both a .cpp AND .h
version.  It seems that .cpp files with NO .h analog EACH
need a separate rule for them. Ahhhh!!!!

Chris



On Wed, Mar 27, 2002 at 10:59:18AM -0800, Christian Seberino wrote:
> Ron
> 
> Thanks for reply.  I was getting desperate to get
> this Makefile question answered since it was slowing
> down my GTK+ work and I didn't know of any make mailing lists.
> I hope this one post was OK. :)
> 
> I made the changes you mentioned to rules but now mysteriously
> Main.cpp doesn't get flags when make works on it?!?!?!
> Can I ask you this hopefully last thing?
> 
> (Main.cpp is the ONLY .cpp file that does not
> have a header file.  Also, I did not add header files
> to $SRCS.  The solution probably has something to do with
> this fact but I don't know what.)
> 
> 
> (seberino /home/seberino/MAIN/AESR) % make
> g++ `gtk-config --cflags` -c AESRSimulator.cpp
> g++ `gtk-config --cflags` -c EulerMaruyama.cpp
> g++ `gtk-config --cflags` -c GUI.cpp
> g++    -c -o Main.o Main.cpp
> In file included from /usr/include/gdk/gdktypes.h:33,
>                  from /usr/include/gdk/gdk.h:31,
>                  from /usr/include/gtk/gtk.h:31,
>                  from Window.h:13,
>                  from GUI.h:13,
>                  from Main.cpp:24:
> /usr/include/glib.h:66: glibconfig.h: No such file or directory
> make: *** [Main.o] Error 1
> 
> ...
> 
> I tried removing tabs from $SRCS below and moving Main.cpp to
> first line of $SRCS definition.. all to no avail.  Makefiles
> just confuse me.
> 
> 
> Here is the new and improved version...
> 
> PROGRAM	=	Main
> 
> CPPC	=	g++
> 
> FLAGS	=	`gtk-config --cflags`
> 
> LIBS	=	`gtk-config --libs` -lpthread
> 
> SRCS	=	AESRSimulator.cpp EulerMaruyama.cpp GUI.cpp    \
>                 Main.cpp RandomNumber.cpp SignalProcessing.cpp \
>                 Window.cpp
> 
> OBJS	=	$(SRCS:.cpp=.o)
> 
> %.o:		%.cpp %.h
> 		$(CPPC) $(FLAGS) -c $*.cpp
> 
> all:		$(PROGRAM)
> 
> $(PROGRAM):	$(OBJS)
> 		$(CPPC) $(OBJS) $(LIBS) -o $(PROGRAM)
> 
> clean:
> 		rm -f $(OBJS) $(PROGRAM)
> 
> 
> 
> On Wed, Mar 27, 2002 at 10:13:33AM -0800, rsteinke w-link net wrote:
> > From: Christian Seberino <seberino spawar navy mil>
> > >
> > > This Makefile will recreate GTK+ object file if header file
> > > is "touched" with touch command which is good....
> > >
> > > It will NOT recreate object file when *.cpp file is 
> > > "touched" the same way.
> > >
> > > WHY IS the "%.o: %.h" rule working
> > > but the "%.o: %.cpp" rule IS NOT!!??!?!?
> > >
> > > Here is makefile...
> > 
> > <snip>
> > 
> > > %.o:		%.h
> > > 		$(CPPC) $(FLAGS) -c $*.cpp
> > >
> > > %.o:		%.cpp
> > > 		$(CPPC) $(FLAGS) -c $<
> > 
> > While you are allowed to have more than one dependency for a file, you are not
> > allowed to have more than one rule on how to build that file. What you need is:
> > 
> > %.o:		%.h %.cpp
> > 		$(CPPC) $(FLAGS) -c $*.cpp
> > 
> > BTW, this isn't really a gtk+ specific question. This would be more
> > appropriate on a discussion list for "make".
> > 
> > Ron Steinke
> 
> -- 
> =======================================================
> | Dr. Christian Seberino  || (619) 553-7940  (office) |
> | SPAWARSYSCEN 2363       || (619) 553-2836  (fax)    |
> | 53560 HULL ST           ||                          |
> | SAN DIEGO CA 92152-5001 || seberino spawar navy mil |
> =======================================================

-- 
=======================================================
| Dr. Christian Seberino  || (619) 553-7940  (office) |
| SPAWARSYSCEN 2363       || (619) 553-2836  (fax)    |
| 53560 HULL ST           ||                          |
| SAN DIEGO CA 92152-5001 || seberino spawar navy mil |
=======================================================



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]