add packaging
[platform/upstream/iproute2.git] / packaging / iproute2.spec
1 %define with_docs 0
2
3 Name:           iproute2
4 Version:        3.4.0
5 Release:        0
6 License:        GPL-2.0
7 Summary:        Linux network configuration utilities
8 Url:            http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
9 Group:          Productivity/Networking/Routing
10 # Using GPL-2.0 instead of GPL-2.0+ because of tc_skbedit.h and tc/q_multiq.c
11
12 #DL-URL:        http://kernel.org/pub/linux/utils/net/iproute2/
13 #Git-Clone:     git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2
14 Source:         %{name}-%{version}.tar.xz
15 Source2:        %{name}-%{version}.tar.sign
16 # PATCH-FIX-UPSTREAM iproute2-libdir-1.diff status=unknown
17 Patch0:         iproute2-libdir-1.diff
18 # PATCH-??-OPENSUSE iproute2-HZ.diff status=noidea
19 Patch1:         iproute2-HZ.diff
20 BuildRequires:  bison
21 BuildRequires:  db4-devel
22 BuildRequires:  flex
23 BuildRequires:  libpng-devel
24 BuildRequires:  libtiff-devel
25 BuildRequires:  pkgconfig >= 0.21
26 BuildRequires:  xz
27 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
28 %if %{with_docs}
29 BuildRequires:  ghostscript-x11
30 BuildRequires:  sgmltool
31 BuildRequires:  texlive-latex
32 %endif
33 %define with_xt 1
34 %if 0%{?with_xt}
35 BuildRequires:  libnl-devel
36 #BuildRequires:  pkgconfig(xtables) >= 1.4.11
37 BuildRequires:  libxtables-devel
38 %endif
39 Provides:       iproute = %{version}-%{release}
40
41 %description
42 This package provides the tools ip, tc, and rtmon needed to use the new
43 and advanced routing options of the Linux kernel. The SUSE Linux
44 distribution has used this package for network setup since SuSE Linux
45 8.0.
46
47 %package -n libnetlink-devel
48 License:        GPL-2.0+
49 Summary:        A Higher Level Interface to the Netlink Service
50 Group:          Development/Libraries/C and C++
51 Provides:       libnetlink = %{version}-%{release}
52
53 %description -n libnetlink-devel
54 libnetlink provides a higher level interface to rtnetlink(7).
55 %if %{with_docs}
56 %package doc
57 License:        GPL-2.0+
58 Summary:        Documentation to iproute2
59 Group:          Documentation
60 BuildArch:      noarch
61
62 %description doc
63 This package contains the PDF documentation from iproute2,
64 as well as examples and other outdated files.
65 %endif
66
67 %prep
68 %if 0%{?__xz:1}
69 %setup -q
70 %else
71 tar -xf "%{SOURCE0}" --use=xz;
72 %setup -DTq
73 %endif
74 %patch1 -P 0 -p1
75 find . -name *.orig -delete
76
77 %build
78 # build with -fPIC. For details see
79 # https://bugzilla.novell.com/show_bug.cgi?id=388021
80 ./configure
81 xtlibdir="$(pkg-config xtables --variable=xtlibdir)";
82 make %{?_smp_mflags} LIBDIR=%{_libdir} CCOPTS="-D_GNU_SOURCE %{optflags} -Wstrict-prototypes -fPIC -DXT_LIB_DIR=\\\"$xtlibdir\\\""
83
84 %if %{with_docs}
85 cd doc
86 make pdf
87 %endif
88
89 %install
90 install -d %{buildroot}/{etc/,sbin/,usr/{sbin,share/man/man{3,8}}}
91 install -d %{buildroot}/{/usr/include,%{_libdir},/usr/share}
92 make install DESTDIR=%{buildroot} LIBDIR=%{_libdir} \
93         MODDESTDIR="%{buildroot}/%{_libdir}/tc"
94 # We have m_xt
95 rm -f "%{buildroot}/%{_libdir}/tc/m_ipt.so"
96 install lib/libnetlink.a %{buildroot}/%{_libdir}
97 chmod -x %{buildroot}/%{_libdir}/libnetlink.a
98 install include/libnetlink.h %{buildroot}%{_includedir}
99 chmod -x %{buildroot}%{_includedir}/libnetlink.h
100 rm %{buildroot}%{_sbindir}/ifcfg
101
102 %files
103 %defattr(-,root,root)
104 %doc README* COPYING
105 %{_sbindir}/*
106 %{_mandir}/man8/*
107 %dir %{_sysconfdir}/iproute2
108 %config(noreplace) %{_sysconfdir}/iproute2/*
109 %{_libdir}/tc
110 %dir %{_datadir}/tc
111 %attr(644,root,root)%{_datadir}/tc/*
112
113 %if %{with_docs}
114 %files doc
115 %defattr(-,root,root)
116 %doc doc/api-ip6-flowlabels.pdf doc/arpd.pdf doc/ip-cref.pdf
117 %doc doc/ip-tunnels.pdf doc/nstat.pdf doc/rtstat.pdf doc/ss.pdf
118 %doc examples/ ip/ifcfg ip/routef ip/routel
119 %endif
120
121 %files -n libnetlink-devel
122 %defattr(-,root,root)
123 %{_includedir}/*
124 %{_mandir}/man3/libnetlink*
125 %{_libdir}/lib*