From patchwork Fri Mar 4 05:40:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 63504 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp284682lbc; Thu, 3 Mar 2016 21:56:18 -0800 (PST) X-Received: by 10.98.87.216 with SMTP id i85mr7720940pfj.72.1457070977979; Thu, 03 Mar 2016 21:56:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si3447471pap.42.2016.03.03.21.56.17; Thu, 03 Mar 2016 21:56:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755495AbcCDF4B (ORCPT + 30 others); Fri, 4 Mar 2016 00:56:01 -0500 Received: from alt22.smtp-out.videotron.ca ([70.80.0.73]:46605 "EHLO alt22.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751065AbcCDFz5 (ORCPT ); Fri, 4 Mar 2016 00:55:57 -0500 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id biZ7ahUuhg8R4biZ8aEpfS; Fri, 04 Mar 2016 00:46:18 -0500 X-Authority-Analysis: v=2.1 cv=b8ISmoyx c=1 sm=1 tr=0 a=keA3yYpnlypCNW5BNWqu+w==:117 a=keA3yYpnlypCNW5BNWqu+w==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=7OsogOcEt9IA:10 a=KKAkSRfTAAAA:8 a=DR8aRbLO010_Rlgsu9YA:9 Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 6EFBA2DA05EA; Fri, 4 Mar 2016 00:40:54 -0500 (EST) From: Nicolas Pitre To: Michal Marek Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/8] fixdep: accept extra dependencies on stdin Date: Fri, 4 Mar 2016 00:40:45 -0500 Message-Id: <1457070050-1564-4-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457070050-1564-1-git-send-email-nicolas.pitre@linaro.org> References: <1457070050-1564-1-git-send-email-nicolas.pitre@linaro.org> X-CMAE-Envelope: MS4wfL7wpRjI8PIXvkWJ3AC7eDIDkVZF0KeKtbZ+KKiS/ezxCx1QKUt0cfTPA2hCLGM7GomLofUayy+FZz2IxhTR9DSXF0Sv78KiaMZx8deioq1xLrSNqnXQ dCZv6hL7c0I/KdSTwT8v7ICJimTwty7FLvSQvqH08gdbD/uElSDznxX+yME6LKq2CTkTzMfpBMxMLIxbJrdAJxxqRhs2u4fLPfXPaw01l1GmYJiVn7t7DJ5K ZeATrTmpk4H61W2Bt+FMog== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... and merge them in the list of parsed dependencies. Signed-off-by: Nicolas Pitre --- scripts/basic/fixdep.c | 60 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 15 deletions(-) -- 2.5.0 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 5b327c67a8..d984deb120 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -120,13 +120,15 @@ #define INT_NFIG ntohl(0x4e464947) #define INT_FIG_ ntohl(0x4649475f) +int insert_extra_deps; char *target; char *depfile; char *cmdline; static void usage(void) { - fprintf(stderr, "Usage: fixdep \n"); + fprintf(stderr, "Usage: fixdep [-e] \n"); + fprintf(stderr, " -e insert extra dependencies given on stdin\n"); exit(1); } @@ -138,6 +140,40 @@ static void print_cmdline(void) printf("cmd_%s := %s\n\n", target, cmdline); } +/* + * Print out a dependency path from a symbol name + */ +static void print_config(const char *m, int slen) +{ + int c, i; + + printf(" $(wildcard include/config/"); + for (i = 0; i < slen; i++) { + c = m[i]; + if (c == '_') + c = '/'; + else + c = tolower(c); + putchar(c); + } + printf(".h) \\\n"); +} + +static void do_extra_deps(void) +{ + if (insert_extra_deps) { + char buf[80]; + while(fgets(buf, sizeof(buf), stdin)) { + int len = strlen(buf); + if (len < 2 || buf[len-1] != '\n') { + fprintf(stderr, "fixdep: bad data on stdin\n"); + exit(1); + } + print_config(buf, len-1); + } + } +} + struct item { struct item *next; unsigned int len; @@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash) static void use_config(const char *m, int slen) { unsigned int hash = strhash(m, slen); - int c, i; if (is_defined_config(m, slen, hash)) return; define_config(m, slen, hash); - - printf(" $(wildcard include/config/"); - for (i = 0; i < slen; i++) { - c = m[i]; - if (c == '_') - c = '/'; - else - c = tolower(c); - putchar(c); - } - printf(".h) \\\n"); + print_config(m, slen); } static void parse_config_file(const char *map, size_t len) @@ -250,7 +275,7 @@ static void parse_config_file(const char *map, size_t len) } } -/* test is s ends in sub */ +/* test if s ends in sub */ static int strrcmp(const char *s, const char *sub) { int slen = strlen(s); @@ -374,6 +399,8 @@ static void parse_dep_file(void *map, size_t len) exit(1); } + do_extra_deps(); + printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); } @@ -430,7 +457,10 @@ int main(int argc, char *argv[]) { traps(); - if (argc != 4) + if (argc == 5 && !strcmp(argv[1], "-e")) { + insert_extra_deps = 1; + argv++; + } else if (argc != 4) usage(); depfile = argv[1];