9fa4210587b8e8297c7fdd6508a2b3842ad40a91
[profile/ivi/OpenAVB.git] / packaging / openavb.spec
1 %{!?_with_debug:%{!?_without_debug:%define _without_debug 0}}
2
3 %define kernel kernel-x86-ivi
4 %define kernel_relstr "%(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' %{kernel})"
5 %define kernel_release %(echo %{kernel_relstr})
6 %define kernel_modstr "%(/bin/rpm -ql %{kernel} | sort | grep /lib/modules/%{kernel_release} | head -1 | sed 's#/*$##g')"
7 %define kernel_modpath %(echo %{kernel_modstr})
8 %define kernel_moddir  %(echo %{kernel_modstr} | sed 's#.*/##g')
9
10 Summary: OpenAVB
11 Name: openavb
12 Version: 20140731
13 Release: 1
14 License: Intel and GPL-2.0
15 Group: Automotive/Ethernet AVB
16 URL: https://github.com/intel-ethernet/Open-AVB
17 Source0: %{name}-%{version}.tar.gz
18 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
19 Requires: openavb-kmod-igb
20 ExclusiveArch:  %ix86 x86_64
21
22 BuildRequires: libstdc++-devel
23 BuildRequires: kernel-devel
24 BuildRequires: pkgconfig(libpci)
25 BuildRequires: pkgconfig(zlib)
26
27 %package kmod-igb
28 Summary: kernel module for Intel ethernet cards
29 Group: System/Kernel
30 Requires: %{kernel} = %{kernel_release}
31
32 %package libigb
33 Summary: IGB runtime library
34 Group: System/Libraries
35
36 %package examples
37 Summary: Example clients
38 Group: Applications/System
39 Requires: openavb-libigb = %{version}
40
41 %package devel
42 Summary: Headers and libraries
43 Group: Development/Libraries
44 Requires: %{name} = %{version}
45
46 %package doc
47 Summary: Documentation
48 Group: Development/Tools
49
50 %description
51 This package contains the basic OpenAVB userspace daemons.
52
53 %description kmod-igb
54 This package contains the kernel module required by OpenAVB for Intel
55 ethernet cards.
56
57 %description libigb
58 This package contains the libigb runtime library from the OpenAVB
59 distribution.
60
61 %description examples
62 This package contains various test and example utilities for OpenAVB.
63
64 %description devel
65 This package contains header files and libraries for OpenAVB.
66
67 %description doc
68 This package contains some documentation from the OpenAVB distribution.
69
70 %prep
71 %setup -q
72
73 %build
74 # For now, always compile for debugging...
75 #%if %{?_with_debug:1}%{!?_with_debug:0}
76 export CFLAGS="-O0 -g3"
77 export CXXFLAGS="-O0 -g3"
78 #%endif
79
80 NUM_CPUS="`cat /proc/cpuinfo | tr -s '\t' ' ' | \
81                grep '^processor *:' | wc -l`"
82 [ -z "$NUM_CPUS" ] && NUM_CPUS=1
83
84 CONFIG_OPTIONS="--enable-kmod-flags=EXTRA_CFLAGS=-DIGB_PTP"
85
86 ./bootstrap && \
87     %configure $CONFIG_OPTIONS  && \
88     make BUILD_KERNEL=%{kernel_moddir} clean && \
89     make BUILD_KERNEL=%{kernel_moddir} -j$(($NUM_CPUS + 1))
90
91 %install
92 rm -rf $RPM_BUILD_ROOT
93
94 make DESTDIR=$RPM_BUILD_ROOT \
95     INSTALL_MOD_PATH=$RPM_BUILD_ROOT \
96     BUILD_KERNEL=%{kernel_moddir} install
97
98 rm -f $RPM_BUILD_ROOT%{_libdir}/libigb.la
99
100 # Install systemd and sample 'configuration' files.
101 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig \
102     $RPM_BUILD_ROOT/lib/systemd/system \
103     %{buildroot}/%{_sysconfdir}/modprobe.d
104 /usr/bin/install -m 644 packaging/openavb.env \
105     $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/openavb
106 /usr/bin/install -m 644 -t $RPM_BUILD_ROOT/lib/systemd/system \
107     packaging/mrpd.service packaging/gptp.service
108 /usr/bin/install -m 644 packaging/igb_avb.conf \
109     %{buildroot}/%{_sysconfdir}/modprobe.d
110
111 %clean
112 rm -rf $RPM_BUILD_ROOT
113
114 %post libigb
115 ldconfig
116
117 %postun libigb
118 ldconfig
119
120 %post kmod-igb
121 depmod -a %{kernel_moddir}
122
123 %files
124 %defattr(-,root,root,-)
125 %{_sbindir}/daemon_cl
126 %{_sbindir}/mrpd
127 %{_bindir}/mrpctl
128 %{_sysconfdir}/sysconfig/openavb
129 /lib/systemd/system/mrpd.service
130 /lib/systemd/system/gptp.service
131
132 %files kmod-igb
133 %defattr(-,root,root,-)
134 %{kernel_modpath}/kernel/drivers/net/igb_avb
135 %config(noreplace)%{_sysconfdir}/modprobe.d/igb_avb.conf
136
137 %files libigb
138 %defattr(-,root,root,-)
139 %{_libdir}/libigb.so.*
140
141 %files examples
142 %defattr(-,root,root,-)
143 %{_bindir}/mrpl
144 %{_bindir}/mrpq
145 %{_bindir}/simple_talker
146
147 %files devel
148 %defattr(-,root,root,-)
149 %{_includedir}/igb
150 %{_libdir}/libigb.so
151 %{_libdir}/pkgconfig/igb.pc
152
153 %files doc
154 %defattr(-,root,root,-)
155 %doc README.rst documents
156 %license examples/LICENSE
157 %doc examples/mrp_client examples/simple_listener examples/simple_talker