klibc: initial commit of version 1.5.24

* from org.openembedded.dev
* reworked in meta-smartphones/meta-zaurus

Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
Andrea Adami
2011-08-06 05:30:14 +00:00
committed by Koen Kooi
parent 06c3e6c9b1
commit 3c0d5e4321
16 changed files with 2903 additions and 0 deletions
@@ -0,0 +1,33 @@
PR = "${INC_PR}.0"
require klibc.inc
require klibc-checksums_${PV}.inc
export KLCC_INST = "${STAGING_DIR_TARGET}/lib/klibc"
SRC_URI += "file://klcc_prefix.patch \
file://use-env-for-perl.patch"
DEPENDS = "klibc"
FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
# ${TARGET_PREFIX}klcc is just a
# perl wrapper around gcc-cross
# so give it the same arch and path
PACKAGE_ARCH = "${TUNE_PKGARCH}"
inherit cross
do_configure () {
:
}
do_compile() {
oe_runmake klcc
}
do_install() {
install -d ${D}${base_bindir}
install -m 0755 klcc/klcc ${D}${base_bindir}/${TARGET_PREFIX}klcc
}
@@ -0,0 +1,111 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id ad67a97e8fbfb03a68088a6ca6ad87b086c88094
Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
Minor adjustments tracking upstream changes
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
diff -uNr klibc-1.5.22.orig//usr/dash/miscbltin.c klibc-1.5.22/usr/dash/miscbltin.c
--- klibc-1.5.22.orig//usr/dash/miscbltin.c 2011-06-11 02:08:49.000000000 +0200
+++ klibc-1.5.22/usr/dash/miscbltin.c 2011-06-11 13:55:32.000000000 +0200
@@ -46,6 +46,7 @@
#include <ctype.h>
#include <inttypes.h>
#include <time.h> /* strtotimeval() */
+#include <termios.h>
#include "shell.h"
#include "options.h"
@@ -149,6 +150,11 @@
int timeout;
int i;
fd_set set;
+ int n_flag = 0;
+ unsigned int nchars = 0;
+ int silent = 0;
+ struct termios tty, old_tty;
+
struct timeval ts, t0, t1, to;
ts.tv_sec = ts.tv_usec = 0;
@@ -156,11 +162,18 @@
rflag = 0;
timeout = 0;
prompt = NULL;
- while ((i = nextopt("p:rt:")) != '\0') {
+ while ((i = nextopt("p:rt:n:s")) != '\0') {
switch(i) {
case 'p':
prompt = optionarg;
break;
+ case 'n':
+ nchars = strtoul(optionarg, NULL, 10);
+ n_flag = nchars; /* just a flag "nchars is nonzero" */
+ break;
+ case 's':
+ silent = 1;
+ break;
case 't':
p = strtotimeval(optionarg, &ts);
if (*p || (!ts.tv_sec && !ts.tv_usec))
@@ -182,6 +197,24 @@
}
if (*(ap = argptr) == NULL)
sh_error("arg count");
+ if (n_flag || silent) {
+ if (tcgetattr(0, &tty) != 0) {
+ /* Not a tty */
+ n_flag = 0;
+ silent = 0;
+ } else {
+ old_tty = tty;
+ if (n_flag) {
+ tty.c_lflag &= ~ICANON;
+ tty.c_cc[VMIN] = nchars < 256 ? nchars : 255;
+ }
+ if (silent) {
+ tty.c_lflag &= ~(ECHO | ECHOK | ECHONL);
+ }
+ tcsetattr(0, TCSANOW, &tty);
+ }
+ }
+
status = 0;
if (timeout) {
@@ -200,12 +231,14 @@
goto start;
- for (;;) {
+ do {
if (timeout) {
gettimeofday(&t1, NULL);
if (t1.tv_sec > ts.tv_sec ||
(t1.tv_sec == ts.tv_sec &&
t1.tv_usec >= ts.tv_usec)) {
status = 1;
+ if (n_flag)
+ tcsetattr(0, TCSANOW, &old_tty);
break; /* Timeout! */
}
@@ -222,6 +255,8 @@
FD_SET(0, &set);
if (select(1, &set, NULL, NULL, &to) != 1) {
status = 1;
+ if (n_flag)
+ tcsetattr(0, TCSANOW, &old_tty);
break; /* Timeout! */
}
}
@@ -263,6 +298,9 @@
newloc = startloc - 1;
}
- }
+ } while (!n_flag || --nchars);
+ if (n_flag || silent)
+ tcsetattr(0, TCSANOW, &old_tty);
+
out:
recordregion(startloc, p - (char *)stackblock(), 0);
STACKSTRNUL(p);
@@ -0,0 +1,74 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id 2a98e2a2c1b55a0eb0ac09f2f9b55db2e4c23553
Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
Refresh and fixes as of commit id 5dbd8d611f3cb7eb8baddb17211d6077e2060fdb
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Index: klibc-1.5.22/usr/kinit/fstype/fstype.c
===================================================================
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -20,7 +20,7 @@
#include <netinet/in.h>
#include <sys/utsname.h>
#include <sys/vfs.h>
-
+#include <linux/types.h>
#define cpu_to_be32(x) __cpu_to_be32(x) /* Needed by romfs_fs.h */
#include "btrfs.h"
@@ -38,6 +38,12 @@
#include "squashfs_fs.h"
#include "xfs_sb.h"
+#if __BYTE_ORDER == __BIG_ENDIAN
+#include <linux/byteorder/big_endian.h>
+#else
+#include <linux/byteorder/little_endian.h>
+#endif
+
/*
* Slightly cleaned up version of jfs_superblock to
* avoid pulling in other kernel header files.
@@ -60,6 +66,30 @@
/* Swap needs the definition of block size */
#include "swap_fs.h"
+static int jffs2_image(const void *buf, unsigned long long *blocks)
+{
+ const unsigned char *p = buf;
+
+ if (p[0] == 0x85 && p[1] == 0x19) {
+ *blocks=0;
+ return 1;
+ }
+ return 0;
+}
+
+static int vfat_image(const void *buf, unsigned long long *blocks)
+{
+ const char *p = buf;
+
+ if (!strncmp(p + 54, "FAT12 ", 8)
+ || !strncmp(p + 54, "FAT16 ", 8)
+ || !strncmp(p + 82, "FAT32 ", 8)) {
+ *blocks=0;
+ return 1;
+ }
+ return 0;
+}
+
static int gzip_image(const void *buf, unsigned long long *bytes)
{
const unsigned char *p = buf;
@@ -495,6 +525,8 @@ static struct imagetype images[] = {
{1, "ext3", ext3_image},
{1, "ext2", ext2_image},
{1, "minix", minix_image},
+ {0, "jffs2", jffs2_image},
+ {0, "vfat", vfat_image},
{1, "nilfs2", nilfs2_image},
{2, "ocfs2", ocfs2_image},
{8, "reiserfs", reiserfs_image},
@@ -0,0 +1,24 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id a29bf15b9c9c0d15f96c254b2ed830e104ae3436
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Index: klibc-1.5.19/klcc/Kbuild
===================================================================
--- --- klibc-1.5.19.orig/klcc/Kbuild 2010-07-07 14:07:48.000000000 +0200
+++ --- klibc-1.5.19./klcc/Kbuild 2010-08-18 23:39:23.000000000 +0200
@@ -22,10 +22,10 @@
$(Q)echo 'EMAIN=$(KLIBCEMAIN)' >> $@
$(Q)echo 'BITSIZE=$(KLIBCBITSIZE)' >> $@
$(Q)echo 'VERSION=$(shell cat $(srctree)/usr/klibc/version)' >> $@
- $(Q)echo 'prefix=$(INSTALLDIR)' >> $@
- $(Q)echo 'bindir=$(INSTALLDIR)/$(KCROSS)bin' >> $@
- $(Q)echo 'libdir=$(INSTALLDIR)/$(KCROSS)lib' >> $@
- $(Q)echo 'includedir=$(INSTALLDIR)/$(KCROSS)include' >> $@
+ $(Q)echo 'prefix=$(KLCC_INST)' >> $@
+ $(Q)echo 'bindir=$(KLCC_INST)/$(KCROSS)bin' >> $@
+ $(Q)echo 'libdir=$(KLCC_INST)/$(KCROSS)lib' >> $@
+ $(Q)echo 'includedir=$(KLCC_INST)/$(KCROSS)include' >> $@
# Generate klcc
@@ -0,0 +1,14 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id b6764cf32ec93547531130dca364fb95e1c495f4
Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
diff -Nur klibc-1.5/defconfig klibc-1.5p/defconfig
--- klibc-1.5/defconfig 2007-03-04 02:52:10.000000000 +0100
+++ klibc-1.5p/defconfig 2008-02-08 19:24:22.337127756 +0100
@@ -5,4 +5,4 @@
CONFIG_REGPARM=y
# ARM options
# CONFIG_KLIBC_THUMB is not set
-# CONFIG_AEABI is not set
+CONFIG_AEABI=y
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,36 @@
Do not strip binaries too early. Strip is done before packaging.
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
--- a/scripts/Kbuild.klibc 2011-06-14 17:11:17.000000000 +0200
+++ b/scripts/Kbuild.klibc 2011-07-15 01:18:58.000000000 +0200
@@ -332,8 +332,7 @@
$(KLIBCLIBC) \
$(KLIBCLIBGCC) \
--end-group ; \
- cp -f $@ $@.g ; \
- $(KLIBCSTRIP) $(KLIBCSTRIPFLAGS) $@
+ cp -f $@ $@.g
$(static-y): $(kprog-objs) $(lib-target) $(KLIBCCRT0) $(KLIBCLIBC) FORCE
@@ -348,8 +347,7 @@
-R $(KLIBCLIBCSHARED) \
$(KLIBCLIBGCC) \
--end-group ; \
- cp -f $@ $@.g ; \
- $(KLIBCSTRIP) $(KLIBCSTRIPFLAGS) $@
+ cp -f $@ $@.g
$(shared-y): $(kprog-objs) $(lib-target) $(KLIBCCRTSHARED) \
--- a/usr/klibc/Kbuild 2011-07-15 01:46:32.000000000 +0200
+++ b/usr/klibc/Kbuild 2011-07-15 01:47:17.000000000 +0200
@@ -147,7 +147,6 @@
quiet_cmd_sohash = GEN $@
cmd_sohash = cat $< > $@; \
- $(KLIBCSTRIP) $(KLIBCSTRIPFLAGS) $@; \
chmod a+x $@; \
rm -f $(obj)/klibc-???????????????????????????.so; \
ln -f $@ $(obj)/klibc-$(SOLIBHASH).so
@@ -0,0 +1,31 @@
Subject: Add relevant socket.h definitions
* Discussed upstream:
* http://www.zytor.com/pipermail/klibc/2010-February/002487.html
* http://www.zytor.com/pipermail/klibc/2010-February/002488.html
*
* Was: Add guards for pre 2.6.33 compatibility.
*
* Changes for 1.5.24
* Only include linux/sockios.h for SIOCGIFCONF and SIOCSIFFLAGS
* requested by kexec-tools when building statically against klibc.
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Index: klibc-1.5.24/usr/include/sys/socket.h
===================================================================
--- a/usr/include/sys/socket.h 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/include/sys/socket.h 2010-05-31 00:44:16.000000000 +0200
@@ -10,6 +10,12 @@
#include <klibc/compiler.h>
#include <klibc/sysconfig.h>
#include <linux/socket.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#include <linux/sockios.h> /* the SIOCxxx I/O controls */
+#endif
+
#include <linux/uio.h>
#include <asm/socket.h>
#if _KLIBC_HAS_ARCHSOCKET_H
@@ -0,0 +1,153 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id eefb99a313bbcc8f34c8b32bf0c5aa2dd2580735
Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
Minor edits following upstream changes
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Index: klibc-1.5.24/Makefile
===================================================================
--- a/Makefile 2011-07-27 15:50:53.000000000 +0200
+++ b/Makefile 2011-08-01 00:47:56.000000000 +0200
@@ -39,7 +39,7 @@
export PERL := perl
# Location for installation
-export prefix = /usr
+export prefix = $(INST)
export bindir = $(prefix)/bin
export libdir = $(prefix)/lib
export mandir = $(prefix)/man
Index: klibc-1.5.24/scripts/Kbuild.install
===================================================================
--- a/scripts/Kbuild.install 2011-07-27 15:50:53.000000000 +0200
+++ b/scripts/Kbuild.install 2011-08-01 00:03:03.000000000 +0200
@@ -88,16 +88,12 @@
header:
$(Q)echo " INSTALL headers + man pages to $(INSTALLROOT)$(INSTALLDIR)"
$(Q)mkdir -p $(INSTALLROOT)$(bindir)
- $(Q)mkdir -p $(INSTALLROOT)$(mandir)/man1
- $(Q)mkdir -p $(INSTALLROOT)$(SHLIBDIR)
$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)
$(Q)-rm -rf $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
- $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
$(Q)$(MAKE) -C $(KLIBCKERNELSRC) ARCH=$(KLIBCARCH) INSTALL_HDR_PATH=$(INSTALLROOT)$(INSTALLDIR)/$(KCROSS) headers_install
$(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
- $(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
$(Q)$(install-bin) $(objtree)/klcc/$(KCROSS)klcc $(INSTALLROOT)$(bindir)
footer: header
Index: klibc-1.5.24/usr/dash/Kbuild
===================================================================
--- a/usr/dash/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/dash/Kbuild 2011-08-01 00:07:56.000000000 +0200
@@ -92,5 +92,3 @@
$(obj)/syntax.h: $(obj)/syntax.c
$(Q):
-# Targets to install
-install-y := sh.shared
Index: klibc-1.5.24/usr/gzip/Kbuild
===================================================================
--- a/usr/gzip/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/gzip/Kbuild 2011-08-01 00:06:39.000000000 +0200
@@ -21,5 +21,3 @@
# Cleaning
targets := gzip gzip.g gunzip zcat
-# Targets to install
-install-y := gzip gunzip zcat
Index: klibc-1.5.24/usr/kinit/fstype/Kbuild
===================================================================
--- a/usr/kinit/fstype/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/kinit/fstype/Kbuild 2011-08-01 00:09:12.000000000 +0200
@@ -21,5 +21,3 @@
# Cleaning
clean-dirs := static shared
-# install binary
-install-y := $(shared-y)
Index: klibc-1.5.24/usr/kinit/ipconfig/Kbuild
===================================================================
--- a/usr/kinit/ipconfig/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/kinit/ipconfig/Kbuild 2011-08-01 00:10:52.000000000 +0200
@@ -27,5 +27,3 @@
# Cleaning
clean-dirs := static shared
-# install binary
-install-y := $(shared-y)
Index: klibc-1.5.24/usr/kinit/Kbuild
===================================================================
--- a/usr/kinit/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/kinit/Kbuild 2011-08-01 00:20:18.000000000 +0200
@@ -33,5 +33,3 @@
subdir- := fstype ipconfig nfsmount resume run-init
-# install binary
-install-y := kinit kinit.shared
Index: klibc-1.5.24/usr/kinit/nfsmount/Kbuild
===================================================================
--- a/usr/kinit/nfsmount/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/kinit/nfsmount/Kbuild 2011-08-01 00:12:52.000000000 +0200
@@ -23,5 +23,3 @@
clean-dirs := static shared
-# Install binary
-install-y := $(shared-y)
Index: klibc-1.5.24/usr/kinit/resume/Kbuild
===================================================================
--- a/usr/kinit/resume/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/kinit/resume/Kbuild 2011-08-01 00:13:51.000000000 +0200
@@ -26,5 +26,3 @@
# Cleaning
clean-dirs := static shared
-# install binary
-install-y := $(shared-y)
Index: klibc-1.5.24/usr/kinit/run-init/Kbuild
===================================================================
--- a/usr/kinit/run-init/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/kinit/run-init/Kbuild 2011-08-01 00:14:41.000000000 +0200
@@ -25,5 +25,3 @@
# Cleaning
clean-dirs := static shared
-# install binary
-install-y := $(shared-y)
Index: klibc-1.5.24/usr/klibc/Kbuild
===================================================================
--- a/usr/klibc/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/klibc/Kbuild 2011-08-01 00:18:11.000000000 +0200
@@ -177,5 +177,3 @@
$(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib))
$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
$(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib
- $(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
- $(INSTALLROOT)$(SHLIBDIR)
Index: klibc-1.5.24/usr/utils/Kbuild
===================================================================
--- a/usr/utils/Kbuild 2011-07-27 15:50:53.000000000 +0200
+++ b/usr/utils/Kbuild 2011-08-01 00:19:13.000000000 +0200
@@ -72,5 +72,3 @@
# Clean deletes the static and shared dir
clean-dirs := static shared
-# install only install the shared binaries
-install-y := $(shared-y) shared/reboot shared/poweroff
@@ -0,0 +1,25 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id 676cbb54d42c89a4832871064cfcb7ee2ad372ee
klcc-cross: Add patch to use /usr/bin/env perl
Certain configurations (such as autobuilders) may build in very
deep paths (that are longer than the #! mechanism allows) which
makes it unsafe to use the direct path for perl. In our case we know
that /usr/bin/env perl will always return ours (if it has been built).
Signed-off-by: Tom Rini <tom_rini@mentor.com>
Index: klibc-1.5.20/klcc/makeklcc.pl
===================================================================
--- a/klcc/makeklcc.pl
+++ b/klcc/makeklcc.pl
@@ -26,7 +26,7 @@ sub pathsearch($) {
return undef;
}
-print "#!${perlpath}\n";
+print "#!/usr/bin/env perl\n";
open(KLIBCCONF, "< $klibcconf\0")
or die "$0: cannot open $klibcconf: $!\n";
@@ -0,0 +1,245 @@
Patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded)
as of commit id acb6fa33fccf7196c86a3a28f927d4fa441d05eb
klibc: add wc to tools
* for use with uniboot
Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
index a52ea61..7c8ccfb 100644
--- a/usr/utils/Kbuild
+++ b/usr/utils/Kbuild
@@ -3,7 +3,7 @@
#
progs := chroot dd mkdir mkfifo mknod mount pivot_root umount
-progs += true false sleep ln mv nuke minips cat ls losetup
+progs += true false sleep ln mv nuke minips cat ls losetup wc
progs += uname halt kill readlink cpio sync dmesg modprobe
static-y := $(addprefix static/, $(progs))
@@ -62,6 +62,8 @@ static/losetup-y := losetup.o
shared/losetup-y := losetup.o
static/modprobe-y := modprobe.o
shared/modprobe-y := modprobe.o
+static/wc-y := wc.o
+shared/wc-y := wc.o
# Additionally linked targets
always := static/reboot static/poweroff shared/reboot shared/poweroff
diff --git a/usr/utils/wc.c b/usr/utils/wc.c
new file mode 100644
index 0000000..f5059fc
--- /dev/null
+++ b/usr/utils/wc.c
@@ -0,0 +1,208 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * wc implementation for busybox
+ *
+ * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+
+/* BB_AUDIT SUSv3 _NOT_ compliant -- option -m is not currently supported. */
+/* http://www.opengroup.org/onlinepubs/007904975/utilities/wc.html */
+
+/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
+ *
+ * Rewritten to fix a number of problems and do some size optimizations.
+ * Problems in the previous busybox implementation (besides bloat) included:
+ * 1) broken 'wc -c' optimization (read note below)
+ * 2) broken handling of '-' args
+ * 3) no checking of ferror on EOF returns
+ * 4) isprint() wasn't considered when word counting.
+ *
+ * TODO:
+ *
+ * When locale support is enabled, count multibyte chars in the '-m' case.
+ *
+ * NOTES:
+ *
+ * The previous busybox wc attempted an optimization using stat for the
+ * case of counting chars only. I omitted that because it was broken.
+ * It didn't take into account the possibility of input coming from a
+ * pipe, or input from a file with file pointer not at the beginning.
+ *
+ * To implement such a speed optimization correctly, not only do you
+ * need the size, but also the file position. Note also that the
+ * file position may be past the end of file. Consider the example
+ * (adapted from example in gnu wc.c)
+ *
+ * echo hello > /tmp/testfile &&
+ * (dd ibs=1k skip=1 count=0 &> /dev/null; wc -c) < /tmp/testfile
+ *
+ * for which 'wc -c' should output '0'.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#undef isspace
+#undef isprint
+#define isspace(c) ((((c) == ' ') || (((unsigned int)((c) - 9)) <= (13 - 9))))
+#define isprint(c) (((unsigned int)((c) - 0x20)) <= (0x7e - 0x20))
+#define isspace_given_isprint(c) ((c) == ' ')
+
+#define COUNT_T unsigned long
+#define COUNT_FMT "u"
+#define optind 1
+FILE *fopen_or_warn_stdin(const char *filename)
+{
+ FILE *fp = stdin;
+
+ if (filename[0]) {
+ fp = fopen(filename, "r");
+ }
+
+ return fp;
+}
+
+enum {
+ WC_LINES = 0,
+ WC_WORDS = 1,
+ WC_CHARS = 2,
+ WC_LENGTH = 3
+};
+
+int main(int argc, char **argv)
+{
+ FILE *fp;
+ const char *s, *arg;
+ const char *start_fmt = "%9"COUNT_FMT;
+ const char *fname_fmt = " %s\n";
+ COUNT_T *pcounts;
+ COUNT_T counts[4];
+ COUNT_T totals[4];
+ unsigned linepos;
+ unsigned u;
+ int num_files = 0;
+ int c;
+ signed char status = EXIT_SUCCESS;
+ signed char in_word;
+ unsigned print_type;
+
+ print_type = getopt(argc, argv, "lwcL");
+
+ if (print_type == 0) {
+ print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
+ }
+
+ argv += optind;
+ if (!argv[0]) {
+ *--argv = (char *) "wc";
+ fname_fmt = "\n";
+ if (!((print_type-1) & print_type)) /* exactly one option? */
+ start_fmt = "%"COUNT_FMT;
+ }
+
+ memset(totals, 0, sizeof(totals));
+
+ pcounts = counts;
+
+ while ((arg = *argv++) != 0) {
+ ++num_files;
+ fp = fopen_or_warn_stdin(arg);
+ if (!fp) {
+ status = EXIT_FAILURE;
+ continue;
+ }
+
+ memset(counts, 0, sizeof(counts));
+ linepos = 0;
+ in_word = 0;
+
+ do {
+ /* Our -w doesn't match GNU wc exactly... oh well */
+
+ ++counts[WC_CHARS];
+ c = getc(fp);
+ if (isprint(c)) {
+ ++linepos;
+ if (!isspace_given_isprint(c)) {
+ in_word = 1;
+ continue;
+ }
+ } else if (((unsigned int)(c - 9)) <= 4) {
+ /* \t 9
+ * \n 10
+ * \v 11
+ * \f 12
+ * \r 13
+ */
+ if (c == '\t') {
+ linepos = (linepos | 7) + 1;
+ } else { /* '\n', '\r', '\f', or '\v' */
+ DO_EOF:
+ if (linepos > counts[WC_LENGTH]) {
+ counts[WC_LENGTH] = linepos;
+ }
+ if (c == '\n') {
+ ++counts[WC_LINES];
+ }
+ if (c != '\v') {
+ linepos = 0;
+ }
+ }
+ } else if (c == EOF) {
+/* if (ferror(fp)) {
+ status = EXIT_FAILURE;
+ }
+*/ --counts[WC_CHARS];
+ goto DO_EOF; /* Treat an EOF as '\r'. */
+ } else {
+ continue;
+ }
+
+ counts[WC_WORDS] += in_word;
+ in_word = 0;
+ if (c == EOF) {
+ break;
+ }
+ } while (1);
+
+ if (totals[WC_LENGTH] < counts[WC_LENGTH]) {
+ totals[WC_LENGTH] = counts[WC_LENGTH];
+ }
+ totals[WC_LENGTH] -= counts[WC_LENGTH];
+
+ if(fp != stdin)
+ fclose(fp);
+
+ OUTPUT:
+ /* coreutils wc tries hard to print pretty columns
+ * (saves results for all files, find max col len etc...)
+ * we won't try that hard, it will bloat us too much */
+ s = start_fmt;
+ u = 0;
+ do {
+ if (print_type & (1 << u)) {
+ printf(s, pcounts[u]);
+ s = " %9"COUNT_FMT; /* Ok... restore the leading space. */
+ }
+ totals[u] += pcounts[u];
+ } while (++u < 4);
+ printf(fname_fmt, arg);
+ }
+
+ /* If more than one file was processed, we want the totals. To save some
+ * space, we set the pcounts ptr to the totals array. This has the side
+ * effect of trashing the totals array after outputting it, but that's
+ * irrelavent since we no longer need it. */
+ if (num_files > 1) {
+ num_files = 0; /* Make sure we don't get here again. */
+ arg = "total";
+ pcounts = totals;
+ --argv;
+ goto OUTPUT;
+ }
+
+ fflush(stdout);
+ exit(status);
+}
@@ -0,0 +1,2 @@
SRC_URI[md5sum] = "4df9b0d3d7f9f366c4b5c171cac3c6c3"
SRC_URI[sha256sum] = "71fac12937ead3f104aad8ac40567ecdcac1ea27474cce939f6226499b1895a2"
@@ -0,0 +1,17 @@
PR = "${INC_PR}.0"
KLIBC_UTILS_VARIANT = "static"
KLIBC_UTILS_PKGNAME = "klibc-static-utils"
FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
do_install() {
:
}
PACKAGES_${PN} = "${PN}"
FILES_${PN} = ""
require klibc-utils.inc
require klibc.inc
require klibc-checksums_${PV}.inc
@@ -0,0 +1,64 @@
KLIBC_UTILS_VARIANT ?= "shared"
KLIBC_UTILS_PKGNAME ?= "klibc-utils"
# modprobe and losetup go to ${base_sbindir}
# even though debian packages all in /usr/lib/klibc/bin
do_install_append() {
install -d ${D}${base_bindir}
install -d ${D}${base_sbindir}
# those 2 are always static
install -m 755 usr/dash/sh ${D}${base_bindir}/sh
install -m 755 usr/kinit/kinit ${D}${base_bindir}/kinit
install -m 755 usr/gzip/gzip ${D}${base_bindir}
install -m 755 usr/kinit/fstype/${KLIBC_UTILS_VARIANT}/fstype ${D}${base_bindir}
install -m 755 usr/kinit/ipconfig/${KLIBC_UTILS_VARIANT}/ipconfig ${D}${base_bindir}
install -m 755 usr/kinit/nfsmount/${KLIBC_UTILS_VARIANT}/nfsmount ${D}${base_bindir}
install -m 755 usr/kinit/resume/${KLIBC_UTILS_VARIANT}/resume ${D}${base_bindir}
install -m 755 usr/kinit/run-init/${KLIBC_UTILS_VARIANT}/run-init ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/cat ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/chroot ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/cpio ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/dd ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/dmesg ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/false ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/halt ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/kill ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/ln ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/losetup ${D}${base_sbindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/ls ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/minips ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mkdir ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mkfifo ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mknod ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/modprobe ${D}${base_sbindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mount ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mv ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/nuke ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/pivot_root ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/poweroff ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/readlink ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/reboot ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/sleep ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/sync ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/true ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/umount ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/uname ${D}${base_bindir}
install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/wc ${D}${base_bindir}
ln -s gzip ${D}${base_bindir}/gunzip
ln -s gzip ${D}${base_bindir}/zcat
}
PACKAGES_DYNAMIC = "${KLIBC_UTILS_PKGNAME}-*"
python populate_packages_prepend () {
base_bin_dir = bb.data.expand('${base_bindir}', d)
do_split_packages(d, base_bin_dir, '(.*)', '${KLIBC_UTILS_PKGNAME}-%s', 'Klibc util for %s', allow_links=True, allow_dirs=True)
base_sbin_dir = bb.data.expand('${base_sbindir}', d)
do_split_packages(d, base_sbin_dir, '(.*)', '${KLIBC_UTILS_PKGNAME}-%s', 'Klibc util for %s', allow_dirs=True)
}
+50
View File
@@ -0,0 +1,50 @@
DEPENDS = "virtual/kernel perl-native"
SECTION = "libs"
DESCRIPTION = "klibc is intended to be a minimalistic libc subset for \
use with initramfs. It is deliberately written for small size, \
minimal entaglement, and portability, not speed."
LICENSE = "BSD-ADV"
LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8b"
PACKAGE_ARCH = "${MACHINE_ARCH}"
# Prevents do_package failures with:
# debugsources.list: No such file or directory:
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
INC_PR = "r0"
KLIBC_ARCH = '${TARGET_ARCH}'
KLIBC_ARCH_armeb = 'arm'
KLIBC_ARCH_mipsel = 'mips'
KLIBC_ARCH_x86 = 'i386'
KLIBC_ARCH_i486 = 'i386'
KLIBC_ARCH_i586 = 'i386'
KLIBC_ARCH_i686 = 'i386'
KLIBC_ARCH_pentium = 'i386'
KLIBC_FETCHDIR = "1.5"
SRC_URI = "${KERNELORG_MIRROR}/linux/libs/klibc/${KLIBC_FETCHDIR}/klibc-${PV}.tar.bz2"
SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch"
SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch"
SRC_URI += "file://fstype-sane-vfat-and-jffs2-for-1.5.patch \
file://modprobe.patch \
file://dash_readopt.patch \
file://wc.patch \
file://no_strip.patch \
file://staging.patch \
file://socket.h.patch \
"
S = "${WORKDIR}/klibc-${PV}"
EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \
'CROSS_COMPILE=${TARGET_PREFIX}' \
'KLIBCKERNELSRC=${STAGING_KERNEL_DIR}' \
"
do_configure () {
ln -sf ${STAGING_KERNEL_DIR} linux
}
@@ -0,0 +1,40 @@
PR = "${INC_PR}.0"
export INST = "${D}"
do_install() {
oe_runmake install
# the crosscompiler is packaged by klcc-cross
# remove klcc
# remove also from FILES_libklibc-dev
rm ${D}${base_bindir}/klcc
# remove Linux headers .install and ..install.cmd files
find ${D}${base_libdir}/klibc/include -name '.install' -delete
find ${D}${base_libdir}/klibc/include -name '..install.cmd' -delete
# only for sh.shared and kinit.shared
install -d ${D}${base_bindir}
install -m 755 usr/dash/sh.shared ${D}${base_bindir}/sh.shared
install -m 755 usr/kinit/kinit.shared ${D}${base_bindir}/kinit.shared
install -d ${D}${base_libdir}
install -m 755 usr/klibc/klibc-*.so ${D}${base_libdir}
(cd ${D}${base_libdir}; ln -s klibc-*.so klibc.so)
}
PACKAGES = "libklibc libklibc-dev"
FILES_libklibc = "${base_libdir}/klibc-*.so"
FILES_libklibc-dev = "${base_libdir}/klibc.so \
${base_libdir}/klibc/lib/* \
${base_libdir}/klibc/include/* \
# see above
# do not package it in -dev
# ${base_bindir}/klcc \
"
require klibc-utils.inc
require klibc.inc
require klibc-checksums_${PV}.inc