4.5.5. C 程序示例的 spec 文件示例


您可以对使用 C 编程语言编写的 cello 程序使用以下示例 spec 文件作为参考。

使用 C 编写的 cello 程序的 spec 文件示例

Name:           cello
Version:        1.0
Release:        1%{?dist}
Summary:        Hello World example implemented in C

License:        GPLv3+
URL:            https://www.example.com/%{name}
Source0:        https://www.example.com/%{name}/releases/%{name}-%{version}.tar.gz

Patch0:         cello-output-first-patch.patch

BuildRequires:  gcc
BuildRequires:  make

%description
The long-tail description for our Hello World Example implemented in
C.

%prep
%setup -q

%patch0

%build
make %{?_smp_mflags}

%install
%make_install

%files
%license LICENSE
%{_bindir}/%{name}

%changelog
* Tue May 31 2016 Adam Miller <maxamillion@fedoraproject.org> - 1.0-1
- First cello package

  • BuildRequires 指令,其指定软件包的 build-time 依赖项,包括以下执行编译构建过程所需的软件包:

    • gcc
    • make
  • 本例中省略了该软件包的运行时依赖项 Requires 指令。所有运行时要求都由 rpmbuild 进行处理,而 cello 程序不需要核心 C 标准库之外的任何内容。
  • %build 部分反映了这样一个事实,即此示例中,为 cello 程序编写了 Makefile 文件。因此,您可以使用 GNU make 命令。但是,您必须删除对 %configure 的调用,因为您没有提供配置脚本。

您可以使用 %make_install 宏安装 cello 程序。这是可能是因为 cello 程序的 Makefile 文件可用。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部