1. spec
  2. -------------------------------------------------------------------------
  3. @ 包的一些关键属性
  4. Name: rcpyangmodels
  5. Version: 1.19.0
  6. Release: 1%{?dist} .wf32
  7. Summary: Yang schemas and library to manipulate yang data conversions
  8. -------------------------------------------------------------------------
  9. @ 源文件download地址
  10. License: Nokia License
  11. URL: https://gitlabe1.ext.net.nokia.com/RCP/rcpyangmodels
  12. Source0: https://gitlabe1.ext.net.nokia.com/RCP/rcpyangmodels/repository/archive.tar.gz?ref=pq%{version}#/%{name}-%{version}.tar.gz
  13. -------------------------------------------------------------------------
  14. @ 界定平台
  15. ExcludeArch: aarch64
  16. -------------------------------------------------------------------------
  17. @ 编译依赖
  18. BuildRequires: autoconf
  19. BuildRequires: automake
  20. BuildRequires: libtool
  21. BuildRequires: boost-devel
  22. BuildRequires: lcov
  23. BuildRequires: python3
  24. BuildRequires: pkgconfig(libyang)
  25. BuildRequires: pkgconfig(libyang-cpp)
  26. BuildRequires: pkgconfig(libgenapiloggermt)
  27. BuildRequires: pkgconfig(gmock)
  28. BuildRequires: pkgconfig(gtest)
  29. BuildRequires: pkgconfig(gtest_main)
  30. Requires: sysrepo
  31. -------------------------------------------------------------------------
  32. @ 包名陈述
  33. %description
  34. %{name} contains YANG modules.
  35. -------------------------------------------------------------------------
  36. %package libs
  37. Summary: Library files for %{name}
  38. %description libs
  39. The %{name}-libs contains library to manipulate yang data conversions
  40. between xml/json/binary formats that use %{name}.
  41. %package devel
  42. Summary: Development files for %{name}
  43. Requires: %{name}-libs%{?_isa} = %{version}-%{release}
  44. %description devel
  45. The %{name}-devel package contains header files
  46. and libraries for developing applications that use %{name}.
  47. %prep
  48. %setup
  49. %build
  50. ./autogen.sh
  51. %configure
  52. %make_build
  53. %check
  54. %make_check
  55. %install
  56. %make_install
  57. rm -f %{buildroot}%{_libdir}/libyangmodelsdk.*a
  58. %files
  59. %{_sysconfdir}/yangmodel
  60. %{_bindir}/yangmodelsetup
  61. %files devel
  62. %{_libdir}/pkgconfig/libyangmodelsdk.pc
  63. %{_includedir}/yangmodel
  64. %{_libdir}/libyangmodelsdk.so
  65. %files libs
  66. %{_libdir}/libyangmodelsdk.so.*

编译触发步骤


rpm build 相关 - 图1

libtool

https://www.xuebuyuan.com/1470147.html
libtool主要的一个作用是在编译大型软件的过程中解决了库的依赖问题;将繁重的库依赖关系的维护工作承担下来,从而释放了程序员的人力资源。

  • libtool提供统一的接口,隐藏了不同平台间库的名称的差异等细节,生成一个抽象的后缀名为la高层库libxx.la(其实是个文本文件),并将该库对其它库的依赖关系,都写在该la的文件中。
  • 该文件中的dependency_libs记录该库依赖的所有库(其中有些是以.la文件的形式加入的);
  • libdir则指出了库的安装位置;
  • library_names记录了共享库的名字;
  • old_library记录了静态库的名字。
  • libtool需要编译哪些库即可,libtool将处理库的依赖等细节。
  • libtool只与后缀名为lo、la为的libtool文件打交道。

    configure.ac中用到的宏

    ``` # AC_INIT([yangmodel], [1.0.0], [], [], []) AC_LANG([C++]) AC_CONFIG_AUX_DIR([build-aux])

AUTOMAKE GLOBAL OPTIONS

AM_INIT_AUTOMAKE([subdir-objects foreign 1.13 tar-pax]) AM_SILENT_RULES([no])

AM_PROG_AR AC_PROG_MKDIR_P

LT_PREREQ([2.4.6]) LT_INIT([disable-static pic-only]) LT_LANG([C++])

AC_CONFIG_MACRO_DIR([m4])

AX_BOOST_BASE([1.60], [], [AC_MSG_ERROR(Unable to detect suitable boost library)]) AX_PTHREAD

PKG_CHECK_MODULES([LIBYANG], [libyang libyang-cpp]) PKG_CHECK_MODULES([GTEST], [gtest_main]) PKG_CHECK_MODULES([GMOCK], [gmock])

code coverage related macro and variables

AX_CODE_COVERAGE

Compile flags

AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS],[],[-pthread],[])

Doxgen

AC_CONFIG_FILES([Doxyfile])

DX_DOT_FEATURE(ON)

DX_INIT_DOXYGEN([tpl], [Doxyfile], [doxygen-doc])

需要修改的部分

AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES( Makefile libyangmodelsdk/Makefile yang/Makefile )

AC_OUTPUT ``` (1)以“#”号开始的行均为注释行。
(2)AC_PREREQ 宏声明本文要求的 autoconf 版本, 如本例中的版本 2.59。
(3)AC_INIT 宏用来定义软件的名称、版本等信息、作者的E-mail等
(4)AM_INIT_AUTOMAKE是通过手动添加的, 它是automake所必备的宏, FULL-PACKAGE-NAME是软件名称,VERSION是软件版本号。
(5)AC_CONFIG_SCRDIR 宏用来侦测所指定的源码文件是否存在, 来确定源码目录的有效性.。此处为当前目录下main.c。
(6)AC_CONFIG_HEADER 宏用于生成config.h文件,以便 autoheader 命令使用。
(7)AC_PROG_CC用来指定编译器,如果不指定,默认gcc。
(8)AC_OUTPUT 用来设定 configure 所要产生的文件,如果是makefile,configure 会把它检查出来的结果带入makefile.in文件产生合适的makefile。使用 Automake 时,还需要一些其他的参数,这些额外的宏用aclocal工具产生。
(9)AC_CONFIG_FILES宏用于生成相应的Makefile文件。