#!/usr/bin/env perl1#***************************************************************************2# _ _ ____ _3# Project ___| | | | _ \| |4# / __| | | | |_) | |5# | (__| |_| | _ <| |___6# \___|\___/|_| \_\_____|7#8# Copyright (C) Viktor Szakats9#10# This software is licensed as described in the file COPYING, which11# you should have received as part of this distribution. The terms12# are also available at https://curl.se/docs/copyright.html.13#14# You may opt to use, copy, modify, merge, publish, distribute and/or sell15# copies of the Software, and permit persons to whom the Software is16# furnished to do so, under the terms of the COPYING file.17#18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY19# KIND, either express or implied.20#21# SPDX-License-Identifier: curl22#23###########################################################################2425# Helper script for "unity"-like support in autotools, to generate the umbrella26# C source that includes the individual source files. Reads Makefile.inc and27# accepts the variable name containing all the source files to include. Also28# allow a list of exceptions that are to be excluded from the generated file.2930use strict;31use warnings;3233if(!@ARGV) {34die "Usage: $0 [<c-sources>] [--exclude <exclude-c-sources>]\n";35}3637my $srcdir = shift @ARGV;3839# Specific sources to exclude or add as an extra source file40my @src;41my %exclude;42my $in_exclude = 0;43foreach my $src (@ARGV) {44if($in_exclude) {45$exclude{$src} = 1;46}47elsif($src eq "--exclude") {48$in_exclude = 1;49}50else {51push @src, $src;52}53}5455print <<HEADER56/* !checksrc! disable COPYRIGHT all */57HEADER58;5960foreach my $src (@src) {61if($src =~ /\.c$/g && !exists $exclude{$src}) {62if(-e "$srcdir/$src") {63print "#include \"$srcdir/$src\"\n";64}65else {66print "#include \"$src\"\n";67}68}69}707172