[packages/lua51] add debian_make.patch, build c++ library

glen glen at pld-linux.org
Wed Aug 27 18:26:29 CEST 2014


commit b7fe5f1e031523902f7d69f2a22f2e2c0cb83565
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Aug 27 19:25:31 2014 +0300

    add debian_make.patch, build c++ library
    
    NOTE: using debian names now, with compat links to pld names

 lua-c++.pc.in |  25 +++++++++++
 lua.pc.in     |  25 +++++++++++
 lua51.spec    | 135 ++++++++++++++++++++++++++++++++++++++++++----------------
 3 files changed, 148 insertions(+), 37 deletions(-)
---
diff --git a/lua51.spec b/lua51.spec
index 32ab791..4c0beea 100644
--- a/lua51.spec
+++ b/lua51.spec
@@ -1,17 +1,20 @@
 #
 # Conditional build:
 %bcond_with	luastatic        # build dietlibc-based static lua version (broken)
-#
+
 Summary:	A simple lightweight powerful embeddable programming language
 Summary(pl.UTF-8):	Prosty, lekki ale potężny, osadzalny język programowania
 Name:		lua51
 Version:	5.1.5
-Release:	1
+Release:	2
 License:	MIT
 Group:		Development/Languages
 Source0:	http://www.lua.org/ftp/lua-%{version}.tar.gz
 # Source0-md5:	2e115fe26e435e33b0d5c022e4490567
+Source1:	lua.pc.in
+Source2:	lua-c++.pc.in
 Patch0:		%{name}-link.patch
+Patch1:		debian_make.patch
 URL:		http://www.lua.org/
 %{?with_luastatic:BuildRequires:       dietlibc-static}
 BuildRequires:	readline-devel
@@ -19,6 +22,12 @@ BuildRequires:	sed >= 4.0
 Requires:	%{name}-libs = %{version}-%{release}
 Provides:	lua = %{version}
 Obsoletes:	lua < 4.0.1
+# Provide old SONAME to avoid rebuilds
+%ifarch %{x8664}
+Provides:	liblua.so.5.1()(64bit)
+%else
+Provides:	liblua.so.5.1
+%endif
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -56,11 +65,23 @@ lua 5.1.x libraries.
 %description libs -l pl.UTF-8
 Biblioteki lua 5.1.x.
 
+%package libs-c++
+Summary:	lua 5.1.x libraries
+Summary(pl.UTF-8):	Biblioteki lua 5.1.x
+Group:		Libraries
+
+%description libs-c++
+lua 5.1.x C++ libraries.
+
+%description libs-c++ -l pl.UTF-8
+Biblioteki lua 5.1.x C++.
+
 %package devel
 Summary:	Header files for Lua
 Summary(pl.UTF-8):	Pliki nagłówkowe dla Lua
 Group:		Development/Languages
 Requires:	%{name}-libs = %{version}-%{release}
+Requires:	%{name}-libs-c++ = %{version}-%{release}
 Provides:	lua-devel = %{version}
 
 %description devel
@@ -98,9 +119,12 @@ Statycznie skonsolidowany interpreter lua.
 %prep
 %setup -q -n lua-%{version}
 %patch0 -p1
+%patch1 -p1
 sed -r -i 's|(#define LUA_ROOT.*)%{_prefix}/local/|\1%{_prefix}/|g' src/luaconf.h
 sed -r -i 's|(#define LUA_CDIR.*)lib/|\1%{_lib}/|g' src/luaconf.h
 
+cp -p %{SOURCE1} %{SOURCE2} .
+
 %build
 %if %{with luastatic}
 %{__make} all \
@@ -112,53 +136,69 @@ mv src/luac luac.static
 %{__make} clean
 %endif
 
-%{__make} -j1 all \
-	PLAT=linux \
+%{__make} debian_linux \
+	RPATH=%{_libdir} \
 	CC="%{__cc}" \
-	CFLAGS="%{rpmcflags} -Wall -fPIC -DPIC -D_GNU_SOURCE -DLUA_USE_LINUX"
-
-#rm -f test/{lua,luac}
+	CXX="%{__cxx}" \
+	CFLAGS="%{rpmcflags} -Wall -fPIC -DPIC -D_GNU_SOURCE -DLUA_USE_LINUX" \
+	CXXFLAGS="%{rpmcxxflags} -Wall -fPIC -DPIC -D_GNU_SOURCE -DLUA_USE_LINUX"
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_libdir}/lua}
+install -d $RPM_BUILD_ROOT{%{_libdir}/lua/5.1,%{_datadir}/lua/5.1,%{_pkgconfigdir}}
 
