1255577Sdes#!/usr/bin/perl -w 2255577Sdes#- 3255577Sdes# Copyright (c) 2013 Dag-Erling Sm��rgrav 4255577Sdes# All rights reserved. 5255577Sdes# 6255577Sdes# Redistribution and use in source and binary forms, with or without 7255577Sdes# modification, are permitted provided that the following conditions 8255577Sdes# are met: 9255577Sdes# 1. Redistributions of source code must retain the above copyright 10255577Sdes# notice, this list of conditions and the following disclaimer. 11255577Sdes# 2. Redistributions in binary form must reproduce the above copyright 12255577Sdes# notice, this list of conditions and the following disclaimer in the 13255577Sdes# documentation and/or other materials provided with the distribution. 14255577Sdes# 15255577Sdes# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16255577Sdes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17255577Sdes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18255577Sdes# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19255577Sdes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20255577Sdes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21255577Sdes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22255577Sdes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23255577Sdes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24255577Sdes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25255577Sdes# SUCH DAMAGE. 26255577Sdes# 27255779Sdes# $FreeBSD$ 28255577Sdes# 29255577Sdes 30255577Sdesuse strict; 31255577Sdesuse warnings; 32255577Sdesuse Text::Wrap; 33255577Sdes 34255589Sdesour @targets = qw(LIBUNBOUND DAEMON UBANCHOR CHECKCONF CONTROL); 35255577Sdes 36255577Sdesour %target_names = ( 37255577Sdes LIBUNBOUND => "libunbound", 38255577Sdes DAEMON => "unbound", 39255577Sdes UBANCHOR => "unbound-anchor", 40255577Sdes CHECKCONF => "unbound-checkconf", 41255589Sdes CONTROL => "unbound-control", 42255577Sdes); 43255577Sdes 44255577Sdessub get_sources($) { 45255577Sdes my ($target) = @_; 46255577Sdes local $/; 47255577Sdes 48255577Sdes open(MAKE, "-|", "make", "-V${target}_OBJ_LINK") 49255577Sdes or die("failed to exec make: $!\n"); 50255577Sdes my $objs = <MAKE>; 51255577Sdes close(MAKE); 52255577Sdes chomp($objs); 53255577Sdes $objs =~ s/\.l?o\b/.c/g; 54276599Sdes return map { 55276599Sdes /lexer/ && s/c$/l/; 56276599Sdes /parser/ && s/c$/y/; 57276599Sdes $_; 58276599Sdes } split(/\s+/, $objs); 59255577Sdes} 60255577Sdes 61255577SdesMAIN:{ 62255577Sdes my %sources; 63255577Sdes foreach my $target (@targets) { 64255577Sdes $sources{$target} = { 65255577Sdes map({ $_ => 1 } 66255577Sdes grep({ !exists($sources{LIBUNBOUND}->{$_}) } 67255577Sdes get_sources($target))) 68255577Sdes }; 69255577Sdes print("# $target_names{$target}\n"); 70255577Sdes my $SRCS = fill("SRCS=\t", "\t", sort keys %{$sources{$target}}); 71255577Sdes $SRCS =~ s/\n/ \\\n/gm; 72255577Sdes print("$SRCS\n"); 73255577Sdes } 74255577Sdes} 75255577Sdes 76255577Sdes1; 77