|
Home > Archive > Unix questions > October 2004 > Makefile novice has error toring object code in sub-directory
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Makefile novice has error toring object code in sub-directory
|
|
| Christopher M. Lusardi 2004-10-08, 5: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)
| |
| Ed Morton 2004-10-08, 8:47 pm |
|
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.
|
|
|
|
|