delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/03/08/21:46:07

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: nospam AT none DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: makefile, how to compile into bin directory?
Date: Tue, 9 Mar 2004 02:43:28 +0000 (UTC)
Organization: University of California, Berkeley
Lines: 28
Sender: Raymond Chi <chiry AT soda DOT csua DOT berkeley DOT edu>
Message-ID: <c2jb0g$lkd$1@agate.berkeley.edu>
NNTP-Posting-Host: soda.csua.berkeley.edu
X-Trace: agate.berkeley.edu 1078800208 22157 128.32.112.233 (9 Mar 2004 02:43:28 GMT)
X-Complaints-To: usenet AT agate DOT berkeley DOT edu
NNTP-Posting-Date: Tue, 9 Mar 2004 02:43:28 +0000 (UTC)
User-Agent: tin/1.5.12-20020427 ("Sugar") (UNIX) (FreeBSD/4.7-STABLE (i386))
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I have a simple makefile as follow:

==================================

all: $(MAIN_TARGET)

$(MAIN_TARGET): hello.o

hello.o: hello.c

VPATH = include src bin

==================================

how do i configure this makefile so that the output files, .o and .exe
files goes into a bin sub directory? my .c files are in src directory

I tried writing explicit rules

%.o: %.c;  $(CC)  $(CFLAGS)   $(CPPFLAGS) -c -o $(OUTPUT_DIR)/$@ $<
%.o: %.cc; $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $(OUTPUT_DIR)/$@ $<
%: %.o;    $(CC)  $(LDFLAGS) $(OUTPUT_DIR)/$^ $(LOADLIBES) $(LDLIBS) -o bin/$@
%.exe: %.o;  $(CC)  $(LDFLAGS) $(OUTPUT_DIR)/$^ $(LOADLIBES) $(LDLIBS) -o bin/$@

and it sort of works, but it has problems sometimes (finding dependencies)...

Raymond

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019