LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-28-2004, 02:19 AM   #1
markelo
Member
 
Registered: Mar 2004
Distribution: Red hat 9 -> 64bit fedora
Posts: 190

Rep: Reputation: 30
My makefile troubles


I have made an app which uses my own Templates ( see variable
MYTEMPLATES=MYTemplateHDRS/*.hpp )
It also needs some files from root dir of the app and then all the rest from the bagdir ( application directory ) itself, which is a subdir of the root dir of the app ( named bag ).

My problem is that make doesn't leave object files subdir. It puts them to application root directory instead.

This line does compilation from .cpp files to .o files
Code:
.cpp.o: $(MYTEMPLATES) $(DRAWHDR) $(STEERHDR)
	@echo mycompile $(CXX) -c $< $(CXXFLAGS)
	@echo mytargetname $@ and target dir $(@D)
	$(CXX) -c $< $(CXXFLAGS)
Those echo lines show that target file is bagdir/bagobject.o and bagdir/bagtest.o but still those targets are put in root directory.

If I just type g++ -c -o ./bagdir/bagtest.o ./bagdir/bagtest.cpp
bagtest.o is place in bagdir where it should be. What I am missing ?


Here is makefile

Code:
SHELL=/bin/sh
CXX=g++
CXXFLAGS= -g -Wall -ansi -pedantic -IMYTemplateHDRS -I.  `sdl-config --cflags`

LIBS=`sdl-config --libs`
OSTYPE=$(shell uname -s)

ifeq ($(OSTYPE),Linux)
	GLLIBS=-lGL -lGLU -L/usr/X11/lib
else
        CXXFLAGS+=-I/usr/include/g++-3
	GLLIBS=-lopengl32 -lglu32
endif

SRCS=$(wildcard bag.cpp )
BINARIES=$(basename $(SRCS))
OBJS=$(subst .cpp,.o,$(SRCS)) 
MYTEMPLATES=MYTemplateHDRS/*.hpp
BAGDIRC=$(wildcard ./bagdir/*.cpp )
BAGDIRH=$(wildcard ./bagdir/*.hpp )
BAGOBJ=$(subst .cpp,.o,$(BAGDIRC))
DRAWHDR=draw.hpp
DRAWOBJ=draw.o
STEERHDR=Steer.hpp
STEEROBJ=Steer.o

#all: 
#	@echo $(BINARIES) $(BAGDIRC) $(BAGOBJ)
all: $(BINARIES) $(OBJS) $(DRAWOBJ) $(STEEROBJ) $(BAGOBJ)

#$(BAGOBJ): $(BAGDIRC)
#	$(CXX) -c $< $(CXXFLAGS)
#	@echo mybagdir $(@D) mybagsources $(BAGDIRC) mybagobjects $(BAGOBJ)

#Compiling 

.cpp.o: $(MYTEMPLATES) $(DRAWHDR) $(STEERHDR)
	@echo mycompile $(CXX) -c $< $(CXXFLAGS)
	@echo mytargetname $@ and target dir $(@D)
	$(CXX) -c $< $(CXXFLAGS)

# linking

bag: bag.o $(DRAWOBJ) $(STEEROBJ) $(BAGOBJ)
	@echo mylinking $(CXX) $< $(DRAWOBJ) $(STEEROBJ) $(BAGOBJ) -o $@ $(LIBS) $(GLLIBS)
	$(CXX) $< $(DRAWOBJ) $(STEEROBJ) $(BAGOBJ) -o $@ $(LIBS) $(GLLIBS)

clean:
	rm -f *.o $(BINARIES) *~ stdout.txt stderr.txt
Edit: Removed couple commants from makefile.

New edit. Learned more about makefiles end then made one which has some sense but still problematic.

Last edited by markelo; 09-06-2004 at 05:22 AM.
 
Old 09-06-2004, 05:27 AM   #2
markelo
Member
 
Registered: Mar 2004
Distribution: Red hat 9 -> 64bit fedora
Posts: 190

Original Poster
Rep: Reputation: 30
Little bump
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
troubles with SATA, troubles with NVIDIA aevangelica Linux - Hardware 6 10-17-2005 02:39 AM
How to modify makefile.in or makefile.am QiangWan Linux - Newbie 1 05-17-2005 11:07 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM
makefile help alaios Programming 5 06-02-2003 03:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration