diff --git a/lua-expat.spec b/lua-expat.spec
index 8603044..2db131d 100644
--- a/lua-expat.spec
+++ b/lua-expat.spec
@@ -1,6 +1,10 @@
 %define luaver 5.2
+%define luavercompat 5.1
 %define lualibdir %{_libdir}/lua/%{luaver}
 %define luapkgdir %{_datadir}/lua/%{luaver}
+%define luacompatlibdir %{_libdir}/lua/%{luavercompat}
+%define luacompatpkgdir %{_datadir}/lua/%{luavercompat}
+%define lua51dir %{_builddir}/lua51-%{name}-%{version}-%{release}
 
 Name:           lua-expat
 Version:        1.3.0
@@ -17,21 +21,48 @@ BuildRequires:  lua >= %{luaver}, lua-devel >= %{luaver}
 BuildRequires:  expat-devel
 Requires:       lua >= %{luaver}
 
+%if 0%{?fedora} >= 20
+BuildRequires:  compat-lua >= %{luavercompat}, compat-lua-devel >= %{luavercompat}
+%endif
+
 %description
 LuaExpat is a SAX XML parser based on the Expat library.
 
+%if 0%{?fedora} >= 20
+%package compat
+Summary:        SAX XML parser based on the Expat library
+Group:          Development/Libraries
+
+%description compat
+LuaExpat is a SAX XML parser based on the Expat library.
+%endif
+
 %prep
 %setup -q -n luaexpat-%{version}
 
+%if 0%{?fedora} >= 20
+rm -rf %{lua51dir}
+cp -a . %{lua51dir}
+%endif
 
 %build
-make %{?_smp_mflags} LUA_CDIR=%{lualibdir} LUA_LDIR=%{luapkgdir} LUA_INC=-I%{_includedir} EXPAT_INC=-I%{_includedir} CFLAGS="%{optflags} -fPIC"
+make %{?_smp_mflags} LUA_V=%{luaver} LUA_CDIR=%{lualibdir} LUA_LDIR=%{luapkgdir} LUA_INC=-I%{_includedir} EXPAT_INC=-I%{_includedir} CFLAGS="%{optflags} -fPIC"
 
+%if 0%{?fedora} >= 20
+pushd %{lua51dir}
+make %{?_smp_mflags} LUA_V=%{luavercompat} LUA_CDIR=%{luacompatlibdir} LUA_LDIR=%{luacompatpkgdir} LUA_INC=-I%{_includedir}/lua-%{luavercompat} EXPAT_INC=-I%{_includedir} CFLAGS="%{optflags} -fPIC"
+popd
+%endif
 
 %install
 rm -rf %{buildroot}
 make install DESTDIR=%{buildroot} LUA_CDIR=%{lualibdir} LUA_LDIR=%{luapkgdir} INSTALL='install -p'
 
+%if 0%{?fedora} >= 20
+pushd %{lua51dir}
+make install DESTDIR=%{buildroot} LUA_CDIR=%{luacompatlibdir} LUA_LDIR=%{luacompatpkgdir} INSTALL='install -p'
+popd
+%endif
 
 %check
 lua -e 'package.cpath="./src/?.so;"..package.cpath; dofile("tests/test.lua");'
@@ -47,6 +78,13 @@ rm -rf %{buildroot}
 %{lualibdir}/*
 %{luapkgdir}/*
 
+%if 0%{?fedora} >= 20
+%files compat
+%defattr(-,root,root,-)
+%doc README doc/us/*
+%{luacompatlibdir}/*
+%{luacompatpkgdir}/*
+%endif
 
 %changelog
 * Wed Apr 23 2014 Robert Scheck <robert@fedoraproject.org> - 1.3.0-1
