Makefile novice has error toring object code in sub-directory
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix questions > Makefile novice has error toring object code in sub-directory




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Makefile novice has error toring object code in sub-directory  
Christopher M. Lusardi


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-08-04 10:52 PM

Hello,

I have been trying to store my suffixed dot o's in a subdirectory using
"mv", but make can only find 2 files in a series of many files!

How can I correct my error(see below)?

Via examples, what other ways would you improve on my makefile?

Thank you,
Christopher Lusardi

P.S.: I am compiling c and c++ files. Occurrences of "..." indicate "etc".

---------------------------------------------------------------------------

#beginning of makefile

#vpath *.o .:/home/clusardi/.objects/
VPATH = .:.objects

MV = /bin/mv

MY_LIB = /home/clusardi

OBJS_DIR = .my_objects

OTHER_SRC = OTHER_SRC

all : edit

OBJS = main.o  \
file1.o \
..

OBJS2 = file_n.o     \
file_np1.o \
..

file1.o: $(OTHER_SRC)/file1.C
CC -c $(OTHER_SRC)/file1.C
$(MV) $@ $(OBJS_DIR)

${OBJS} : ${@:.o=.c}
cc -c  $?
$(MV) $@ $(OBJS_DIR)/$@

edit: $(OBJS) $(OBJS2)
CC $(OBJS_DIR)/$(OBJS) $(OBJS_DIR)/$(OBJS2) -o $@
$(MV) $@ $(MY_LIB)/$@

#end makefile

---------------------------------------------------------------------------
%make

CC -g /home/clusardi/.objects/main.o file1.o ...
/home/clusardi/.objects/file_n.o  file_np1.o     ...  -o edit
ld64: FATAL   9  : I/O error (file1.o): No such file or directory
*** Error code 2 (bu21)





[ Post a follow-up to this message ]



    Re: Makefile novice has error toring object code in sub-directory  
Ed Morton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-09-04 01:47 AM



Christopher M. Lusardi wrote:
> Hello,
>
>    I have been trying to store my suffixed dot o's in a subdirectory using
> "mv", but make can only find 2 files in a series of many files!
>
>    How can I correct my error(see below)?
<snip>
> edit: $(OBJS) $(OBJS2)
> 	CC $(OBJS_DIR)/$(OBJS) $(OBJS_DIR)/$(OBJS2) -o $@

The above line is a problem. OBJS_DIR is a single directory, but OBJS
(and similairly OBJS2) is a list of files, so this expands to:

/home/clusardi/.objects/main.o file1.o ...

instead of what you want:

/home/clusardi/.objects/main.o /home/clusardi/.objects/file1.o ...

since file1.o isn't in the current directory, but instead under
$OBJS_DIR just like main.o, and so you get the error message.

I suspect the "patsub" command could help you convert %.o into
$(OBJS_DIR)/%.o.

If you're still having problems, posting a small, complete example that
demonstrates the problem would be useful.

Ed.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:29 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register