From 8aed1fcd443b550c15a21ddbf1b1d3899803120a Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 30 Mar 2014 15:55:20 +0200 Subject: rework hosttools building, add tools into package stuff --- tools/Makefile | 57 - tools/addpattern/Makefile | 4 - tools/addpattern/addpattern.c | 252 -- tools/adk/Makefile | 17 - tools/adk/depmaker.c | 313 -- tools/adk/dkgetsz.c | 95 - tools/adk/pkgmaker.c | 1194 ------ tools/adk/pkgrebuild.c | 273 -- tools/adk/sortfile.c | 153 - tools/adk/sortfile.h | 1 - tools/adk/strmap.c | 510 --- tools/adk/strmap.h | 350 -- tools/bc/Makefile | 25 - tools/bzip2/Makefile | 24 - tools/ccache/Makefile | 25 - tools/cdrtools/Makefile | 25 - tools/cpio/Makefile | 32 - tools/cpio/src/_alloca.h | 27 - tools/cpio/src/_malloc.h | 26 - tools/cpio/src/_utmpx.h | 89 - tools/cpio/src/asciitype.c | 59 - tools/cpio/src/asciitype.h | 60 - tools/cpio/src/atoll.h | 8 - tools/cpio/src/blank.h | 38 - tools/cpio/src/blast.c | 449 --- tools/cpio/src/blast.h | 76 - tools/cpio/src/cpio.1 | 943 ----- tools/cpio/src/cpio.c | 7172 --------------------------------- tools/cpio/src/cpio.h | 232 -- tools/cpio/src/crc32.c | 115 - tools/cpio/src/expand.c | 193 - tools/cpio/src/explode.c | 1138 ------ tools/cpio/src/flags.c | 257 -- tools/cpio/src/getdir.c | 197 - tools/cpio/src/getdir.h | 33 - tools/cpio/src/getopt.c | 141 - tools/cpio/src/gmatch.c | 136 - tools/cpio/src/ib_alloc.c | 60 - tools/cpio/src/ib_close.c | 36 - tools/cpio/src/ib_free.c | 33 - tools/cpio/src/ib_getlin.c | 78 - tools/cpio/src/ib_getw.c | 81 - tools/cpio/src/ib_open.c | 48 - tools/cpio/src/ib_popen.c | 87 - tools/cpio/src/ib_read.c | 51 - tools/cpio/src/ib_seek.c | 53 - tools/cpio/src/iblok.h | 135 - tools/cpio/src/inflate.c | 991 ----- tools/cpio/src/mbtowi.h | 22 - tools/cpio/src/memalign.c | 51 - tools/cpio/src/memalign.h | 35 - tools/cpio/src/msgselect.h | 30 - tools/cpio/src/nonpax.c | 55 - tools/cpio/src/oblok.c | 260 -- tools/cpio/src/oblok.h | 96 - tools/cpio/src/pathconf.c | 51 - tools/cpio/src/pathconf.h | 29 - tools/cpio/src/pax.1 | 919 ----- tools/cpio/src/pax.c | 757 ---- tools/cpio/src/pfmt.c | 39 - tools/cpio/src/pfmt.h | 46 - tools/cpio/src/pfmt_label.c | 1 - tools/cpio/src/regexp.h | 1211 ------ tools/cpio/src/regexpr.c | 90 - tools/cpio/src/regexpr.h | 53 - tools/cpio/src/setlabel.c | 40 - tools/cpio/src/setuxlabel.c | 47 - tools/cpio/src/sfile.c | 99 - tools/cpio/src/sfile.h | 40 - tools/cpio/src/sighold.c | 42 - tools/cpio/src/sigignore.c | 45 - tools/cpio/src/signal.c | 46 - tools/cpio/src/sigpause.c | 48 - tools/cpio/src/sigrelse.c | 42 - tools/cpio/src/sigset.c | 57 - tools/cpio/src/sigset.h | 40 - tools/cpio/src/strtol.c | 117 - tools/cpio/src/unshrink.c | 307 -- tools/cpio/src/unzip.h | 121 - tools/cpio/src/utmpx.c | 252 -- tools/cpio/src/version.c | 26 - tools/cpio/src/vpfmt.c | 90 - tools/flex/Makefile | 25 - tools/genext2fs/Makefile | 25 - tools/lzma/Makefile | 25 - tools/lzo/Makefile | 28 - tools/lzop/Makefile | 30 - tools/m4/Makefile | 25 - tools/mkcrypt/Makefile | 11 - tools/mkcrypt/mkcrypt.c | 441 -- tools/mkfimage/Makefile | 4 - tools/mkfimage/mkfimage.c | 72 - tools/mkimage/Makefile | 11 - tools/mkimage/crc32.c | 200 - tools/mkimage/image.h | 161 - tools/mkimage/mkimage | Bin 23424 -> 0 bytes tools/mkimage/mkimage.c | 755 ---- tools/mksh/Makefile | 29 - tools/mtd-utils/Makefile | 24 - tools/mtd-utils/patches/darwin.patch | 261 -- tools/mtd-utils/patches/lzo.patch | 88 - tools/pcre/Makefile | 30 - tools/rules.mk | 7 - tools/squashfs/Makefile | 29 - tools/squashfs/patches/cppflags.patch | 12 - tools/squashfs/patches/darwin.patch | 88 - tools/srec2bin/Makefile | 4 - tools/srec2bin/srec2bin.c | 521 --- tools/syslinux/Makefile | 37 - tools/trx/Makefile | 4 - tools/trx/trx.c | 366 -- tools/xz/Makefile | 28 - 112 files changed, 24937 deletions(-) delete mode 100644 tools/Makefile delete mode 100644 tools/addpattern/Makefile delete mode 100644 tools/addpattern/addpattern.c delete mode 100644 tools/adk/Makefile delete mode 100644 tools/adk/depmaker.c delete mode 100644 tools/adk/dkgetsz.c delete mode 100644 tools/adk/pkgmaker.c delete mode 100644 tools/adk/pkgrebuild.c delete mode 100644 tools/adk/sortfile.c delete mode 100644 tools/adk/sortfile.h delete mode 100644 tools/adk/strmap.c delete mode 100644 tools/adk/strmap.h delete mode 100644 tools/bc/Makefile delete mode 100644 tools/bzip2/Makefile delete mode 100644 tools/ccache/Makefile delete mode 100644 tools/cdrtools/Makefile delete mode 100644 tools/cpio/Makefile delete mode 100644 tools/cpio/src/_alloca.h delete mode 100644 tools/cpio/src/_malloc.h delete mode 100644 tools/cpio/src/_utmpx.h delete mode 100644 tools/cpio/src/asciitype.c delete mode 100644 tools/cpio/src/asciitype.h delete mode 100644 tools/cpio/src/atoll.h delete mode 100644 tools/cpio/src/blank.h delete mode 100644 tools/cpio/src/blast.c delete mode 100644 tools/cpio/src/blast.h delete mode 100644 tools/cpio/src/cpio.1 delete mode 100644 tools/cpio/src/cpio.c delete mode 100644 tools/cpio/src/cpio.h delete mode 100644 tools/cpio/src/crc32.c delete mode 100644 tools/cpio/src/expand.c delete mode 100644 tools/cpio/src/explode.c delete mode 100644 tools/cpio/src/flags.c delete mode 100644 tools/cpio/src/getdir.c delete mode 100644 tools/cpio/src/getdir.h delete mode 100644 tools/cpio/src/getopt.c delete mode 100644 tools/cpio/src/gmatch.c delete mode 100644 tools/cpio/src/ib_alloc.c delete mode 100644 tools/cpio/src/ib_close.c delete mode 100644 tools/cpio/src/ib_free.c delete mode 100644 tools/cpio/src/ib_getlin.c delete mode 100644 tools/cpio/src/ib_getw.c delete mode 100644 tools/cpio/src/ib_open.c delete mode 100644 tools/cpio/src/ib_popen.c delete mode 100644 tools/cpio/src/ib_read.c delete mode 100644 tools/cpio/src/ib_seek.c delete mode 100644 tools/cpio/src/iblok.h delete mode 100644 tools/cpio/src/inflate.c delete mode 100644 tools/cpio/src/mbtowi.h delete mode 100644 tools/cpio/src/memalign.c delete mode 100644 tools/cpio/src/memalign.h delete mode 100644 tools/cpio/src/msgselect.h delete mode 100644 tools/cpio/src/nonpax.c delete mode 100644 tools/cpio/src/oblok.c delete mode 100644 tools/cpio/src/oblok.h delete mode 100644 tools/cpio/src/pathconf.c delete mode 100644 tools/cpio/src/pathconf.h delete mode 100644 tools/cpio/src/pax.1 delete mode 100644 tools/cpio/src/pax.c delete mode 100644 tools/cpio/src/pfmt.c delete mode 100644 tools/cpio/src/pfmt.h delete mode 100644 tools/cpio/src/pfmt_label.c delete mode 100644 tools/cpio/src/regexp.h delete mode 100644 tools/cpio/src/regexpr.c delete mode 100644 tools/cpio/src/regexpr.h delete mode 100644 tools/cpio/src/setlabel.c delete mode 100644 tools/cpio/src/setuxlabel.c delete mode 100644 tools/cpio/src/sfile.c delete mode 100644 tools/cpio/src/sfile.h delete mode 100644 tools/cpio/src/sighold.c delete mode 100644 tools/cpio/src/sigignore.c delete mode 100644 tools/cpio/src/signal.c delete mode 100644 tools/cpio/src/sigpause.c delete mode 100644 tools/cpio/src/sigrelse.c delete mode 100644 tools/cpio/src/sigset.c delete mode 100644 tools/cpio/src/sigset.h delete mode 100644 tools/cpio/src/strtol.c delete mode 100644 tools/cpio/src/unshrink.c delete mode 100644 tools/cpio/src/unzip.h delete mode 100644 tools/cpio/src/utmpx.c delete mode 100644 tools/cpio/src/version.c delete mode 100644 tools/cpio/src/vpfmt.c delete mode 100644 tools/flex/Makefile delete mode 100644 tools/genext2fs/Makefile delete mode 100644 tools/lzma/Makefile delete mode 100644 tools/lzo/Makefile delete mode 100644 tools/lzop/Makefile delete mode 100644 tools/m4/Makefile delete mode 100644 tools/mkcrypt/Makefile delete mode 100644 tools/mkcrypt/mkcrypt.c delete mode 100644 tools/mkfimage/Makefile delete mode 100644 tools/mkfimage/mkfimage.c delete mode 100644 tools/mkimage/Makefile delete mode 100644 tools/mkimage/crc32.c delete mode 100644 tools/mkimage/image.h delete mode 100755 tools/mkimage/mkimage delete mode 100644 tools/mkimage/mkimage.c delete mode 100644 tools/mksh/Makefile delete mode 100644 tools/mtd-utils/Makefile delete mode 100644 tools/mtd-utils/patches/darwin.patch delete mode 100644 tools/mtd-utils/patches/lzo.patch delete mode 100644 tools/pcre/Makefile delete mode 100644 tools/rules.mk delete mode 100644 tools/squashfs/Makefile delete mode 100644 tools/squashfs/patches/cppflags.patch delete mode 100644 tools/squashfs/patches/darwin.patch delete mode 100644 tools/srec2bin/Makefile delete mode 100644 tools/srec2bin/srec2bin.c delete mode 100644 tools/syslinux/Makefile delete mode 100644 tools/trx/Makefile delete mode 100644 tools/trx/trx.c delete mode 100644 tools/xz/Makefile (limited to 'tools') diff --git a/tools/Makefile b/tools/Makefile deleted file mode 100644 index bfed325e0..000000000 --- a/tools/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# This file is part of the OpenADK project. OpenADK is copyrighted -# material, please see the LICENCE file in the top-level directory. - -include $(TOPDIR)/rules.mk - -TARGETS:=adk mksh mkcrypt cpio m4 flex bc bzip2 xz - -ifeq ($(ADK_HOST_NEED_GENEXT2FS),y) -TARGETS+=genext2fs -endif -ifeq ($(ADK_HOST_NEED_MKIMAGE),y) -TARGETS+=mkimage -endif -ifeq ($(ADK_HOST_NEED_MKISOFS),y) -TARGETS+=cdrtools -endif -ifeq ($(ADK_HOST_NEED_SYSLINUX),y) -TARGETS+=syslinux -endif -ifeq ($(ADK_HOST_NEED_JFFS2),y) -TARGETS+=mtd-utils -endif -ifeq ($(ADK_HOST_NEED_SQUASHFS),y) -TARGETS+=squashfs -endif -ifeq ($(ADK_HOST_NEED_LZOP),y) -TARGETS+=lzo lzop -endif -ifeq ($(ADK_HOST_NEED_LZMA),y) -TARGETS+=lzma -endif -ifeq ($(ADK_HOST_NEED_CCACHE),y) -TARGETS+=ccache -endif -ifeq ($(ADK_HOST_NEED_PCRE),y) -TARGETS+=pcre -endif - -TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS)) -TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS)) - -all: install -compile: -install: $(TARGETS_INSTALL) -clean: $(TARGETS_CLEAN) - -%-compile: $(TOOLS_BUILD_DIR) - $(TRACE) "tools/$(patsubst %-compile,%,$@)/compile " - $(MAKE) -C $(patsubst %-compile,%,$@) compile $(MAKE_TRACE) - -%-install: - $(TRACE) "tools/$(patsubst %-install,%,$@)/install " - $(MAKE) -C $(patsubst %-install,%,$@) install $(MAKE_TRACE) - -%-clean: - $(TRACE) "tools/$(patsubst %-clean,%,$@)/clean " - $(MAKE) -C $(patsubst %-clean,%,$@) clean diff --git a/tools/addpattern/Makefile b/tools/addpattern/Makefile deleted file mode 100644 index 10ba05933..000000000 --- a/tools/addpattern/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include $(TOPDIR)/rules.mk - -all: addpattern.c - $(CC_FOR_BUILD) $(FLAGS_FOR_BUILD) -o ${STAGING_HOST_DIR}/usr/bin/addpattern addpattern.c diff --git a/tools/addpattern/addpattern.c b/tools/addpattern/addpattern.c deleted file mode 100644 index 8133bf26e..000000000 --- a/tools/addpattern/addpattern.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (C) 2004 Manuel Novoa III - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* July 29, 2004 - * - * This is a hacked replacement for the 'addpattern' utility used to - * create wrt54g .bin firmware files. It isn't pretty, but it does - * the job for me. - * - * Extensions: - * -v allows setting the version string on the command line. - * -{0|1} sets the (currently ignored) hw_ver flag in the header - * to 0 or 1 respectively. - */ - -/* January 12, 2005 - * - * Modified by rodent at rodent dot za dot net - * Support added for the new WRT54G v2.2 and WRT54GS v1.1 "flags" - * Without the flags set to 0x7, the above units will refuse to flash. - * - * Extensions: - * -{0|1|2} sets {0|1} sets hw_ver flag to 0/1. {2} sets hw_ver to 1 - * and adds the new hardware "flags" for the v2.2/v1.1 units -*/ - -/* January 1, 2007 - * - * Modified by juan.i.gonzalez at subdown dot net - * Support added for the AG241v2 and similar - * - * Extensions: - * -r #.# adds revision hardware flags. AG241v2 and similar. - * - * AG241V2 firmware sets the hw_ver to 0x44. - * - * Example: -r 2.0 - * - * Convert 2.0 to 20 to be an integer, and add 0x30 to skip special ASCII - * #define HW_Version ((HW_REV * 10) + 0x30) -> from cyutils.h -*/ - -#include -#include -#include -#include -#include -#include - -/**********************************************************************/ - -#define CODE_ID "U2ND" /* from code_pattern.h */ -#define CODE_PATTERN "W54S" /* from code_pattern.h */ -#define PBOT_PATTERN "PBOT" - -#define CYBERTAN_VERSION "v3.37.2" /* from cyutils.h */ - -/* WRT54G v2.2 and WRT54GS v1.1 "flags" (from 3.37.32 firmware cyutils.h) */ -#define SUPPORT_4712_CHIP 0x0001 -#define SUPPORT_INTEL_FLASH 0x0002 -#define SUPPORT_5325E_SWITCH 0x0004 - -struct code_header { /* from cyutils.h */ - char magic[4]; - char res1[4]; /* for extra magic */ - char fwdate[3]; - char fwvern[3]; - char id[4]; /* U2ND */ - char hw_ver; /* 0: for 4702, 1: for 4712 -- new in 2.04.3 */ - char unused; - unsigned char flags[2]; /* SUPPORT_ flags new for 3.37.2 (WRT54G v2.2 and WRT54GS v1.1) */ - unsigned char res2[10]; -} ; - -/**********************************************************************/ - -void usage(void) __attribute__ (( __noreturn__ )); - -void usage(void) -{ - fprintf(stderr, "Usage: addpattern [-i trxfile] [-o binfile] [-p pattern] [-g] [-b] [-v v#.#.#] [-r #.#] [-{0|1|2|4}] -h\n"); - exit(EXIT_FAILURE); -} - -int main(int argc, char **argv) -{ - char buf[1024]; /* keep this at 1k or adjust garbage calc below */ - struct code_header *hdr; - FILE *in = stdin; - FILE *out = stdout; - char *ifn = NULL; - char *ofn = NULL; - char *pattern = CODE_PATTERN; - char *pbotpat = PBOT_PATTERN; - char *version = CYBERTAN_VERSION; - int gflag = 0; - int pbotflag = 0; - int c; - int v0, v1, v2; - size_t off, n; - time_t t; - struct tm *ptm; - - hdr = (struct code_header *) buf; - memset(hdr, 0, sizeof(struct code_header)); - - while ((c = getopt(argc, argv, "i:o:p:gbv:0124hr:")) != -1) { - switch (c) { - case 'i': - ifn = optarg; - break; - case 'o': - ofn = optarg; - break; - case 'p': - pattern = optarg; - break; - case 'g': - gflag = 1; - break; - case 'b': - pbotflag = 1; - break; - case 'v': /* extension to allow setting version */ - version = optarg; - break; - case '0': - hdr->hw_ver = 0; - break; - case '1': - hdr->hw_ver = 1; - break; - case '2': /* new 54G v2.2 and 54GS v1.1 flags */ - hdr->hw_ver = 1; - hdr->flags[0] |= SUPPORT_4712_CHIP; - hdr->flags[0] |= SUPPORT_INTEL_FLASH; - hdr->flags[0] |= SUPPORT_5325E_SWITCH; - break; - case '4': - /* V4 firmware sets the flags to 0x1f */ - hdr->hw_ver = 0; - hdr->flags[0] = 0x1f; - break; - case 'r': - hdr->hw_ver = (char)(atof(optarg)*10)+0x30; - break; - - case 'h': - default: - usage(); - } - } - - if (optind != argc || optind == 1) { - fprintf(stderr, "illegal arg \"%s\"\n", argv[optind]); - usage(); - } - - if (strlen(pattern) != 4) { - fprintf(stderr, "illegal pattern \"%s\": length != 4\n", pattern); - usage(); - } - - if (ifn && !(in = fopen(ifn, "r"))) { - fprintf(stderr, "can not open \"%s\" for reading\n", ifn); - usage(); - } - - if (ofn && !(out = fopen(ofn, "w"))) { - fprintf(stderr, "can not open \"%s\" for writing\n", ofn); - usage(); - } - - if (time(&t) == (time_t)(-1)) { - fprintf(stderr, "time call failed\n"); - return EXIT_FAILURE; - } - - ptm = localtime(&t); - - if (3 != sscanf(version, "v%d.%d.%d", &v0, &v1, &v2)) { - fprintf(stderr, "bad version string \"%s\"\n", version); - return EXIT_FAILURE; - } - - memcpy(&hdr->magic, pattern, 4); - if (pbotflag) - memcpy(&hdr->res1, pbotpat, 4); - hdr->fwdate[0] = ptm->tm_year % 100; - hdr->fwdate[1] = ptm->tm_mon + 1; - hdr->fwdate[2] = ptm->tm_mday; - hdr->fwvern[0] = v0; - hdr->fwvern[1] = v1; - hdr->fwvern[2] = v2; - memcpy(&hdr->id, CODE_ID, strlen(CODE_ID)); - - off = sizeof(struct code_header); - - fprintf(stderr, "writing firmware v%d.%d.%d on %d/%d/%d (y/m/d)\n", - v0, v1, v2, - hdr->fwdate[0], hdr->fwdate[1], hdr->fwdate[2]); - - - while ((n = fread(buf + off, 1, sizeof(buf)-off, in) + off) > 0) { - off = 0; - if (n < sizeof(buf)) { - if (ferror(in)) { - FREAD_ERROR: - fprintf(stderr, "fread error\n"); - return EXIT_FAILURE; - } - if (gflag) { - gflag = sizeof(buf) - n; - memset(buf + n, 0xff, gflag); - n = sizeof(buf); - } - } - if (!fwrite(buf, n, 1, out)) { - FWRITE_ERROR: - fprintf(stderr, "fwrite error\n"); - return EXIT_FAILURE; - } - } - - if (ferror(in)) { - goto FREAD_ERROR; - } - - if (fflush(out)) { - goto FWRITE_ERROR; - } - - fclose(in); - fclose(out); - - return EXIT_SUCCESS; -} diff --git a/tools/adk/Makefile b/tools/adk/Makefile deleted file mode 100644 index edd559f85..000000000 --- a/tools/adk/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# This file is part of the OpenADK project. OpenADK is copyrighted -# material, please see the LICENCE file in the top-level directory. - -include $(TOPDIR)/rules.mk - -install: ${STAGING_HOST_DIR}/usr/bin/depmaker ${STAGING_HOST_DIR}/usr/bin/pkgrebuild ${STAGING_HOST_DIR}/usr/bin/dkgetsz - -${STAGING_HOST_DIR}/usr/bin/depmaker: depmaker.c - ${CC_FOR_BUILD} ${FLAGS_FOR_BUILD} -o $@ depmaker.c - -${STAGING_HOST_DIR}/usr/bin/pkgrebuild: pkgrebuild.c strmap.c - ${CC_FOR_BUILD} ${FLAGS_FOR_BUILD} -o $@ pkgrebuild.c strmap.c - -${STAGING_HOST_DIR}/usr/bin/dkgetsz: dkgetsz.c - ${CC_FOR_BUILD} ${FLAGS_FOR_BUILD} -o $@ dkgetsz.c - -include $(TOPDIR)/mk/tools.mk diff --git a/tools/adk/depmaker.c b/tools/adk/depmaker.c deleted file mode 100644 index 023e58504..000000000 --- a/tools/adk/depmaker.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - * depmaker - create package/Depends.mk for OpenADK buildsystem - * - * Copyright (C) 2010-2014 Waldemar Brodkorb - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -#define MAXLINE 1024 -#define MAXPATH 128 - -static int prefix = 0; -static int hprefix = 0; - -static int check_symbol(char *symbol) { - - FILE *config; - char buf[MAXLINE]; - char *sym; - int ret; - - if ((sym = malloc(strlen(symbol) + 2)) != NULL) - memset(sym, 0, strlen(symbol) + 2); - else { - perror("Can not allocate memory."); - exit(EXIT_FAILURE); - } - - strncat(sym, symbol, strlen(symbol)); - strncat(sym, "=", 1); - if ((config = fopen(".config", "r")) == NULL) { - perror("Can not open file \".config\"."); - exit(EXIT_FAILURE); - } - - ret = 1; - while (fgets(buf, MAXLINE, config) != NULL) { - if (strncmp(buf, sym, strlen(sym)) == 0) - ret = 0; - } - - free(sym); - if (fclose(config) != 0) - perror("Closing file stream failed"); - - return(ret); -} - -/*@null@*/ -static char *parse_line(char *package, char *pkgvar, char *string, int checksym, int pprefix, int system, int *prefixp) { - - char *key, *value, *dep, *key_sym, *pkgdeps; - char temp[MAXLINE]; - - string[strlen(string)-1] = '\0'; - if ((key = strtok(string, ":=")) == NULL) { - perror("Can not get key from string."); - exit(EXIT_FAILURE); - } - - if (checksym == 1) { - /* extract symbol */ - if ((key_sym = malloc(MAXLINE)) != NULL) - memset(key_sym, 0, MAXLINE); - else { - perror("Can not allocate memory."); - exit(EXIT_FAILURE); - } - if (system == 0) { - if (pprefix == 0) { - if (snprintf(key_sym, MAXLINE, "ADK_PACKAGE_%s_", pkgvar) < 0) - perror("Can not create string variable."); - } else { - if (snprintf(key_sym, MAXLINE, "ADK_PACKAGE_") < 0) - perror("Can not create string variable."); - } - strncat(key_sym, key+6, strlen(key)-6); - } else { - if (snprintf(key_sym, MAXLINE, "ADK_TARGET_SYSTEM_%s", pkgvar) < 0) - perror("Can not create string variable."); - } - - if (check_symbol(key_sym) != 0) { - free(key_sym); - return(NULL); - } - free(key_sym); - } - - if ((pkgdeps = malloc(MAXLINE)) != NULL) - memset(pkgdeps, 0, MAXLINE); - else { - perror("Can not allocate memory."); - exit(EXIT_FAILURE); - } - - value = strtok(NULL, "=\t"); - dep = strtok(value, " "); - while (dep != NULL) { - if (*prefixp == 0) { - *prefixp = 1; - if (snprintf(temp, MAXLINE, "%s-compile: %s-compile", package, dep) < 0) - perror("Can not create string variable."); - } else { - if (snprintf(temp, MAXLINE, " %s-compile", dep) < 0) - perror("Can not create string variable."); - } - strncat(pkgdeps, temp, strlen(temp)); - dep = strtok(NULL, " "); - } - return(pkgdeps); -} - -int main() { - - DIR *pkgdir; - struct dirent *pkgdirp; - FILE *pkg; - char buf[MAXLINE]; - char path[MAXPATH]; - char *string, *pkgvar, *pkgdeps, *hpkgdeps = NULL, *tmp, *fpkg, *cpkg, *spkg, *key, *check, *dpkg; - char *stringtmp; - int i; - - spkg = NULL; - cpkg = NULL; - fpkg = NULL; - - /* read Makefile's for all packages */ - pkgdir = opendir("package"); - while ((pkgdirp = readdir(pkgdir)) != NULL) { - /* skip dotfiles */ - if (strncmp(pkgdirp->d_name, ".", 1) > 0) { - if (snprintf(path, MAXPATH, "package/%s/Makefile", pkgdirp->d_name) < 0) - perror("Can not create string variable."); - pkg = fopen(path, "r"); - if (pkg == NULL) - continue; - - /* transform to uppercase variable name */ - pkgvar = strdup(pkgdirp->d_name); - for (i=0; i<(int)strlen(pkgvar); i++) { - if (pkgvar[i] == '+') - pkgvar[i] = 'X'; - if (pkgvar[i] == '-') - pkgvar[i] = '_'; - pkgvar[i] = toupper(pkgvar[i]); - } - - /* exclude manual maintained packages from package/Makefile */ - if ( - !(strncmp(pkgdirp->d_name, "libpthread", 10) == 0 && strlen(pkgdirp->d_name) == 10) && - !(strncmp(pkgdirp->d_name, "uclibc++", 8) == 0) && - !(strncmp(pkgdirp->d_name, "uclibc", 6) == 0) && - !(strncmp(pkgdirp->d_name, "musl", 4) == 0) && - !(strncmp(pkgdirp->d_name, "glibc", 5) == 0)) { - /* print result to stdout */ - printf("package-$(ADK_COMPILE_%s) += %s\n", pkgvar, pkgdirp->d_name); - } - - if ((pkgdeps = malloc(MAXLINE)) != NULL) - memset(pkgdeps, 0, MAXLINE); - else { - perror("Can not allocate memory."); - exit(EXIT_FAILURE); - } - prefix = 0; - hprefix = 0; - - /* generate build dependencies */ - while (fgets(buf, MAXLINE, pkg) != NULL) { - if ((tmp = malloc(MAXLINE)) != NULL) - memset(tmp, 0 , MAXLINE); - else { - perror("Can not allocate memory."); - exit(EXIT_FAILURE); - } - - /* just read variables prefixed with PKG */ - if (strncmp(buf, "PKG", 3) == 0) { - - string = strstr(buf, "PKG_BUILDDEP:="); - if (string != NULL) { - tmp = parse_line(pkgdirp->d_name, pkgvar, string, 0, 0, 0, &prefix); - if (tmp != NULL) { - strncat(pkgdeps, tmp, strlen(tmp)); - } - } - - string = strstr(buf, "PKG_BUILDDEP+="); - if (string != NULL) { - tmp = parse_line(pkgdirp->d_name, pkgvar, string, 0, 0, 0, &prefix); - if (tmp != NULL) - strncat(pkgdeps, tmp, strlen(tmp)); - } - - // We need to find the system name here - string = strstr(buf, "PKG_BUILDDEP_"); - if (string != NULL) { - check = strstr(buf, ":="); - if (check != NULL) { - stringtmp = strdup(string); - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - dpkg = strdup(key+13); - tmp = parse_line(pkgdirp->d_name, dpkg, stringtmp, 1, 0, 1, &prefix); - if (tmp != NULL) - strncat(pkgdeps, tmp, strlen(tmp)); - } - } - - // We need to find the subpackage name here - string = strstr(buf, "PKG_FLAVOURS_"); - if (string != NULL) { - check = strstr(buf, ":="); - if (check != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - fpkg = strdup(key+13); - } - } - - string = strstr(buf, "PKGFB_"); - if (string != NULL) { - tmp = parse_line(pkgdirp->d_name, fpkg, string, 1, 0, 0, &prefix); - if (tmp != NULL) - strncat(pkgdeps, tmp, strlen(tmp)); - } - - // We need to find the subpackage name here - string = strstr(buf, "PKG_CHOICES_"); - if (string != NULL) { - check = strstr(buf, ":="); - if (check != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - cpkg = strdup(key+12); - } - } - string = strstr(buf, "PKGCB_"); - if (string != NULL) { - tmp = parse_line(pkgdirp->d_name, cpkg, string, 1, 0, 0, &prefix); - if (tmp != NULL) - strncat(pkgdeps, tmp, strlen(tmp)); - } - - // We need to find the subpackage name here - string = strstr(buf, "PKG_SUBPKGS_"); - if (string != NULL) { - check = strstr(buf, ":="); - if (check != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - spkg = strdup(key+12); - } - } - - string = strstr(buf, "PKGSB_"); - if (string != NULL) { - tmp = parse_line(pkgdirp->d_name, spkg, string, 1, 1, 0, &prefix); - if (tmp != NULL) { - strncat(pkgdeps, tmp, strlen(tmp)); - } - } - } else if (strncmp(buf, "HOST_BUILDDEP", 13) == 0) { - asprintf(&string, "%s-host", pkgdirp->d_name); - // check retval; string for NULL - tmp = parse_line(string, NULL, buf, 0, 0, 0, &hprefix); - if (tmp && *tmp) { - asprintf(&string, "%s%s", - hpkgdeps ? hpkgdeps : "", - tmp); - free(hpkgdeps); - hpkgdeps = string; - } - } - free(tmp); - } - if (strlen(pkgdeps) != 0) - printf("%s\n", pkgdeps); - if (hpkgdeps && *hpkgdeps) - printf("%s\n", hpkgdeps); - free(hpkgdeps); - hpkgdeps = NULL; - free(pkgdeps); - free(pkgvar); - if (fclose(pkg) != 0) - perror("Closing file stream failed"); - } - } - if (closedir(pkgdir) != 0) - perror("Closing directory stream failed"); - - return(0); -} diff --git a/tools/adk/dkgetsz.c b/tools/adk/dkgetsz.c deleted file mode 100644 index b8315be70..000000000 --- a/tools/adk/dkgetsz.c +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright © 2010 - * Waldemar Brodkorb - * Thorsten Glaser - * - * Provided that these terms and disclaimer and all copyright notices - * are retained or reproduced in an accompanying document, permission - * is granted to deal in this work without restriction, including un‐ - * limited rights to use, publicly perform, distribute, sell, modify, - * merge, give away, or sublicence. - * - * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to - * the utmost extent permitted by applicable law, neither express nor - * implied; without malicious intent or gross negligence. In no event - * may a licensor, author or contributor be held liable for indirect, - * direct, other damage, loss, or other issues arising in any way out - * of dealing in the work, even if advised of the possibility of such - * damage or existence of a defect, except proven that it results out - * of said person’s immediate fault when using the work as intended. - * - * Alternatively, this work may be distributed under the terms of the - * General Public License, any version, as published by the Free Soft- - * ware Foundation. - *- - * Display the size of a block device (e.g. USB stick, CF/SF/MMC card - * or hard disc) in 512-byte sectors. - */ - -#define _FILE_OFFSET_BITS 64 - -#include -#include -#include -#include - -#if defined(__APPLE__) -#include -#endif - -#if defined(DIOCGDINFO) -#include -#endif - -#include -#include -#include -#include - -unsigned long long numsecs(int); - -int -main(int argc, char *argv[]) { - int fd; - - if (argc != 2) - errx(255, "Syntax: dkgetsz /dev/sda"); - - if ((fd = open(argv[1], O_RDONLY)) == -1) - err(1, "open"); - printf("%llu\n", numsecs(fd)); - close(fd); - return (0); -} - -unsigned long long -numsecs(int fd) -{ -#if defined(BLKGETSIZE) || defined(DKIOCGETBLOCKCOUNT) -/* - * note: BLKGETSIZE64 returns bytes, not sectors, but the return - * type is size_t which is 32 bits on an ILP32 platform, so it - * fails interestingly here… thus we use BLKGETSIZE instead. - */ -#if defined(DKIOCGETBLOCKCOUNT) - uint64_t nsecs; -#define THEIOCTL DKIOCGETBLOCKCOUNT -#define STRIOCTL "DKIOCGETBLOCKCOUNT" -#else - unsigned long nsecs; -#define THEIOCTL BLKGETSIZE -#define STRIOCTL "BLKGETSIZE" -#endif - if (ioctl(fd, THEIOCTL, &nsecs) == -1) - err(1, "ioctl %s", STRIOCTL); - return ((unsigned long long)nsecs); -#elif defined(DIOCGDINFO) - struct disklabel dl; - - if (ioctl(fd, DIOCGDINFO, &dl) == -1) - err(1, "ioctl DIOCGDINFO"); - return ((unsigned long long)dl.d_secperunit); -#else -#warning PLEASE DO IMPLEMENT numsecs FOR THIS PLATFORM. -#endif -} diff --git a/tools/adk/pkgmaker.c b/tools/adk/pkgmaker.c deleted file mode 100644 index 51d31aa70..000000000 --- a/tools/adk/pkgmaker.c +++ /dev/null @@ -1,1194 +0,0 @@ -/* - * pkgmaker - create package meta-data for OpenADK buildsystem - * - * Copyright (C) 2010-2014 Waldemar Brodkorb - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sortfile.h" -#include "strmap.h" - -#define MAXLINE 4096 -#define MAXVALUE 168 -#define MAXVAR 64 -#define MAXPATH 320 -#define HASHSZ 96 - -static int nobinpkgs; - -#define fatal_error(...) { \ - fprintf(stderr, "Fatal error. "); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - exit(1); \ -} - -static int parse_var_hash(char *buf, const char *varname, StrMap *strmap) { - - char *key, *value, *string; - - string = strstr(buf, varname); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - value = strtok(NULL, "=\t"); - if (value != NULL) - strmap_put(strmap, key, value); - return(0); - } - return(1); -} - -static int parse_var(char *buf, const char *varname, char *pvalue, char **result) { - - char *pkg_var; - char *key, *value, *string; - char pkg_str[MAXVAR]; - - if ((pkg_var = malloc(MAXLINE)) != NULL) - memset(pkg_var, 0, MAXLINE); - else { - perror("Can not allocate memory"); - exit(EXIT_FAILURE); - } - - if (snprintf(pkg_str, MAXVAR, "%s:=", varname) < 0) - perror("can not create path variable."); - string = strstr(buf, pkg_str); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - value = strtok(NULL, "=\t"); - if (value != NULL) { - strncat(pkg_var, value, strlen(value)); - *result = strdup(pkg_var); - } else { - nobinpkgs = 1; - *result = NULL; - } - free(pkg_var); - return(0); - } else { - if (snprintf(pkg_str, MAXVAR, "%s+=", varname) < 0) - perror("can not create path variable."); - string = strstr(buf, pkg_str); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, "+="); - value = strtok(NULL, "=\t"); - if (pvalue != NULL) - strncat(pkg_var, pvalue, strlen(pvalue)); - strncat(pkg_var, " ", 1); - if (value != NULL) - strncat(pkg_var, value, strlen(value)); - *result = strdup(pkg_var); - free(pkg_var); - return(0); - } - } - free(pkg_var); - return(1); -} - -static int parse_var_with_system(char *buf, const char *varname, char *pvalue, char **result, char **sysname, int varlen) { - - char *pkg_var, *check; - char *key, *value, *string; - - if ((pkg_var = malloc(MAXLINE)) != NULL) - memset(pkg_var, 0, MAXLINE); - else { - perror("Can not allocate memory"); - exit(EXIT_FAILURE); - } - - check = strstr(buf, ":="); - if (check != NULL) { - string = strstr(buf, varname); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - *sysname = strdup(key+varlen); - value = strtok(NULL, "=\t"); - if (value != NULL) { - strncat(pkg_var, value, strlen(value)); - *result = strdup(pkg_var); - } - free(pkg_var); - return(0); - } - } else { - string = strstr(buf, varname); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, "+="); - value = strtok(NULL, "=\t"); - if (pvalue != NULL) - strncat(pkg_var, pvalue, strlen(pvalue)); - strncat(pkg_var, " ", 1); - if (value != NULL) - strncat(pkg_var, value, strlen(value)); - *result = strdup(pkg_var); - free(pkg_var); - return(0); - } - } - free(pkg_var); - return(1); -} - -static int parse_var_with_pkg(char *buf, const char *varname, char *pvalue, char **result, char **pkgname, int varlen) { - - char *pkg_var, *check; - char *key, *value, *string; - - if ((pkg_var = malloc(MAXLINE)) != NULL) - memset(pkg_var, 0, MAXLINE); - else { - perror("Can not allocate memory"); - exit(EXIT_FAILURE); - } - - check = strstr(buf, ":="); - if (check != NULL) { - string = strstr(buf, varname); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, ":="); - *pkgname = strdup(key+varlen); - value = strtok(NULL, "=\t"); - if (value != NULL) { - strncat(pkg_var, value, strlen(value)); - *result = strdup(pkg_var); - } - free(pkg_var); - return(0); - } - } else { - string = strstr(buf, varname); - if (string != NULL) { - string[strlen(string)-1] = '\0'; - key = strtok(string, "+="); - value = strtok(NULL, "=\t"); - if (pvalue != NULL) - strncat(pkg_var, pvalue, strlen(pvalue)); - strncat(pkg_var, " ", 1); - if (value != NULL) - strncat(pkg_var, value, strlen(value)); - *result = strdup(pkg_var); - free(pkg_var); - return(0); - } - } - free(pkg_var); - return(1); -} - -#if 0 -static void iter_debug(const char *key, const char *value, const void *obj) { - fprintf(stderr, "HASHMAP key: %s value: %s\n", key, value); -} -#endif - -static int hash_str(char *string) { - - int i; - int hash; - - hash = 0; - for (i=0; i<(int)strlen(string); i++) { - hash += string[i]; - } - return(hash); -} - -static void iter(const char *key, const char *value, const void *obj) { - - FILE *config, *section; - int hash; - char *valuestr, *pkg, *subpkg; - char buf[MAXPATH]; - char infile[MAXPATH]; - char outfile[MAXPATH]; - - valuestr = strdup(value); - config = fopen("package/Config.in.auto", "a"); - if (config == NULL) - fatal_error("Can not open file package/Config.in.auto"); - - hash = hash_str(valuestr); - snprintf(infile, MAXPATH, "package/pkglist.d/sectionlst.%d", hash); - snprintf(outfile, MAXPATH, "package/pkglist.d/sectionlst.%d.sorted", hash); - - if (access(infile, F_OK) == 0) { - valuestr[strlen(valuestr)-1] = '\0'; - fprintf(config, "menu \"%s\"\n", valuestr); - sortfile(infile, outfile); - /* avoid duplicate section entries */ - unlink(infile); - section = fopen(outfile, "r"); - while (fgets(buf, MAXPATH, section) != NULL) { - buf[strlen(buf)-1] = '\0'; - if (buf[strlen(buf)-1] == '@') { - buf[strlen(buf)-1] = '\0'; - fprintf(config, "source \"package/%s/Config.in.manual\"\n", buf); - } else { - subpkg = strtok(buf, "|"); - subpkg[strlen(subpkg)-1] = '\0'; - pkg = strtok(NULL, "|"); - fprintf(config, "source \"package/pkgconfigs.d/%s/Config.in.%s\"\n", pkg, subpkg); - } - } - fprintf(config, "endmenu\n\n"); - fclose(section); - } - fclose(config); -} - -static char *tolowerstr(char *string) { - - int i; - char *str; - - /* transform to lowercase variable name */ - str = strdup(string); - for (i=0; i<(int)strlen(str); i++) { - if (str[i] == '_') - str[i] = '-'; - str[i] = tolower(str[i]); - } - return(str); -} - -static char *toupperstr(char *string) { - - int i; - char *str; - - /* transform to uppercase variable name */ - str = strdup(string); - for (i=0; i<(int)strlen(str); i++) { - if (str[i] == '+') - str[i] = 'X'; - if (str[i] == '-') - str[i] = '_'; - /* remove negation here, useful for package host depends */ - if (str[i] == '!') - str[i] = '_'; - str[i] = toupper(str[i]); - } - return(str); -} - - -int main() { - - DIR *pkgdir, *pkglistdir; - struct dirent *pkgdirp; - FILE *pkg, *cfg, *menuglobal, *section; - char hvalue[MAXVALUE]; - char buf[MAXPATH]; - char tbuf[MAXPATH]; - char path[MAXPATH]; - char spath[MAXPATH]; - char dir[MAXPATH]; - char variable[2*MAXVAR]; - char *key, *value, *token, *cftoken, *sp, *hkey, *val, *pkg_fd; - char *pkg_name, *pkg_depends, *pkg_depends_system, *pkg_section, *pkg_descr, *pkg_url; - char *pkg_cxx, *pkg_subpkgs, *pkg_cfline, *pkg_dflt, *pkg_multi; - char *pkg_need_cxx, *pkg_need_java, *pkgname, *sysname, *pkg_debug; - char *pkg_libc_depends, *pkg_host_depends, *pkg_system_depends, *pkg_arch_depends, *pkg_flavours, *pkg_flavours_string, *pkg_choices, *pseudo_name; - char *packages, *pkg_name_u, *pkgs, *pkg_opts, *pkg_libname; - char *saveptr, *p_ptr, *s_ptr, *pkg_helper; - int result; - StrMap *pkgmap, *sectionmap; - - pkg_name = NULL; - pkg_descr = NULL; - pkg_section = NULL; - pkg_url = NULL; - pkg_depends = NULL; - pkg_depends_system = NULL; - pkg_opts = NULL; - pkg_libname = NULL; - pkg_flavours = NULL; - pkg_flavours_string = NULL; - pkg_choices = NULL; - pkg_subpkgs = NULL; - pkg_arch_depends = NULL; - pkg_system_depends = NULL; - pkg_host_depends = NULL; - pkg_libc_depends = NULL; - pkg_cxx = NULL; - pkg_dflt = NULL; - pkg_cfline = NULL; - pkg_multi = NULL; - pkg_need_cxx = NULL; - pkg_need_java = NULL; - pkgname = NULL; - sysname = NULL; - pkg_helper = NULL; - pkg_debug = NULL; - - p_ptr = NULL; - s_ptr = NULL; - - unlink("package/Config.in.auto"); - /* open global sectionfile */ - menuglobal = fopen("package/Config.in.auto.global", "w"); - if (menuglobal == NULL) - fatal_error("global section file not writable."); - - /* read section list and create a hash table */ - section = fopen("package/section.lst", "r"); - if (section == NULL) - fatal_error("section listfile is missing"); - - sectionmap = strmap_new(HASHSZ); - while (fgets(tbuf, MAXPATH, section) != NULL) { - key = strtok(tbuf, "\t"); - value = strtok(NULL, "\t"); - strmap_put(sectionmap, key, value); - } - fclose(section); - - if (mkdir("package/pkgconfigs.d", S_IRWXU) > 0) - fatal_error("creation of package/pkgconfigs.d failed."); - if (mkdir("package/pkgconfigs.d/gcc", S_IRWXU) > 0) - fatal_error("creation of package/pkgconfigs.d/gcc failed."); - if (mkdir("package/pkglist.d", S_IRWXU) > 0) - fatal_error("creation of package/pkglist.d failed."); - - /* delete Config.in.dev */ - if (snprintf(path, MAXPATH, "package/pkgconfigs.d/gcc/Config.in.dev") < 0) - fatal_error("failed to create path variable."); - unlink(path); - cfg = fopen(path, "w"); - if (cfg == NULL) - fatal_error("Config.in.dev can not be opened"); - fprintf(cfg, "config ADK_PACKAGE_GLIBC_DEV\n"); - fprintf(cfg, "\tprompt \"glibc-dev............ development files for glibc\"\n"); - fprintf(cfg, "\ttristate\n"); - fprintf(cfg, "\tdefault n\n"); - fprintf(cfg, "\tdepends on ADK_TARGET_LIB_GLIBC\n"); - fprintf(cfg, "\thelp\n"); - fprintf(cfg, "\t GNU C library header files.\n\n"); - fprintf(cfg, "config ADK_PACKAGE_UCLIBC_DEV\n"); - fprintf(cfg, "\tprompt \"uclibc-dev........... development files for uclibc\"\n"); - fprintf(cfg, "\ttristate\n"); - fprintf(cfg, "\tdefault n\n"); - fprintf(cfg, "\tdepends on ADK_TARGET_LIB_UCLIBC\n"); - fprintf(cfg, "\thelp\n"); - fprintf(cfg, "\t C library header files.\n\n"); - fprintf(cfg, "config ADK_PACKAGE_MUSL_DEV\n"); - fprintf(cfg, "\tprompt \"musl-dev............. development files for musl\"\n"); - fprintf(cfg, "\ttristate\n"); - fprintf(cfg, "\tdefault n\n"); - fprintf(cfg, "\tdepends on ADK_TARGET_LIB_MUSL\n"); - fprintf(cfg, "\thelp\n"); - fprintf(cfg, "\t C library header files.\n\n"); - fclose(cfg); - - /* read Makefile's for all packages */ - pkgdir = opendir("package"); - while ((pkgdirp = readdir(pkgdir)) != NULL) { - /* skip dotfiles */ - if (strncmp(pkgdirp->d_name, ".", 1) > 0) { - if (snprintf(path, MAXPATH, "package/%s/Makefile", pkgdirp->d_name) < 0) - fatal_error("can not create path variable."); - pkg = fopen(path, "r"); - if (pkg == NULL) - continue; - - /* skip manually maintained packages */ - if (snprintf(path, MAXPATH, "package/%s/Config.in.manual", pkgdirp->d_name) < 0) - fatal_error("can not create path variable."); - if (!access(path, F_OK)) { - while (fgets(buf, MAXPATH, pkg) != NULL) { - if ((parse_var(buf, "PKG_SECTION", NULL, &pkg_section)) == 0) - continue; - } - - memset(hvalue, 0 , MAXVALUE); - result = strmap_get(sectionmap, pkg_section, hvalue, sizeof(hvalue)); - if (result == 1) { - if (snprintf(spath, MAXPATH, "package/pkglist.d/sectionlst.%d", hash_str(hvalue)) < 0) - fatal_error("can not create path variable."); - section = fopen(spath, "a"); - if (section != NULL) { - fprintf(section, "%s@\n", pkgdirp->d_name); - fclose(section); - } - } else - fatal_error("Can not find section description for package %s.", - pkgdirp->d_name); - - fclose(pkg); - continue; - } - - nobinpkgs = 0; - - /* create output directories */ - if (snprintf(dir, MAXPATH, "package/pkgconfigs.d/%s", pkgdirp->d_name) < 0) - fatal_error("can not create dir variable."); - if (mkdir(dir, S_IRWXU) > 0) - fatal_error("can not create directory."); - - - /* allocate memory */ - hkey = malloc(MAXVAR); - memset(hkey, 0, MAXVAR); - memset(variable, 0, 2*MAXVAR); - - pkgmap = strmap_new(HASHSZ); - - /* parse package Makefile */ - while (fgets(buf, MAXPATH, pkg) != NULL) { - /* just read variables prefixed with PKG */ - if (strncmp(buf, "PKG", 3) == 0) { - if ((parse_var(buf, "PKG_NAME", NULL, &pkg_name)) == 0) - continue; - if (pkg_name != NULL) - pkg_name_u = toupperstr(pkg_name); - else - pkg_name_u = toupperstr(pkgdirp->d_name); - - snprintf(variable, MAXVAR, "PKG_CFLINE_%s", pkg_name_u); - if ((parse_var(buf, variable, pkg_cfline, &pkg_cfline)) == 0) - continue; - snprintf(variable, MAXVAR, "PKG_DFLT_%s", pkg_name_u); - if ((parse_var(buf, variable, NULL, &pkg_dflt)) == 0) - continue; - if ((parse_var(buf, "PKG_LIBC_DEPENDS", NULL, &pkg_libc_depends)) == 0) - continue; - if ((parse_var(buf, "PKG_HOST_DEPENDS", NULL, &pkg_host_depends)) == 0) - continue; - if ((parse_var(buf, "PKG_ARCH_DEPENDS", NULL, &pkg_arch_depends)) == 0) - continue; - if ((parse_var(buf, "PKG_SYSTEM_DEPENDS", NULL, &pkg_system_depends)) == 0) - continue; - if ((parse_var(buf, "PKG_DESCR", NULL, &pkg_descr)) == 0) - continue; - if ((parse_var(buf, "PKG_SECTION", NULL, &pkg_section)) == 0) - continue; - if ((parse_var(buf, "PKG_URL", NULL, &pkg_url)) == 0) - continue; - if ((parse_var(buf, "PKG_CXX", NULL, &pkg_cxx)) == 0) - continue; - if ((parse_var(buf, "PKG_NEED_CXX", NULL, &pkg_need_cxx)) == 0) - continue; - if ((parse_var(buf, "PKG_NEED_JAVA", NULL, &pkg_need_java)) == 0) - continue; - if ((parse_var(buf, "PKG_MULTI", NULL, &pkg_multi)) == 0) - continue; - if ((parse_var(buf, "PKG_DEPENDS", pkg_depends, &pkg_depends)) == 0) - continue; - if ((parse_var_with_system(buf, "PKG_DEPENDS_", pkg_depends_system, &pkg_depends_system, &sysname, 12)) == 0) - continue; - if ((parse_var(buf, "PKG_LIBNAME", pkg_libname, &pkg_libname)) == 0) - continue; - if ((parse_var(buf, "PKG_OPTS", pkg_opts, &pkg_opts)) == 0) - continue; - if ((parse_var_with_pkg(buf, "PKG_FLAVOURS_STRING_", pkg_flavours_string, &pkg_flavours_string, &pkgname, 20)) == 0) - continue; - if ((parse_var_with_pkg(buf, "PKG_FLAVOURS_", pkg_flavours, &pkg_flavours, &pkgname, 13)) == 0) - continue; - if ((parse_var_hash(buf, "PKGFD_", pkgmap)) == 0) - continue; - if ((parse_var_hash(buf, "PKGFX_", pkgmap)) == 0) - continue; - if ((parse_var_hash(buf, "PKGFS_", pkgmap)) == 0) - continue; - if ((parse_var_hash(buf, "PKGFC_", pkgmap)) == 0) - continue; - if ((parse_var_with_pkg(buf, "PKG_CHOICES_", pkg_choices, &pkg_choices, &pkgname, 12)) == 0) - continue; - if ((parse_var_hash(buf, "PKGCD_", pkgmap)) == 0) - continue; - if ((parse_var_hash(buf, "PKGCS_", pkgmap)) == 0) - continue; - if ((parse_var(buf, "PKG_SUBPKGS", pkg_subpkgs, &pkg_subpkgs)) == 0) - continue; - if ((parse_var_hash(buf, "PKGSD_", pkgmap)) == 0) - continue; - if ((parse_var_hash(buf, "PKGSS_", pkgmap)) == 0) - continue; - if ((parse_var_hash(buf, "PKGSC_", pkgmap)) == 0) - continue; - } - } - - /* when PKG_LIBNAME exist use this instead of PKG_NAME, but only for !libmix */ - if (pkg_libname != NULL) - if (pkg_opts != NULL) - if (strstr(pkg_opts, "libmix") == NULL) - pkg_name = strdup(pkg_libname); - - /* end of package Makefile parsing */ - if (fclose(pkg) != 0) - perror("Failed to close file stream for Makefile"); - -#if 0 - if (pkg_name != NULL) - fprintf(stderr, "Package name is %s\n", pkg_name); - if (pkg_libname != NULL) - fprintf(stderr, "Package library name is %s\n", pkg_libname); - if (pkg_section != NULL) - fprintf(stderr, "Package section is %s\n", pkg_section); - if (pkg_descr != NULL) - fprintf(stderr, "Package description is %s\n", pkg_descr); - if (pkg_depends != NULL) - fprintf(stderr, "Package dependencies are %s\n", pkg_depends); - if (pkg_depends_system != NULL) - fprintf(stderr, "Package systemspecific dependencies are %s\n", pkg_depends_system); - if (pkg_subpkgs != NULL) - fprintf(stderr, "Package subpackages are %s\n", pkg_subpkgs); - if (pkg_flavours != NULL && pkgname != NULL) - fprintf(stderr, "Package flavours for %s are %s\n", pkgname, pkg_flavours); - if (pkg_flavours_string != NULL && pkgname != NULL) - fprintf(stderr, "Package string flavours for %s are %s\n", pkgname, pkg_flavours_string); - if (pkg_choices != NULL && pkgname != NULL) - fprintf(stderr, "Package choices for %s are %s\n", pkgname, pkg_choices); - if (pkg_url != NULL) - fprintf(stderr, "Package homepage is %s\n", pkg_url); - if (pkg_cfline != NULL) - fprintf(stderr, "Package cfline is %s\n", pkg_cfline); - if (pkg_multi != NULL) - fprintf(stderr, "Package multi is %s\n", pkg_multi); - if (pkg_opts != NULL) - fprintf(stderr, "Package options are %s\n", pkg_opts); - - strmap_enum(pkgmap, iter_debug, NULL); -#endif - - /* generate master source Config.in file */ - if (snprintf(path, MAXPATH, "package/pkgconfigs.d/%s/Config.in", pkgdirp->d_name) < 0) - fatal_error("path variable creation failed."); - fprintf(menuglobal, "source \"%s\"\n", path); - /* recreating file is faster than truncating with w+ */ - unlink(path); - cfg = fopen(path, "w"); - if (cfg == NULL) - continue; - - pkgs = NULL; - if (pkg_subpkgs != NULL) - pkgs = strdup(pkg_subpkgs); - - fprintf(cfg, "config ADK_COMPILE_%s\n", toupperstr(pkgdirp->d_name)); - fprintf(cfg, "\ttristate\n"); - if (nobinpkgs == 0) { - fprintf(cfg, "\tdepends on "); - if (pkgs != NULL) { - if (pkg_multi != NULL) - if (strncmp(pkg_multi, "1", 1) == 0) - fprintf(cfg, "ADK_HAVE_DOT_CONFIG || "); - token = strtok(pkgs, " "); - fprintf(cfg, "ADK_PACKAGE_%s", token); - token = strtok(NULL, " "); - while (token != NULL) { - fprintf(cfg, " || ADK_PACKAGE_%s", token); - token = strtok(NULL, " "); - } - fprintf(cfg, "\n"); - } else { - fprintf(cfg, "ADK_PACKAGE_%s\n", toupperstr(pkg_name)); - } - } - fprintf(cfg, "\tdefault n\n"); - fclose(cfg); - free(pkgs); - - - /* skip packages without binary package output */ - if (nobinpkgs == 1) - continue; - - /* generate binary package specific Config.in files */ - if (pkg_subpkgs != NULL) - packages = tolowerstr(pkg_subpkgs); - else - packages = strdup(pkg_name); - - token = strtok_r(packages, " ", &p_ptr); - while (token != NULL) { - strncat(hkey, "PKGSC_", 6); - strncat(hkey, toupperstr(token), strlen(token)); - memset(hvalue, 0 , MAXVALUE); - result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - if (result == 1) - pkg_section = strdup(hvalue); - - strncat(hkey, "PKGSD_", 6); - strncat(hkey, toupperstr(token), strlen(token)); - memset(hvalue, 0 , MAXVALUE); - result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - if (result == 1) - pkg_descr = strdup(hvalue); - - pseudo_name = malloc(MAXLINE); - memset(pseudo_name, 0, MAXLINE); - strncat(pseudo_name, token, strlen(token)); - while (strlen(pseudo_name) < 20) - strncat(pseudo_name, ".", 1); - - if (snprintf(path, MAXPATH, "package/pkgconfigs.d/%s/Config.in.%s", pkgdirp->d_name, token) < 0) - fatal_error("failed to create path variable."); - - /* create temporary section files */ - memset(hvalue, 0 , MAXVALUE); - result = strmap_get(sectionmap, pkg_section, hvalue, sizeof(hvalue)); - if (result == 1) { - if (snprintf(spath, MAXPATH, "package/pkglist.d/sectionlst.%d", hash_str(hvalue)) < 0) - fatal_error("failed to create path variable."); - section = fopen(spath, "a"); - if (section != NULL) { - fprintf(section, "%s |%s\n", token, pkgdirp->d_name); - fclose(section); - } - } else - fatal_error("Can not find section description for package %s.", pkgdirp->d_name); - - unlink(path); - cfg = fopen(path, "w"); - if (cfg == NULL) - perror("Can not open Config.in file"); - - if (pkg_need_cxx != NULL) { - fprintf(cfg, "comment \"%s... %s (disabled, c++ missing)\"\n", token, pkg_descr); - fprintf(cfg, "depends on !ADK_TOOLCHAIN_GCC_CXX\n\n"); - } - - /* save token in pkg_debug */ - pkg_debug = strdup(token); - fprintf(cfg, "config ADK_PACKAGE_%s\n", toupperstr(token)); - /* no prompt for devonly packages */ - if (pkg_opts != NULL) { - if (strstr(pkg_opts, "devonly") != NULL) { - fprintf(cfg, "\t#prompt \"%s. %s\"\n", pseudo_name, pkg_descr); - } else { - fprintf(cfg, "\tprompt \"%s. %s\"\n", pseudo_name, pkg_descr); - } - } else { - fprintf(cfg, "\tprompt \"%s. %s\"\n", pseudo_name, pkg_descr); - } - - fprintf(cfg, "\ttristate\n"); - if (pkg_multi != NULL) - if (strncmp(pkg_multi, "1", 1) == 0) - if (strncmp(toupperstr(token), toupperstr(pkgdirp->d_name), strlen(token)) != 0) - fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", toupperstr(pkgdirp->d_name)); - - free(pseudo_name); - - /* print custom cf line */ - if (pkg_cfline != NULL) { - cftoken = strtok_r(pkg_cfline, "@", &saveptr); - while (cftoken != NULL) { - fprintf(cfg, "\t%s\n", cftoken); - cftoken = strtok_r(NULL, "@", &saveptr); - } - free(pkg_cfline); - pkg_cfline = NULL; - } - - /* add sub package dependencies */ - strncat(hkey, "PKGSS_", 6); - strncat(hkey, toupperstr(token), strlen(token)); - memset(hvalue, 0, MAXVALUE); - result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - if (result == 1) { - val = strtok_r(hvalue, " ", &saveptr); - while (val != NULL) { - if (strncmp(val, "kmod", 4) == 0) - fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val)); - else - fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val)); - val = strtok_r(NULL, " ", &saveptr); - } - } - memset(hkey, 0, MAXVAR); - - /* create package target system dependency information */ - if (pkg_system_depends != NULL) { - pkg_helper = strdup(pkg_system_depends); - token = strtok(pkg_helper, " "); - fprintf(cfg, "\tdepends on "); - sp = ""; - while (token != NULL) { - if(strncmp(token, "!", 1) == 0) { - fprintf(cfg, "%s!ADK_TARGET_SYSTEM%s", sp, toupperstr(token)); - sp = " && "; - } else { - fprintf(cfg, "%sADK_TARGET_SYSTEM_%s", sp, toupperstr(token)); - sp = " || "; - } - token = strtok(NULL, " "); - } - fprintf(cfg, "\n"); - free(pkg_helper); - pkg_helper = NULL; - } - /* create package host dependency information */ - if (pkg_host_depends != NULL) { - pkg_helper = strdup(pkg_host_depends); - token = strtok(pkg_helper, " "); - fprintf(cfg, "\tdepends on "); - sp = ""; - while (token != NULL) { - if(strncmp(token, "!", 1) == 0) { - fprintf(cfg, "%s!ADK_HOST%s", sp, toupperstr(token)); - sp = " && "; - } else { - fprintf(cfg, "%sADK_HOST_%s", sp, toupperstr(token)); - sp = " || "; - } - token = strtok(NULL, " "); - } - fprintf(cfg, "\n"); - free(pkg_helper); - pkg_helper = NULL; - } - - /* create package libc dependency information */ - if (pkg_libc_depends != NULL) { - pkg_helper = strdup(pkg_libc_depends); - token = strtok(pkg_helper, " "); - fprintf(cfg, "\tdepends on "); - sp = ""; - while (token != NULL) { - if(strncmp(token, "!", 1) == 0) { - fprintf(cfg, "%s!ADK_TARGET_LIB_%s", sp, toupperstr(token)); - sp = " && "; - } else { - fprintf(cfg, "%sADK_TARGET_LIB_%s", sp, toupperstr(token)); - sp = " || "; - } - token = strtok(NULL, " "); - } - fprintf(cfg, "\n"); - free(pkg_helper); - pkg_helper = NULL; - } - /* create package target architecture dependency information */ - if (pkg_arch_depends != NULL) { - pkg_helper = strdup(pkg_arch_depends); - token = strtok(pkg_helper, " "); - fprintf(cfg, "\tdepends on "); - sp = ""; - while (token != NULL) { - if(strncmp(token, "!", 1) == 0) { - fprintf(cfg, "%s!ADK_LINUX%s", sp, toupperstr(token)); - sp = " && "; - } else { - fprintf(cfg, "%sADK_LINUX_%s", sp, toupperstr(token)); - sp = " || "; - } - token = strtok(NULL, " "); - } - fprintf(cfg, "\n"); - free(pkg_helper); - pkg_helper = NULL; - } - - /* create package dependency information */ - if (pkg_depends != NULL) { - token = strtok(pkg_depends, " "); - while (token != NULL) { - if (strncmp(token, "kmod", 4) == 0) - fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(token)); - else - fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(token)); - token = strtok(NULL, " "); - } - free(pkg_depends); - pkg_depends = NULL; - } - /* create system specific package dependency information */ - if (pkg_depends_system != NULL) { - token = strtok(pkg_depends_system, " "); - while (token != NULL) { - fprintf(cfg, "\tselect ADK_PACKAGE_%s if ADK_TARGET_SYSTEM_%s\n", toupperstr(token), sysname); - token = strtok(NULL, " "); - } - free(pkg_depends_system); - pkg_depends_system = NULL; - } - - if (pkg_need_cxx != NULL) { - fprintf(cfg, "\tdepends on ADK_TOOLCHAIN_GCC_CXX\n"); - } - if (pkg_need_java != NULL) { - fprintf(cfg, "\tdepends on ADK_TOOLCHAIN_GCC_JAVA\n"); - pkg_need_java = NULL; - } - - fprintf(cfg, "\tselect ADK_COMPILE_%s\n", toupperstr(pkgdirp->d_name)); - - if (pkg_dflt != NULL) { - fprintf(cfg, "\tdefault %s\n", pkg_dflt); - pkg_dflt = NULL; - } else { - fprintf(cfg, "\tdefault n\n"); - } - - fprintf(cfg, "\thelp\n"); - fprintf(cfg, "\t %s\n\n", pkg_descr); - if (pkg_url != NULL) - fprintf(cfg, "\t WWW: %s\n", pkg_url); - - /* handle special C++ packages */ - if (pkg_cxx != NULL) { - fprintf(cfg, "\nchoice\n"); - fprintf(cfg, "prompt \"C++ library to use\"\n"); - fprintf(cfg, "depends on ADK_COMPILE_%s\n\n", toupperstr(pkgdirp->d_name)); - fprintf(cfg, "default ADK_COMPILE_%s_WITH_STDCXX if ADK_TARGET_LIB_GLIBC\n", pkg_cxx); - fprintf(cfg, "default ADK_COMPILE_%s_WITH_UCLIBCXX if ADK_TARGET_LIB_UCLIBC\n\n", pkg_cxx); - fprintf(cfg, "config ADK_COMPILE_%s_WITH_STDCXX\n", pkg_cxx); - fprintf(cfg, "\tbool \"GNU C++ library\"\n"); - fprintf(cfg, "\tselect ADK_PACKAGE_LIBSTDCXX\n\n"); - fprintf(cfg, "config ADK_COMPILE_%s_WITH_UCLIBCXX\n", pkg_cxx); - fprintf(cfg, "\tbool \"uClibc++ library\"\n"); - fprintf(cfg, "\tselect ADK_PACKAGE_UCLIBCXX\n\n"); - fprintf(cfg, "endchoice\n"); - free(pkg_cxx); - pkg_cxx = NULL; - } - - /* handle debug subpackages */ - fprintf(cfg, "\nconfig ADK_PACKAGE_%s_DBG\n", toupperstr(pkg_debug)); - fprintf(cfg, "\tprompt \"add debug symbols package\"\n"); - fprintf(cfg, "\ttristate\n"); - fprintf(cfg, "\tdepends on ADK_PACKAGE_GDB\n"); - fprintf(cfg, "\tdepends on !ADK_DEBUG\n"); - fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", toupperstr(pkg_debug)); - fprintf(cfg, "\tdefault n\n"); - fprintf(cfg, "\thelp\n\n"); - - /* package flavours */ - if (pkg_flavours != NULL) { - token = strtok(pkg_flavours, " "); - while (token != NULL) { - fprintf(cfg, "\nconfig ADK_PACKAGE_%s_%s\n", pkgname, toupperstr(token)); - - // process default value - strncat(hkey, "PKGFX_", 6); - strncat(hkey, token, strlen(token)); - memset(hvalue, 0 , MAXVALUE); - strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - pkg_fd = strdup(hvalue); - if (strlen(pkg_fd) > 0) - fprintf(cfg, "\tdefault %s\n", pkg_fd); - else - fprintf(cfg, "\tdefault n\n"); - - - // process flavour cfline - strncat(hkey, "PKGFC_", 6); - strncat(hkey, token, strlen(token)); - memset(hvalue, 0 , MAXVALUE); - strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - pkg_fd = strdup(hvalue); - if (strlen(pkg_fd) > 0) - fprintf(cfg, "\t%s\n", pkg_fd); - - fprintf(cfg, "\tboolean "); - strncat(hkey, "PKGFD_", 6); - strncat(hkey, token, strlen(token)); - memset(hvalue, 0 , MAXVALUE); - strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - pkg_fd = strdup(hvalue); - - fprintf(cfg, "\"%s\"\n", pkg_fd); - fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", pkgname); - strncat(hkey, "PKGFS_", 6); - strncat(hkey, token, strlen(token)); - - result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - if (result == 1) { - val = strtok_r(hvalue, " ", &saveptr); - while (val != NULL) { - if (strncmp(val, "kmod", 4) == 0) - fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val)); - else - fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val)); - val = strtok_r(NULL, " ", &saveptr); - } - } - memset(hkey, 0, MAXVAR); - fprintf(cfg, "\thelp\n"); - fprintf(cfg, "\t %s\n", pkg_fd); - token = strtok(NULL, " "); - } - free(pkg_flavours); - pkg_flavours = NULL; - } - - /* package flavours string */ - if (pkg_flavours_string != NULL) { - token = strtok(pkg_flavours_string, " "); - while (token != NULL) { - fprintf(cfg, "\nconfig ADK_PACKAGE_%s_%s\n", pkgname, toupperstr(token)); - - // process default value - strncat(hkey, "PKGFX_", 6); - strncat(hkey, token, strlen(token)); - memset(hvalue, 0 , MAXVALUE); - strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - pkg_fd = strdup(hvalue); - if (strlen(pkg_fd) > 0) - fprintf(cfg, "\tdefault \"%s\"\n", pkg_fd); - - // process flavour cfline - strncat(hkey, "PKGFC_", 6); - strncat(hkey, token, strlen(token)); - memset(hvalue, 0 , MAXVALUE); - strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - pkg_fd = strdup(hvalue); - if (strlen(pkg_fd) > 0) - fprintf(cfg, "\t%s\n", pkg_fd); - - fprintf(cfg, "\tstring "); - strncat(hkey, "PKGFD_", 6); - strncat(hkey, token, strlen(token)); - memset(hvalue, 0 , MAXVALUE); - strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - memset(hkey, 0 , MAXVAR); - pkg_fd = strdup(hvalue); - fprintf(cfg, "\"%s\"\n", pkg_fd); - - fprintf(cfg, "\tdepends on ADK_PACKAGE_%s\n", pkgname); - strncat(hkey, "PKGFS_", 6); - strncat(hkey, token, strlen(token)); - - result = strmap_get(pkgmap, hkey, hvalue, sizeof(hvalue)); - if (result == 1) { - val = strtok_r(hvalue, " ", &saveptr); - while (val != NULL) { - if (strncmp(val, "kmod", 4) == 0) - fprintf(cfg, "\tselect ADK_KPACKAGE_%s\n", toupperstr(val)); - else - fprintf(cfg, "\tselect ADK_PACKAGE_%s\n", toupperstr(val)); - val = strtok_r(NULL, " ", &saveptr); - } - } - memset(hkey, 0, MAXVAR); - fprintf(cfg, "\thelp\n"); - fprintf(cfg, "\t %s\n", pkg_fd); - token = strtok(NULL, " "); - } - free(pkg_flavours_string); - pkg_flavours_string = NULL; - } - - /* package choices */ - if (pkg_choices != NULL) { - fprintf(cfg, "\nchoice\n"); - fprintf(cfg, "prompt \"Package flavour choice\"\n"); - fprintf(cfg, "depends on ADK_PACKAGE_%s\n\n", pkgname); - token = strtok(pkg_choices, " "); - while (to