summaryrefslogtreecommitdiff
path: root/libdmtx.spec
blob: a8d95622496a86bd80a79af83263961621c0facc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
%bcond_with	ruby
%bcond_without	test
Summary:	Library for working with Data Matrix 2D bar-codes
Name:		libdmtx
Version:	0.7.2
Release:	1
License:	LGPL v2+
Group:		Libraries
URL:		http://www.libdmtx.org/
Source0:	http://downloads.sourceforge.net/libdmtx/%{name}-%{version}.tar.bz2
# Source0-md5:	0684cf3857591e777b57248d652444ae
BuildRequires:	ImageMagick-devel
BuildRequires:	pkgconfig
BuildRequires:	python-modules
BuildRequires:	rpm-pythonprov
BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
# required for tests
BuildRequires:	OpenGL-GLU-devel
BuildRequires:	SDL_image-devel
BuildRequires:	libpng-devel
# language bindings
#BuildRequires:  java-1.6.0-devel
BuildRequires:	php-devel
BuildRequires:	python-devel
%if %{with ruby}
BuildRequires:	ruby
BuildRequires:	ruby-devel
%endif

%description
libdmtx is open source software for reading and writing Data Matrix 2D
bar-codes on Linux, Unix, OS X, Windows, and mobile devices. At its
core libdmtx is a shared library, allowing C/C++ programs to use its
capabilities without restrictions or overhead.

The included utility programs, dmtxread and dmtxwrite, provide the
official interface to libdmtx from the command line, and also serve as
a good reference for programmers who wish to write their own programs
that interact with libdmtx. All of the software in the libdmtx package
is distributed under the LGPLv2 and can be used freely under these
terms.

%package        devel
Summary:	Development files for %{name}
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%package        utils
Summary:	Utilities for %{name}
Group:		Applications/System
Requires:	%{name} = %{version}-%{release}

%description    utils
The %{name}-utils package contains utilities that use %{name}.

# language bindings
%package -n     php-libdmtx
Summary:	PHP bindings for %{name}
License:	GPL v2+
Group:		Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	php-common

%description -n php-libdmtx
The php-%{name} package contains bindings for using %{name} from PHP.

%package -n     python-libdmtx
Summary:	Python bindings for %{name}
Group:		Libraries
Requires:	%{name} = %{version}-%{release}

%description -n python-libdmtx
The python-%{name} package contains bindings for using %{name} from
Python.

%package -n     ruby-libdmtx
Summary:	Ruby bindings for %{name}
Group:		Libraries
Requires:	%{name} = %{version}-%{release}
Provides:	ruby(%{name}) = %{version}

%description -n ruby-libdmtx
The ruby-%{name} package contains bindings for using %{name} from
Ruby.

%prep
%setup -q

# fix permissions
chmod a-x wrapper/{php,python}/README

%build
%configure \
	--disable-static \

%{__make} %{?_smp_mflags}

# temporary installation required by the language wrappers
install -d tmp
%{__make} install \
	DESTDIR=$(pwd)/tmp

# language wrappers must be built separately
cd wrapper/php
phpize
%configure \
	--disable-static \

# Don't use rpath!
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

%{__make} \
	EXTRA_CFLAGS="-I$(pwd)/../../tmp%{_includedir}" \
	DMTX_SHARED_LIBADD="-L$(pwd)/../../tmp%{_libdir} -ldmtx"
cd ..

cd python
# fix paths
sed -i.orig -e "s|%{_prefix}/local/include|$(pwd)/../../tmp%{_includedir}|" -e "s|%{_prefix}/local/lib|$(pwd)/../../tmp%{_libdir}|" setup.py
python setup.py build
chmod 0755 build/lib.*/*.so
cd ..

%if %{with ruby}
cd ruby
ruby extconf.rb
%{__make} \
	CPPFLAGS="-I$(pwd)/../../tmp%{_includedir}" \
	LIBPATH="-L$(pwd)/../../tmp%{_libdir} -ldmtx"
cd ..
%endif

#cd java
#make LIBDMTX_LA="/tmp%{_libdir}/libdmtx.so"
#cd ..
cd ..

%if %{with test}
%{__make} check
cd test
for t in simple unit
do
	./${t}_test/${t}_test
done
%endif

%install
rm -rf $RPM_BUILD_ROOT

%{__make} install \
	DESTDIR=$RPM_BUILD_ROOT

find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'

cd wrapper
%{__make} -C php install \
	INSTALL_ROOT=$RPM_BUILD_ROOT

cd python
python setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
cd ..

%if %{with ruby}
%{__make} -C ruby install \
	DESTDIR=$RPM_BUILD_ROOT
%endif

#pushd java
#popd
cd ..

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig


%files
%defattr(644,root,root,755)
%doc AUTHORS COPYING.LESSER ChangeLog KNOWNBUG NEWS README README.linux TODO
%attr(755,root,root) %{_libdir}/%{name}.so.*

%files devel
%defattr(644,root,root,755)
%{_includedir}/*
%attr(755,root,root) %{_libdir}/%{name}.so
%{_pkgconfigdir}/%{name}.pc
%{_mandir}/man3/%{name}.3*

%files utils
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/dmtx*
%{_mandir}/man1/dmtx*.1*

%files -n php-libdmtx
%defattr(644,root,root,755)
%doc COPYING wrapper/php/README
%attr(755,root,root) %{_libdir}/php/*.so

%files -n python-libdmtx
%defattr(644,root,root,755)
%doc wrapper/python/README
%{py_sitedir}/*

%if %{with ruby}
%files -n ruby-libdmtx
%defattr(644,root,root,755)
%doc wrapper/ruby/README
%attr(755,root,root) %{ruby_sitearchdir}/*.so
%endif