[Momonga-devel.ja:01857] Re: Momonga Linux のリリースへ向けた spec ファイルの見直し


小松です。

From: Kenta MURATA <muraken2@xxxxxxxxx>
Subject: [Momonga-devel.ja:01827] Momonga Linux のリリースへ向けた spec ファイルの見直し
Date: Tue, Jul 01, 2003 at 07:31:32AM JST

> * make の引数に %{?_smp_mflags} が存在しない場合,書き足します.

これですが、make %{?_smp_mflags} || make とか書くのは繁雑だし、
間違いの元なので
(2番目の make に引数や環境変数を渡すのを忘れたりする。e.g. rpm.spec)、
%make って macro を作りましょう。↓こんな感じ。

    # set these variables in specfile if needed
    %make_env	%nil
    %make_args	%nil
    %make_target	%nil

    # make macro
    %make \
      %{?_smp_mflags:\
	%{make_env} %__make %{?_smp_mflags} %{make_args} %{make_target} || \\\
      } \\\
      %{make_env} %__make %{make_args} %{make_target}


make %{?_smp_mflags} が絶対失敗するような spec では

    %undefine _smp_mflags

しておけばいいと思います。

ついでというか何というか、
今の %makeinstall や %configure はイマイチ使いにくいので、
こいつらも再定義してしまいましょう。
具体的には添付の macros.momonga を見てもらうとして、
spec 中で以下の変数 (macro) を適宜定義し直せるようになっています。

    %makeinstall_target
    make install の時の make の target (default はもちろん "install")。

    %makeinstall_env	
    make install の時に make に渡す環境変数 (default: %nil)

    %makeinstall_args
    make install の時に make に渡す引数

    %configure_cmd
    configure のコマンド名  (default: "./configure")

    %configure_env
    configure に渡す環境変数

    %configure_args
    configure に渡す引数

これで例えば configure のコマンド名が ./Configure であったり、
../configure であっても %configure_cmd を再定義すれば対処できるし、
%makeinstall に余計は引数を渡したくない時には
%makeinstall_args を再定義すれば対処できたりします。

> * [Momonga-devel.ja:00492] で小松さんが作成された %NoSource と,
>   %NoPatch マクロを使用した形式に変更します.specopt における
>   オプションの定義で扱われている
> 
>     %{?!with_hoge:%define with_hoge 1}
> 
>   のような記述は
> 
>     %{?!with_hoge:%global with_hoge 1}
> 
>   というように,%define を %global に変更することで,%NoSource 
>   の使用によるマクロの無効化を回避する (以下で詳細を述べます).

あれ以降深く追及できなくて申し訳ない…
これで問題ないようなら是非入れましょう。
少なくとも定義するだけなら(使わなければ)問題ないと思うので 
とりあえず入れてしまってもいいかも。


あと、この先いろんな macro を定義しようと思っているのですが、
そのたびに rpm を rebuild するのもアホらしいので、
momonga 特有な macro は rpm からは切離そうと思うのですが、
いかがでしょう?

-- 
---------------------------------------
東京大学大学院総合文化研究科
広域科学専攻相関基礎科学系 
  佐々研究室  博士4年
    小松  晋一朗            
koma2@xxxxxxxxxxxxxxxxxxxx
koma2@xxxxxxxxxxxxxxxxx
http://kamuy.c.u-tokyo.ac.jp/~koma2/
---------------------------------------
#------------------------------------------------------------------------
# %%make
#------------------------------------------------------------------------

# set these variables in specfile if needed
%make_env	%nil
%make_args	%nil
%make_target	%nil

# make macro
%make \
  %{?_smp_mflags:\
    %{make_env} %__make %{?_smp_mflags} %{make_args} %{make_target} || \\\
  } \\\
  %{make_env} %__make %{make_args} %{make_target}


#------------------------------------------------------------------------
# overwrite %%makeinstall
#------------------------------------------------------------------------

# set these variables in specfile if needed
%makeinstall_target	install
%makeinstall_env	%nil
%makeinstall_args \\\
	prefix=%{?buildroot:%{buildroot}}%{_prefix} \\\
	exec_prefix=%{?buildroot:%{buildroot}}%{_exec_prefix} \\\
	bindir=%{?buildroot:%{buildroot}}%{_bindir} \\\
	sbindir=%{?buildroot:%{buildroot}}%{_sbindir} \\\
	sysconfdir=%{?buildroot:%{buildroot}}%{_sysconfdir} \\\
	datadir=%{?buildroot:%{buildroot}}%{_datadir} \\\
	includedir=%{?buildroot:%{buildroot}}%{_includedir} \\\
	libdir=%{?buildroot:%{buildroot}}%{_libdir} \\\
	libexecdir=%{?buildroot:%{buildroot}}%{_libexecdir} \\\
	localstatedir=%{?buildroot:%{buildroot}}%{_localstatedir} \\\
	sharedstatedir=%{?buildroot:%{buildroot}}%{_sharedstatedir} \\\
	mandir=%{?buildroot:%{buildroot}}%{_mandir} \\\
	infodir=%{?buildroot:%{buildroot}}%{_infodir}

# makeinstall macro
%makeinstall \
    %{makeinstall_env} %__make %{makeinstall_args} %{makeinstall_target}


#------------------------------------------------------------------------
# overwrite %%configure
#------------------------------------------------------------------------

# set these variables in specfile if needed
%configure_cmd		./configure
%configure_env \\\
    CFLAGS="${CFLAGS:-%optflags}" \\\
    CXXFLAGS="${CXXFLAGS:-%optflags}" \\\
    FFLAGS="${FFLAGS:-%optflags}"

%configure_args \\\
	--prefix=%{_prefix} \\\
	--exec-prefix=%{_exec_prefix} \\\
	--bindir=%{_bindir} \\\
	--sbindir=%{_sbindir} \\\
	--sysconfdir=%{_sysconfdir} \\\
	--datadir=%{_datadir} \\\
	--includedir=%{_includedir} \\\
	--libdir=%{_libdir} \\\
	--libexecdir=%{_libexecdir} \\\
	--localstatedir=%{_localstatedir} \\\
	--sharedstatedir=%{_sharedstatedir} \\\
	--mandir=%{_mandir} \\\
	--infodir=%{_infodir}

# configure macro
%configure \
  %{?__libtoolize:[ -f configure.in ] && %{__libtoolize} --copy --force ;} \
  %{configure_env} %{configure_cmd} %{_target_platform} %{configure_args}