Index: trunk/essentials/sys-libs/bzip2/Makefile.kmk
===================================================================
--- trunk/essentials/sys-libs/bzip2/Makefile.kmk	(revision 3322)
+++ trunk/essentials/sys-libs/bzip2/Makefile.kmk	(revision 3322)
@@ -0,0 +1,216 @@
+# $Id$
+## @file
+#
+# kNIX Makefile for bzip2
+#
+# Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
+#
+#
+# This file is part of kLIBC.
+#
+# kLIBC 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.
+#
+# kLIBC 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 kLIBC; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+DEPTH = ../../..
+include $(PATH_KBUILD)/header.kmk
+
+#
+# libbz2_s - static.
+#
+LIBRARIES += libbz2_s
+libbz2_s_TEMPLATE = usr.lib
+libbz2_s_SOURCES = \
+	blocksort.c \
+	huffman.c \
+	crctable.c \
+	randtable.c \
+	compress.c \
+	decompress.c \
+	bzlib.c
+
+#
+# libbz2_dll - dynamic import library.
+#
+LIBRARIES += libbz2_dll
+libbz2_dll_TEMPLATE = usr.lib
+libbz2_dll_SOURCES = \
+	$(PATH_TARGET)/libbz2.def
+libbz2_dll_CLEAN = \
+	$(PATH_TARGET)/libbz2.def
+
+#
+# kbz2104 - dynamic.
+#
+DLLS += kbz2104
+kbz2104_TEMPLATE = usr.lib
+kbz2104_DEFS = BZ_EXPORT
+kbz2104_SOURCES = \
+	blocksort.c \
+	huffman.c \
+	crctable.c \
+	randtable.c \
+	compress.c \
+	decompress.c \
+	bzlib.c \
+	$(PATH_TARGET)/libbz2.def
+
+$(PATH_TARGET)/libbz2.def: Makefile.kmk
+	$(RM) -f $@
+	$(APPEND) $@ "LIBRARY kbz2104 INITINSTANCE TERMINSTANCE"
+	$(APPEND) $@ "DATA MULTIPLE NONSHARED"
+	$(APPEND) $@ "EXPORTS"
+	$(APPEND) $@ "    _BZ2_bzerror                     @1"
+	$(APPEND) $@ "    _BZ2_bzclose                     @2"
+	$(APPEND) $@ "    _BZ2_bzflush                     @3"
+	$(APPEND) $@ "    _BZ2_bzwrite                     @4"
+	$(APPEND) $@ "    _BZ2_bzread                      @5"
+	$(APPEND) $@ "    _BZ2_bzdopen                     @6"
+	$(APPEND) $@ "    _BZ2_bzopen                      @7"
+	$(APPEND) $@ "    _BZ2_bzlibVersion                @8"
+	$(APPEND) $@ "    _BZ2_bzBuffToBuffDecompress      @9"
+	$(APPEND) $@ "    _BZ2_bzBuffToBuffCompress        @10"
+	$(APPEND) $@ "    _BZ2_bzReadGetUnused             @11"
+	$(APPEND) $@ "    _BZ2_bzRead                      @12"
+	$(APPEND) $@ "    _BZ2_bzReadClose                 @13"
+	$(APPEND) $@ "    _BZ2_bzReadOpen                  @14"
+	$(APPEND) $@ "    _BZ2_bzWriteClose64              @15"
+	$(APPEND) $@ "    _BZ2_bzWriteClose                @16"
+	$(APPEND) $@ "    _BZ2_bzWrite                     @17"
+	$(APPEND) $@ "    _BZ2_bzWriteOpen                 @18"
+	$(APPEND) $@ "    _BZ2_bzDecompressEnd             @19"
+	$(APPEND) $@ "    _BZ2_bzDecompress                @20"
+	$(APPEND) $@ "    _BZ2_bzDecompressInit            @21"
+	$(APPEND) $@ "    _BZ2_bzCompressEnd               @22"
+	$(APPEND) $@ "    _BZ2_bzCompress                  @23"
+	$(APPEND) $@ "    _BZ2_bzCompressInit              @24"
+
+#
+# The programs: bzip2, bzip2recover, bzgrep, bzmore, bzdiff and their aliases.
+#
+PROGRAMS += bzip2
+bzip2_TEMPLATE = usr.bin
+bzip2_INST = usr/bin/bzip2$(SUFF_EXE) usr/bin/bunzip2$(SUFF_EXE) usr/bin/bzcat$(SUFF_EXE)
+bzip2_SOURCES = bzip2.c
+bzip2_LIBS = $(TARGET_libbz2_s)
+
+PROGRAMS += bzip2recover
+bzip2recover_TEMPLATE = usr.bin
+bzip2recover_SOURCES = bzip2recover.c
+bzip2recover_LIBS = $(TARGET_libbz2_s)
+
+INSTALLS += bzip2-scripts
+bzip2-scripts_TEMPLATE = usr.bin.script
+bzip2-scripts_SOURCES = \
+	bzgrep \
+	bzmore \
+	bzdiff
+bzip2-scripts_SYMLINKS = \
+	bzegrep=>bzgrep \
+	bzfgrep=>bzgrep \
+	bzless=>bzmore \
+	bzcmp=>bzdiff
+
+#
+# Install headers.
+#
+INSTALLS += libbz2-headers
+libbz2-headers_TEMPLATE = usr.include
+libbz2-headers_SOURCES = \
+	bzlib.h
+
+#
+# The man pages.
+#
+INSTALLS += bzip2-manpages
+bzip2-manpages_TEMPLATE = usr.bin.man
+bzip2-manpages_SOURCES = \
+	bzip2.1 \
+	bzdiff.1 \
+	bzgrep.1 \
+	bzmore.1 \
+	$(PATH_TARGET)/bunzip2.1 \
+	$(PATH_TARGET)/bzcat.1 \
+	$(PATH_TARGET)/bzip2recover.1 \
+	$(PATH_TARGET)/bzegrep.1 \
+	$(PATH_TARGET)/bzfgrep.1 \
+	$(PATH_TARGET)/bzless.1 \
+	$(PATH_TARGET)/bzcmp.1
+
+$(PATH_TARGET)/bunzip2.1 \
+$(PATH_TARGET)/bzcat.1 \
+$(PATH_TARGET)/bzip2recover.1: | $(call DIRDEP,$(PATH_TARGET))
+	$(RM) -f $@
+	$(APPEND) $@ ".so man1/bzip2.1"
+
+$(PATH_TARGET)/bzegrep.1 \
+$(PATH_TARGET)/bzfgrep.1: | $(call DIRDEP,$(PATH_TARGET))
+	$(RM) -f $@
+	$(APPEND) $@ ".so man1/bzgrep.1"
+
+$(PATH_TARGET)/bzless.1: | $(call DIRDEP,$(PATH_TARGET))
+	$(RM) -f $@
+	$(APPEND) $@ ".so man1/bzmore.1"
+
+$(PATH_TARGET)/bzcmp.1: | $(call DIRDEP,$(PATH_TARGET))
+	$(RM) -f $@
+	$(APPEND) $@ ".so man1/bzdiff.1"
+
+#
+# Documentation.
+#
+INSTALLS += bzip2-docs
+bzip2-docs_TEMPLATE = usr.bin.doc
+bzip2-docs_SOURCES = \
+	CHANGES \
+	README \
+	README.COMPILATION.PROBLEMS \
+	README.XML.STUFF \
+	bzip2.txt \
+	manual.html \
+	manual.pdf \
+	manual.ps \
+	manual.xml
+
+#
+# Integrity checks.
+#
+OTHERS += $(PATH_TARGET)/bzip2-tests
+OTHER_CLEAN += \
+	$(PATH_TARGET)/sample1.rb2 \
+	$(PATH_TARGET)/sample2.rb2 \
+	$(PATH_TARGET)/sample3.rb2 \
+	$(PATH_TARGET)/sample1.tst \
+	$(PATH_TARGET)/sample2.tst \
+	$(PATH_TARGET)/sample3.tst
+
+$(PATH_TARGET)/bzip2-tests: $$(TARGET_bzip2)
+	$(RM) -f $@
+	$(TARGET_bzip2) -1  < sample1.ref > $(PATH_TARGET)/sample1.rb2
+	$(TARGET_bzip2) -2  < sample2.ref > $(PATH_TARGET)/sample2.rb2
+	$(TARGET_bzip2) -3  < sample3.ref > $(PATH_TARGET)/sample3.rb2
+	$(TARGET_bzip2) -d  < sample1.bz2 > $(PATH_TARGET)/sample1.tst
+	$(TARGET_bzip2) -d  < sample2.bz2 > $(PATH_TARGET)/sample2.tst
+	$(TARGET_bzip2) -ds < sample3.bz2 > $(PATH_TARGET)/sample3.tst
+	cmp sample1.bz2 $(PATH_TARGET)/sample1.rb2
+	cmp sample2.bz2 $(PATH_TARGET)/sample2.rb2
+	cmp sample3.bz2 $(PATH_TARGET)/sample3.rb2
+	cmp sample1.ref $(PATH_TARGET)/sample1.tst
+	cmp sample2.ref $(PATH_TARGET)/sample2.tst
+	cmp sample3.ref $(PATH_TARGET)/sample3.tst
+	$(APPEND) $@ done
+
+include $(PATH_KBUILD)/footer.kmk
+
