From owner-freebsd-hackers@freebsd.org Thu Apr 27 19:26:43 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9EB25D53D28 for ; Thu, 27 Apr 2017 19:26:43 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mailout.stack.nl (mailout05.stack.nl [IPv6:2001:610:1108:5010::202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailout.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 6E91B168F; Thu, 27 Apr 2017 19:26:43 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mailout.stack.nl (Postfix) with ESMTP id 5EAD56E; Thu, 27 Apr 2017 21:26:33 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 4993428497; Thu, 27 Apr 2017 21:26:33 +0200 (CEST) Date: Thu, 27 Apr 2017 21:26:33 +0200 From: Jilles Tjoelker To: Brooks Davis Cc: Eric McCorkle , "freebsd-hackers@freebsd.org" Subject: Re: Generating sources during buildworld Message-ID: <20170427192633.GB88843@stack.nl> References: <3f63e99c-9241-380d-2e3a-12ef6a5a2758@metricspace.net> <20170426155153.GA24831@spindle.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170426155153.GA24831@spindle.one-eyed-alien.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Apr 2017 19:26:43 -0000 On Wed, Apr 26, 2017 at 03:51:53PM +0000, Brooks Davis wrote: > On Wed, Apr 26, 2017 at 11:40:10AM -0400, Eric McCorkle wrote: > > I'm looking for some help with the build system, specifically how to > > generate sources for a library that will then be used to build the library. > > Basically, I want to have a tool which collects public key certificates, > > then converts them into .c files which are used to build both loader and > > the kernel. > > Knowing how LLVM works, it seems that this is possible; however, I've > > been unable to find documentation on how to write a makefile that > > accomplishes this. Can someone point me to documentation or examples on > > how to do this? > It the tool is a script then take a look at usr.bin/getaddrinfo/Makefile > (make sure it's from the tip of head, the initial version had rather > poor style.) > If the tool is a compiled program, then things get more complicated. An > example of this is usr.bin/fortune/strfile/ and > usr.bin/fortune/datfiles/. For a new program, you'd need to make your > tool a bootstrap tool in Makefile.inc1. There are actually two kinds of these tools: bootstrap tools and build tools. Bootstrap tools such as strfile are also installed as normal programs; often, they are not built as a bootstrap tool if the version in the host system is sufficiently recent. Build tools are specific to building a particular directory, and are not installed. These work by adding the directory to a list in Makefile.inc1 and adding a build-tools target to the directory's Makefile. Examples are bin/sh and usr.bin/awk. In either case, the tool must be buildable on fairly old systems and your life will be simpler if you can write your tool in shell or awk. -- Jilles Tjoelker