--- /dev/null
+diff --git a/src/Makefile.am b/src/Makefile.am
+index cd99d2d..0b29004 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -47,12 +47,15 @@ libfont_a_SOURCES = \
+ loadunimap.c loadunimap.h \
+ kdfontop.c kdfontop.h
+
++libfont_a_CFLAGS = -fPIC
++
+ ALL_S = paths.h
+
+ chvt_SOURCES = $(ALL_S) chvt.c
+ clrunimap_SOURCES = $(ALL_S) clrunimap.c
+ deallocvt_SOURCES = $(ALL_S) deallocvt.c
+ fgconsole_SOURCES = $(ALL_S) fgconsole.c
++kbdrate_SOURCES = kbdrate.c
+ getkeycodes_SOURCES = $(ALL_S) getkeycodes.c
+ getunimap_SOURCES = $(ALL_S) getunimap.c
+ kbd_mode_SOURCES = $(ALL_S) kbd_mode.c
+@@ -75,10 +78,66 @@ kbdinfo_SOURCES = $(ALL_S) kbdinfo.c
+ dumpkeys_SOURCES = $(ALL_S) dumpkeys.c
+ loadkeys_SOURCES = $(ALL_S) loadkeys.c
+
+-mapscrn_CFLAGS = -DMAIN
+-loadunimap_CFLAGS = -DMAIN
++mapscrn_CFLAGS = -DMAIN -fPIC
++loadunimap_CFLAGS = -DMAIN -fPIC
++dumpkeys_CFLAGS = -fPIC
++loadkeys_CFLAGS = -fPIC
++showkey_CFLAGS = -fPIC
++setfont_CFLAGS = -fPIC
++showconsolefont_CFLAGS = -fPIC
++setleds_CFLAGS = -fPIC
++setmetamode_CFLAGS = -fPIC
++kbd_mode_CFLAGS = -fPIC
++psfxtable_CFLAGS = -fPIC
++fgconsole_CFLAGS = -fPIC
++kbdrate_CFLAGS = -fPIC
++chvt_CFLAGS = -fPIC
++deallocvt_CFLAGS = -fPIC
++openvt_CFLAGS = -fPIC
++kbdinfo_CFLAGS = -fPIC
++setvtrgb_CFLAGS = -fPIC
++getkeycodes_CFLAGS = -fPIC
++setkeycodes_CFLAGS = -fPIC
++resizecons_CFLAGS = -fPIC
++setlogcons_CFLAGS = -fPIC
++setvesablank_CFLAGS = -fPIC
++getunimap_CFLAGS = -fPIC
++clrunimap_CFLAGS = -fPIC
++setpalette_CFLAGS = -fPIC
++screendump_CFLAGS = -fPIC
++
++mapscrn_LDFLAGS = -pie
++loadunimap_LDFLAGS = -pie
++dumpkeys_LDFLAGS = -pie
++loadkeys_LDFLAGS = -pie
++showkey_LDFLAGS = -pie
++setfont_LDFLAGS = -pie
++showconsolefont_LDFLAGS = -pie
++setleds_LDFLAGS = -pie
++setmetamode_LDFLAGS = -pie
++kbd_mode_LDFLAGS = -pie
++psfxtable_LDFLAGS = -pie
++fgconsole_LDFLAGS = -pie
++kbdrate_LDFLAGS = -pie
++chvt_LDFLAGS = -pie
++deallocvt_LDFLAGS = -pie
++openvt_LDFLAGS = -pie
++kbdinfo_LDFLAGS = -pie
++ebdinfo_LDFLAGS = -pie
++setvtrgb_LDFLAGS = -pie
++getkeycodes_LDFLAGS = -pie
++setkeycodes_LDFLAGS = -pie
++resizecons_LDFLAGS = -pie
++setlogcons_LDFLAGS = -pie
++setvesablank_LDFLAGS = -pie
++getunimap_LDFLAGS = -pie
++clrunimap_LDFLAGS = -pie
++setpalette_LDFLAGS = -pie
++screendump_LDFLAGS = -pie
++
+
+ noinst_LIBRARIES = libfont.a
++noinst_CFLAGS = -fPIC
+ LDADD = \
+ libfont.a \
+ libkeymap/libkeymap.la \
+diff --git a/src/libcommon/Makefile.am b/src/libcommon/Makefile.am
+index 25553a7..4c6a489 100644
+--- a/src/libcommon/Makefile.am
++++ b/src/libcommon/Makefile.am
+@@ -8,4 +8,6 @@ libcommon_a_SOURCES = \
+ xmalloc.c \
+ libcommon.h
+
++libcommon_a_CFLAGS = -fPIC
++
+ noinst_LIBRARIES = libcommon.a
+diff --git a/src/libkbdfile/Makefile.am b/src/libkbdfile/Makefile.am
+index 247f128..65f703d 100644
+--- a/src/libkbdfile/Makefile.am
++++ b/src/libkbdfile/Makefile.am
+@@ -20,6 +20,8 @@ libkbdfile_la_SOURCES = \
+ init.c \
+ kbdfile.c
+
++libkbdfile_la_CFLAGS = -fPIC
++
+ KBDFILE_CURRENT = 1
+ KBDFILE_REVISION = 0
+ KBDFILE_AGE = 0
+diff --git a/src/libkeymap/Makefile.am b/src/libkeymap/Makefile.am
+index b6a99e2..11bb3bf 100644
+--- a/src/libkeymap/Makefile.am
++++ b/src/libkeymap/Makefile.am
+@@ -62,6 +62,7 @@ libkeymap_la_SOURCES = \
+ ksyms.c ksyms.h $(ksyms_headers) \
+ $(srcdir)/../paths.h
+
++libkeymap_la_CFLAGS = -fPIC
+ libkeymap_la_LIBADD = $(builddir)/../libkbdfile/libkbdfile.la
+
+ if BUILD_LIBKEYMAP
+diff --git a/src/vlock/Makefile.am b/src/vlock/Makefile.am
+index 49ce5b6..cdff372 100644
+--- a/src/vlock/Makefile.am
++++ b/src/vlock/Makefile.am
+@@ -19,5 +19,7 @@ vlock_SOURCES = \
+ vlock.c \
+ vlock.h \
+ vt.c
++vlock_CFLAGS = -fPIC
++vlock_LDFLAGS = -pie
+
+ vlock_LDADD = $(top_builddir)/src/libcommon/libcommon.a @PAM_LIBS@
--- /dev/null
+Name: kbd
+Version: 2.2.0
+Release: 0
+Summary: Tools for configuring the console (keyboard, virtual terminals, etc
+
+License: GPL-2.0+
+Url: http://ftp.altlinux.org/pub/people/legion/kbd
+Group: Base/Utilities
+Source0: %{name}-%{version}.tar.bz2
+Source2: kbd-latsun-fonts.tar.bz2
+Source3: kbd-latarcyrheb-16-fixed.tar.bz2
+Source4: fr-dvorak.tar.bz2
+Source5: kbd-latarcyrheb-32.tar.bz2
+Source6: Add_pie_compile_option.patch
+Source1001: kbd.manifest
+
+BuildRequires: bison
+BuildRequires: flex
+BuildRequires: gettext
+BuildRequires: pkgconfig(check)
+BuildRequires: pam-devel
+BuildRequires: fdupes
+Requires: %{name}-misc = %{version}
+
+%description
+The %{name} package contains tools for managing a Linux
+system's console's behavior, including the keyboard, the screen
+fonts, the virtual terminals and font files.
+
+%package misc
+Summary: Data for kbd package
+BuildArch: noarch
+
+%description misc
+The %{name}-misc package contains data for kbd package - console fonts,
+keymaps etc. Please note that %{name}-misc is not helpful without kbd.
+
+%prep
+%setup -q -a 2 -a 3 -a 4 -a 5
+cp %{SOURCE1001} .
+%{__patch} -p1 < %{SOURCE6}
+
+# 7-bit maps are obsolete; so are non-euro maps
+pushd data/keymaps/i386
+mv qwerty/fi.map qwerty/fi-old.map
+#cp qwerty/fi-latin9.map qwerty/fi.map
+cp qwerty/pt-latin9.map qwerty/pt.map
+cp qwerty/sv-latin1.map qwerty/se-latin1.map
+
+mv azerty/fr.map azerty/fr-old.map
+cp azerty/fr-latin9.map azerty/fr.map
+
+cp azerty/fr-latin9.map azerty/fr-latin0.map # legacy alias
+
+# Rename conflicting keymaps
+mv fgGIod/trf.map fgGIod/trf-fgGIod.map
+mv olpc/es.map olpc/es-olpc.map
+mv olpc/pt.map olpc/pt-olpc.map
+mv qwerty/cz.map qwerty/cz-qwerty.map
+popd
+
+# remove obsolete "gr" translation
+pushd po
+rm -f gr.po gr.gmo
+popd
+
+%build
+%if "%{asan}" == "1"
+%restore_fcommon
+%endif
+
+autoreconf -fi
+%configure --prefix=%{_prefix} \
+ --datadir=%{_prefix}/lib/kbd \
+ --mandir=%{_mandir} \
+ --localedir=%{_datadir}/locale \
+ --disable-nls
+
+%__make %{?_smp_mflags}
+
+%install
+%make_install
+
+# ro_win.map.gz is useless
+rm -f %{buildroot}/%{_prefix}/lib/kbd/keymaps/i386/qwerty/ro_win.map.gz
+
+# Create additional name for Serbian latin keyboard
+ln -sf sr-cy.map.gz %{buildroot}/%{_prefix}/lib/kbd/keymaps/i386/qwerty/sr-latin.map.gz
+
+# The rhpl keyboard layout table is indexed by kbd layout names, so we need a
+# Korean keyboard
+ln -sf us.map.gz %{buildroot}/%{_prefix}/lib/kbd/keymaps/i386/qwerty/ko.map.gz
+
+# Some microoptimization
+sed -i -e 's,\<kbd_mode\>,/usr/bin/kbd_mode,g;s,\<setfont\>,/usr/bin/setfont,g' \
+ %{buildroot}/%{_bindir}/unicode_start
+
+# Link open to openvt
+ln -sf openvt %{buildroot}%{_bindir}/open
+
+## Move locale files to correct place
+#cp -r %%{buildroot}/lib/kbd/locale/ %%{buildroot}%%{_datadir}/locale
+#rm -rf %%{buildroot}/lib/kbd/locale
+
+%fdupes %{buildroot}%{_prefix}/lib/kbd
+
+%docs_package
+
+%check
+# %__make check || exit 0
+
+
+%files
+%manifest %{name}.manifest
+%license COPYING
+%{_bindir}/*
+
+%files misc
+%manifest %{name}.manifest
+%{_prefix}/lib/kbd