-%{__make} install \
+%{__make} debian_install \
 	INSTALL_TOP=$RPM_BUILD_ROOT%{_prefix} \
 	INSTALL_INC=$RPM_BUILD_ROOT%{_includedir}/lua51 \
 	INSTALL_LIB=$RPM_BUILD_ROOT%{_libdir} \
 	INSTALL_MAN=$RPM_BUILD_ROOT%{_mandir}/man1 \
 	INSTALL_CMOD=$RPM_BUILD_ROOT%{_libdir}/lua/5.1
 
-# change name from lua to lua51
-for i in $RPM_BUILD_ROOT%{_bindir}/* ; do mv ${i}{,51} ; done
-mv $RPM_BUILD_ROOT%{_mandir}/man1/lua{,51}.1
-mv $RPM_BUILD_ROOT%{_mandir}/man1/luac{,51}.1
-mv $RPM_BUILD_ROOT%{_libdir}/liblua{,51}.a
-
-install src/liblua.so.5.1 $RPM_BUILD_ROOT%{_libdir}
-ln -s liblua.so.5.1 $RPM_BUILD_ROOT%{_libdir}/liblua51.so
+# generate autodeps
+chmod +x $RPM_BUILD_ROOT%{_libdir}/lib*.so*
 
 %if %{with luastatic}
-install lua.static $RPM_BUILD_ROOT%{_bindir}/lua51.static
-install luac.static $RPM_BUILD_ROOT%{_bindir}/luac51.static
+install -p lua.static $RPM_BUILD_ROOT%{_bindir}/lua51.static
+install -p luac.static $RPM_BUILD_ROOT%{_bindir}/luac51.static
 %endif
 
-# create pkgconfig file
-install -d $RPM_BUILD_ROOT%{_pkgconfigdir}
-cat > $RPM_BUILD_ROOT%{_pkgconfigdir}/lua51.pc <<'EOF'
+# alias to old pld names
+ln -s liblua5.1.so $RPM_BUILD_ROOT%{_libdir}/liblua51.so
+ln -s liblua5.1.a $RPM_BUILD_ROOT%{_libdir}/liblua51.a
+ln -s lua5.1.pc $RPM_BUILD_ROOT%{_pkgconfigdir}/lua51.pc
+ln -s liblua5.1.so.0 $RPM_BUILD_ROOT%{_libdir}/liblua.so.5.1
+
+# we have pkgconfig files, rm .la
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/liblua5.1.la
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/liblua5.1-c++.la
+
+# create pkgconfig files
+cat > $RPM_BUILD_ROOT%{_pkgconfigdir}/lua5.1.pc <<'EOF'
+major_version=5.1
+version=%{version}
+lib_name_include=lua5.1
+
+prefix=%{_prefix}
+exec_prefix=%{_exec_prefix}
+libdir=%{_libdir}
+interpreter=%{_bindir}/lua5.1
+compiler=%{_bindir}/luac5.1
+
+$(cat lua.pc.in)
+EOF
+
+cat > $RPM_BUILD_ROOT%{_pkgconfigdir}/lua5.1-c++.pc <<'EOF'
+major_version=5.1
+version=%{version}
+lib_name_include=lua5.1
+
 prefix=%{_prefix}
 exec_prefix=%{_exec_prefix}
-includedir=%{_includedir}/%{name}
 libdir=%{_libdir}
-interpreter=%{_bindir}/lua51
-compiler=%{_bindir}/luac51
-
-Name: Lua
-Description: An extension programming language
-Version: %{version}
-Cflags: -I%{_includedir}/%{name}
-Libs: -L%{_libdir} -llua51 -ldl -lm
+interpreter=%{_bindir}/lua5.1
+compiler=%{_bindir}/luac5.1
+
+$(cat lua-c++.pc.in)
 EOF
 
 %clean
@@ -167,32 +207,53 @@ rm -rf $RPM_BUILD_ROOT
 %post   libs -p /sbin/ldconfig
 %postun libs -p /sbin/ldconfig
 
+%post   libs-c++ -p /sbin/ldconfig
+%postun libs-c++ -p /sbin/ldconfig
+
+%triggerpostun -- %{name} < 5.1.5-1.2
+# restore symlink which ldconfig removed (it was ghost of old package)
+ln -s liblua5.1.so.0 %{_libdir}/liblua.so.5.1 || :
+
 %files
 %defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/lua51
-%attr(755,root,root) %{_bindir}/luac51
-%{_mandir}/man1/lua51.1*
-%{_mandir}/man1/luac51.1*
+%attr(755,root,root) %{_bindir}/lua5.1
+%attr(755,root,root) %{_bindir}/luac5.1
+%{_mandir}/man1/lua5.1.1*
+%{_mandir}/man1/luac5.1.1*
 
 %files libs
 %defattr(644,root,root,755)
 %doc COPYRIGHT HISTORY README
-%attr(755,root,root) %{_libdir}/liblua.so.*.*
+%attr(755,root,root) %{_libdir}/liblua.so.5.1
+%attr(755,root,root) %{_libdir}/liblua5.1.so.*.*.*
+%ghost %{_libdir}/liblua5.1.so.0
 %dir %{_libdir}/lua
 %{_libdir}/lua/5.1
 %dir %{_datadir}/lua
 %{_datadir}/lua/5.1
 
+%files libs-c++
+%defattr(644,root,root,755)
+%doc COPYRIGHT HISTORY README
+%attr(755,root,root) %{_libdir}/liblua5.1-c++.so.*.*.*
+%ghost %{_libdir}/liblua5.1-c++.so.0
+
 %files devel
 %defattr(644,root,root,755)
 %doc doc/*.{html,css,gif} test
-%attr(755,root,root) %{_libdir}/liblua51.so
+%{_libdir}/liblua5.1.so
+%{_libdir}/liblua5.1-c++.so
+%{_libdir}/liblua51.so
 %{_includedir}/lua51
+%{_pkgconfigdir}/lua5.1-c++.pc
+%{_pkgconfigdir}/lua5.1.pc
 %{_pkgconfigdir}/lua51.pc
 
 %files static
 %defattr(644,root,root,755)
+%{_libdir}/liblua5.1.a
 %{_libdir}/liblua51.a
+%{_libdir}/liblua5.1-c++.a
 
 %if %{with luastatic}
 %files luastatic
diff --git a/lua-c++.pc.in b/lua-c++.pc.in
new file mode 100644
index 0000000..f68b4f8
--- /dev/null
+++ b/lua-c++.pc.in
@@ -0,0 +1,25 @@
+#prefix=/usr
+#major_version=5.1
+#version=5.1.0
+#deb_host_multiarch=x86_64-linux-gnu
+
+lib_name=lua${major_version}-c++
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+#
+# The following are intended to be used via "pkg-config --variable".
+
+# Install paths for Lua modules.  For example, if a package wants to install
+# Lua source modules to the /usr/local tree, call pkg-config with
+# "--define-variable=prefix=/usr/local" and "--variable=INSTALL_LMOD".
+INSTALL_LMOD=${prefix}/share/lua/${major_version}
+INSTALL_CMOD=${prefix}/lib/${deb_host_multiarch}/lua/${major_version}
+
+Name: Lua
+Description: Lua language engine
+Version: ${version}
+Requires:
+Libs: -L${libdir} -l${lib_name}
+Libs.private: -lm -ldl
+Cflags: -I${includedir}/${lib_name_include}
diff --git a/lua.pc.in b/lua.pc.in
new file mode 100644
index 0000000..d594c1f
--- /dev/null
+++ b/lua.pc.in
@@ -0,0 +1,25 @@
+#prefix=/usr
+#major_version=5.1
+#version=5.1.0
+#deb_host_multiarch=x86_64-linux-gnu
+
+lib_name=lua${major_version}
+#libdir=${prefix}/lib
+includedir=${prefix}/include
+
+#
+# The following are intended to be used via "pkg-config --variable".
+
+# Install paths for Lua modules.  For example, if a package wants to install
+# Lua source modules to the /usr/local tree, call pkg-config with
+# "--define-variable=prefix=/usr/local" and "--variable=INSTALL_LMOD".
+INSTALL_LMOD=${prefix}/share/lua/${major_version}
+INSTALL_CMOD=${prefix}/lib/${deb_host_multiarch}/lua/${major_version}
+
+Name: Lua
+Description: Lua language engine
+Version: ${version}
+Requires:
+Libs: -L${libdir} -l${lib_name}
+Libs.private: -lm -ldl
+Cflags: -I${includedir}/${lib_name_include}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/lua51.git/commitdiff/b7fe5f1e031523902f7d69f2a22f2e2c0cb83565



More information about the pld-cvs-commit mailing list