Add GNU grep to sys-apps
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 28 Sep 2018 20:29:52 +0000 (16:29 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 2 Oct 2018 18:07:01 +0000 (14:07 -0400)
This will get built and installed with the other apps.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
Makefile
tools/sys-apps/grep/.gitignore [new file with mode: 0644]
tools/sys-apps/grep/Makefile [new file with mode: 0644]
tools/sys-apps/grep/akaros-patches/3.1/0001-config.patch [new file with mode: 0644]
tools/sys-apps/grep/akaros-patches/3.1/0002-skip-path-update-when-cross-compiling.patch [new file with mode: 0644]

index c4e71b0..5801394 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -698,6 +698,8 @@ apps-install: $(app-dirs-install)
        @echo perf install succeeded.
        @$(call make_as_parent, -C tools/sys-apps/bash install) > build_logs/bash_install.log 2>&1
        @echo bash install succeeded.
+       @$(call make_as_parent, -C tools/sys-apps/grep install) > build_logs/grep_install.log 2>&1
+       @echo grep install succeeded.
 
 PHONY += apps-clean
 apps-clean: $(app-dirs-clean)
@@ -712,6 +714,8 @@ apps-clean: $(app-dirs-clean)
        @echo perf clean succeeded.
        @$(call make_as_parent, -C tools/sys-apps/bash clean) > build_logs/bash_clean.log 2>&1
        @echo bash clean succeeded.
+       @$(call make_as_parent, -C tools/sys-apps/grep clean) > build_logs/grep_clean.log 2>&1
+       @echo grep clean succeeded.
 
 # Cross Compiler
 # =========================================================================
diff --git a/tools/sys-apps/grep/.gitignore b/tools/sys-apps/grep/.gitignore
new file mode 100644 (file)
index 0000000..df41b56
--- /dev/null
@@ -0,0 +1 @@
+grep-*
diff --git a/tools/sys-apps/grep/Makefile b/tools/sys-apps/grep/Makefile
new file mode 100644 (file)
index 0000000..080400b
--- /dev/null
@@ -0,0 +1,57 @@
+include ../../Makefrag
+
+########## Package-specific variables
+version := 3.1
+src-dir = grep-$(version)
+build-dir = $(src-dir)/build
+tarball = grep-$(version).tar.xz
+fetch-url = http://ftp.gnu.org/gnu/grep/$(tarball)
+config-opts = --prefix=/usr \
+              --bindir=/bin \
+              --disable-nls \
+              --host=x86_64-ucb-akaros \
+              --build=i686-pc-linux-gnu
+
+########## Generic Infrastructure
+
+PHONY := all
+all: make
+
+%.tar.xz:
+       $(Q)wget $(fetch-url)
+
+akaros-patches := $(sort $(wildcard akaros-patches/$(version)/*))
+
+$(build-dir): $(tarball) $(akaros-patches)
+       rm -fr $(src-dir)
+       tar -xf $<
+       $(Q)mkdir $(build-dir) &&                                                  \
+       for i in $(akaros-patches); do                                             \
+               (cd $(src-dir) && patch -p1 < ../$$i);                                 \
+       done
+
+PHONY += config
+$(build-dir)/Makefile config: $(build-dir)
+       cd $(build-dir) && env ../configure $(config-opts) && \
+       sed -i '/^.run_help2man = .*dummy-man/s/^.//' Makefile &&  \
+       sed -i '/^run_help2man = .*help2man/d' Makefile
+
+PHONY += make
+make: config
+       $(Q)$(MAKE) -C $(build-dir)
+
+PHONY += install
+install: make
+       $(Q)$(MAKE) -C $(build-dir) install-exec DESTDIR=$(KFS_ROOT)
+
+PHONY += clean
+clean:
+       $(Q)[ -d $(build-dir) ] &&                                                 \
+           [ -f $(build-dir)/Makefile ] &&                                        \
+           $(MAKE) -C $(build-dir) clean || true
+
+PHONY += mrproper
+mrproper:
+       $(Q)rm -rf $(src-dir)
+
+.PHONY: $(PHONY)
diff --git a/tools/sys-apps/grep/akaros-patches/3.1/0001-config.patch b/tools/sys-apps/grep/akaros-patches/3.1/0001-config.patch
new file mode 100644 (file)
index 0000000..6ce144e
--- /dev/null
@@ -0,0 +1,26 @@
+diff -ur a/build-aux/config.guess b/build-aux/config.guess
+--- a/build-aux/config.guess   2016-01-16 12:11:09.000000000 -0500
++++ b/build-aux/config.guess   2016-05-25 13:45:03.633843452 -0400
+@@ -233,6 +233,10 @@
+       UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+       exit ;;
++    *:Akaros:*:*)
++      UNAME_MACHINE_ARCH=x86_64
++      echo x86_64-ucb-akaros1.0
++      exit ;;
+     *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+diff -ur a/build-aux/config.sub b/build-aux/config.sub
+--- a/build-aux/config.sub     2016-01-16 12:11:09.000000000 -0500
++++ b/build-aux/config.sub     2016-05-25 13:45:28.554516328 -0400
+@@ -1378,7 +1378,7 @@
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+             | -sym* | -kopensolaris* | -plan9* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+-            | -aos* | -aros* | -cloudabi* | -sortix* \
++            | -akaros* | -aos* | -aros* | -cloudabi* | -sortix* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
diff --git a/tools/sys-apps/grep/akaros-patches/3.1/0002-skip-path-update-when-cross-compiling.patch b/tools/sys-apps/grep/akaros-patches/3.1/0002-skip-path-update-when-cross-compiling.patch
new file mode 100644 (file)
index 0000000..3dd944b
--- /dev/null
@@ -0,0 +1,12 @@
+--- a/cfg.mk   2018-09-28 14:33:33.652414862 -0400
++++ b/cfg.mk   2018-09-28 14:33:37.916437913 -0400
+@@ -17,7 +17,9 @@
+ # Cause the tool(s) built by this package to be used also when running
+ # commands via e.g., "make syntax-check".  Doing this a little sooner
+ # would have avoided a grep infloop bug.
++ifeq ($(build_triplet), $(host_triplet))
+ export PATH := $(builddir)/src$(PATH_SEPARATOR)$(PATH)
++endif
+ # Used in maint.mk's web-manual rule
+ manual_title = GNU Grep: Print lines matching a pattern