Re: Makefile for library and application
- From: "Michael Marsh" <michael.a.marsh@xxxxxxxxx>
- Date: Mon, 13 Mar 2006 17:18:25 -0500
On 3/13/06, Michael Ott <michael@xxxxxxxxxx> wrote:
I want to write an application which includes library which are also
written by me.
I can create a makefile for an application and i can create makefile for
libraries. But is it possible to write both in one makefile with
subdirs. One for the source of the application, one for the libs and a
few for the libraries which i want also use for other applications.
It's pretty simple to handle multiple subdirectories. Here's a
makefile stub for gmake:
DIRS := mylib myapp
.PHONY : $(DIRS)
default : $(DIRS)
$(DIRS) :
<tab>$(MAKE) -C $@
Obviously, you'd want to replace "mylib" and "myapp". This also
assumes that you have makefiles in the subdirectories, since for
compiling multiple libraries or applications that's generally easier
than trying to make one big makefile for everything. That's not to
say it can't be done, though. You'd probably want something like
$(MYLIBSRCS) := $(wildcard mylib/*.c)
$(MYLIBOBJS) := $(patsubst %.c,libmylib.a(%.o),$(MYLIBSRCS))
.PHONY : mylib
mylib : $(MYLIBOBJS)
I'm not sure if this will actually work properly, since I haven't
tested it. It'll also tend to make your makefile more difficult to
read and maintain.
--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
- References:
- Makefile for library and application
- From: Michael Ott
- Makefile for library and application
- Prev by Date: Re: Best Linux Laptop
- Next by Date: Re: Hardware
- Previous by thread: Makefile for library and application
- Index(es):
Relevant Pages
|