From owner-freebsd-questions@FreeBSD.ORG Thu Feb 7 20:54:10 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7823016A418 for ; Thu, 7 Feb 2008 20:54:10 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from snoogles.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 3E84013C455 for ; Thu, 7 Feb 2008 20:54:09 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (localhost [127.0.0.1]) by snoogles.rachie.is-a-geek.net (Postfix) with ESMTP id 01F991CC8B; Thu, 7 Feb 2008 11:53:58 -0900 (AKST) From: Mel To: freebsd-questions@freebsd.org Date: Thu, 7 Feb 2008 21:54:05 +0100 User-Agent: KMail/1.9.7 References: <80f4f2b20802060749p60c9d0ddw83b1ecbbed19db47@mail.gmail.com> In-Reply-To: <80f4f2b20802060749p60c9d0ddw83b1ecbbed19db47@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802072154.06464.fbsd.questions@rachie.is-a-geek.net> Cc: Jim Stapleton Subject: Re: ports makefile stuff (bsd.lib.mk) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Feb 2008 20:54:10 -0000 Hi, first of all, /usr/share/mk/bsd.lib.mk is part of the FreeBSD system make files, not just the ports. So if you change something there, you will almost certainly break your buildworld and buildkernel. On Wednesday 06 February 2008 16:49:46 Jim Stapleton wrote: > 1) Initially, this library will actually build several sublibraries. > To keep my code neat, each library has it's own source directory. So you set SUBDIR. > However, I also want to make cross linking easier and less prone to > "oops, I forgot to add the library's directory to the lib path list" > issues, so under the source directory I made an 'objs' directory, > where I was manually putting the output. Is there a way to simply have > the final output files sent to that directory? Not sure exactly what you want to do, so I'll just explain the "right" way: The system make, will always look for ${.CURDIR}/../Makefile.inc and include that if it's present. This allows you to centralize common CFLAGS/LDADD/LDFLAGS variables in one file, providing your source tree isn't deeper then 2 levels (otherwise, simply do .include "${.CURDIR}/../../Makefile.inc" before .include ) Objects are put in OBJDIR. If you have not set MAKEOBJDIRPREFIX in the environment, this will default to ${.CURDIR} and give you a warning. Providing the right libraries to compile /your/ program is /your/ responsibility. Here's an example: ./Makefile.inc: ====================================== .ifdef USING_LIBFOO LDFLAGS+=-L${.OBJDIR}/../libfoo CFLAGS+=-I${.CURDIR}/../include LDADD+=-lfoo .endif ./progfoo/Makefile: ====================================== SRCS=main.c foo.c PROG=progfoo USING_LIBFOO=yes .include Now the only problem you have, is making sure libfoo is built before progfoo, so: ./Makefile: ====================================== SUBDIR=libfoo progfoo .include -- Mel