RFC: Macro for building modules
sparky at pld-linux.org
sparky at pld-linux.org
Tue Nov 7 23:49:54 CET 2006
On Tue, Nov 07, 2006 at 11:52:51PM +0300, Elan Ruusamäe wrote:
> just another idea, could use optional <<EOF for "patching section"
>
> %build_kernel_module -m foo <<EOF
> some scripting around here
> EOF
ok, got something
> oh, and don't use %Opts, it could conflict with spec macros.
> (hint: %__build_kernel_module_opts)
it isn't any problem, macros defined inside other macro are visible only
internally
the only problem with internal macros is they are expanded before anything,
that's why %if is placed inside Opts definition and not viceversa
--
____ Sparky{PI] -- Przemyslaw _ ___ _ _ ........... LANG...Pl..Ca..Es..En
/____) ___ ___ _ _ || Iskra | | _ \| | | : WWW........ppcrcd.pld-linux.org
\____\| -_)'___| ||^'||//\\// < | _/| | | : JID......sparky<at>jabberes.org
(____/|| (_-_|_|| ||\\ || |_ |_| |_| _| : Mail....sparky<at>pld-linux.org
-------------- next part --------------
#
%build_kernel_modules(p:P:m:) \
%{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \
\
%define Opts \\\\\\\
%if "%{_target_base_arch}" != "%{_arch}" \\\
%if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\
CC="%{__cc}" CPP="%{__cpp}" ARCH=%{_target_base_arch} \\\
%else \\\
ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
%endif \\\
%else \\\
CC="%{__cc}" CPP="%{__cpp}" \\\
%endif \
%define MakeOpts HOSTCC="%{__cc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
O=$PWD/o %{?with_verbose:V=1} %{Opts} \
compile() { \
L="<"; [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \
set -e -x \
\
for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do \
if [ ! -r "%{_kernelsrcdir}/config-$cfg" ]; then \
exit 1 \
fi \
install -d o/include/linux \
ln -sf %{_kernelsrcdir}/config-$cfg o/.config \
ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers \
ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
\
set +x \
[ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell \
set -x \
\
%if %{with dist_kernel} \
%{__make} -j1 -C %{_kernelsrcdir} prepare scripts \\\
%{-p*} %{-P*} \\\
%{MakeOpts} \
%else \
install -d o/include/config \
touch o/include/config/MARKER \
ln -sf %{_kernelsrcdir}/scripts o/scripts \
%endif \
\
%{__make} -C %{_kernelsrcdir} clean \\\
RCS_FIND_IGNORE="-name '*.ko' -o" \\\
M=$PWD %{MakeOpts} \
%{__make} -C %{_kernelsrcdir} modules \\\
${1+"$@"} \\\
M=$PWD %{MakeOpts} \
\
for MODULE in {%{-m*},}; do \
[ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko \
done \
done \
} \
compile %{*} \
%{nil}
More information about the pld-devel-en
mailing list