Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
8.7KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_rpm_init.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_RPM_INIT
  8. #
  9. # DESCRIPTION
  10. #
  11. # Setup variables for creation of rpms. It will define several variables
  12. # useful for creating rpms on a system where rpms are supported.
  13. # Currently, I requires changes to Makefile.am to function properly (see
  14. # the example below).
  15. #
  16. # Also note that I do not use any non-UNIX OSs (and for the most part, I
  17. # only use RedHat), so this is probably generally not useful for other
  18. # systems.
  19. #
  20. # Required setup:
  21. #
  22. # In configure.in:
  23. #
  24. # dnl For my rpm.m4 macros
  25. # RPM_RELEASE=1
  26. # AC_SUBST(RPM_RELEASE)
  27. #
  28. # AX_RPM_INIT
  29. # dnl Enable or disable the rpm making rules in Makefile.am
  30. # AM_CONDITIONAL(MAKE_RPMS, test x$make_rpms = xtrue)
  31. #
  32. # Furthermore, the %GNUconfigure rpm macro has a problem in that it does
  33. # not define CXXFLAGS for the target system correctly, so for compiling
  34. # C++ code, add the following line _before_ calling AC_PROG_CXX:
  35. #
  36. # dnl This is a little hack to make this work with rpm better (see mysql++.spec.in)
  37. # test -z "$CXXFLAGS" && CXXFLAGS="${CFLAGS}"
  38. #
  39. # Changes to Makefile.am (I am trying to get rid of this step; suggestions
  40. # invited):
  41. #
  42. # if MAKE_RPMS
  43. # rpm: @RPM_TARGET@
  44. #
  45. # .PHONY: rpm
  46. #
  47. # $(RPM_TARGET): $(DISTFILES)
  48. # ${MAKE} dist
  49. # -mkdir -p $(RPM_DIR)/SRPMS
  50. # -mkdir -p `dirname $(RPM_TARGET)`
  51. # $(RPM_PROG) $(RPM_ARGS) $(RPM_TARBALL)
  52. # @echo Congratulations, $(RPM_TARGET) "(and friends)" should now exist.
  53. # else
  54. # endif
  55. #
  56. # Also, it works best with a XXXX.spec.in file like the following (this is
  57. # way down on the wishlist, but a program to generate the skeleton spec.in
  58. # much like autoscan would just kick butt!):
  59. #
  60. # ---------- 8< ----------
  61. # # -*- Mode:rpm-spec -*-
  62. # # mysql++.spec.in
  63. # Summary: Your package description goes here
  64. # %define rel @RPM_RELEASE@
  65. #
  66. # %define version @VERSION@
  67. # %define pkgname @PACKAGE@
  68. # %define prefix /usr
  69. #
  70. # %define lt_release @LT_RELEASE@
  71. # %define lt_version @LT_CURRENT@.@LT_REVISION@.@LT_AGE@
  72. #
  73. # # This is a hack until I can figure out how to better handle replacing
  74. # # autoconf macros... (gotta love autoconf...)
  75. # %define __aclocal aclocal || aclocal -I ./macros
  76. # %define configure_args @RPM_CONFIGURE_ARGS@
  77. #
  78. # Name: %{pkgname}
  79. # Version: %{version}
  80. # Release: %{rel}
  81. #
  82. # Copyright: LGPL
  83. # Group: # your group name goes here
  84. # Source: %{pkgname}-%{version}.tar.gz
  85. # Requires: # additional requirements
  86. # Buildroot: /tmp/%{pkgname}-root
  87. # URL: http://yoururl.go.here
  88. # Prefix: %{prefix}
  89. # BuildArchitectures: # Target platforms, i.e., i586
  90. # Packager: Your Name <youremail@your.address>
  91. #
  92. # %description
  93. # Your package description
  94. #
  95. # %changelog
  96. #
  97. # %prep
  98. # %setup
  99. # #%patch
  100. #
  101. # %build
  102. # %GNUconfigure %{configure_args}
  103. # # This is why we copy the CFLAGS to the CXXFLAGS in configure.in
  104. # # CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{prefix}
  105. # make
  106. #
  107. # %install
  108. # # To make things work with BUILDROOT
  109. # if [ "$RPM_BUILD_ROOT" != "/tmp/%{pkgname}-root" ]
  110. # then
  111. # echo
  112. # echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  113. # echo @ @
  114. # echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @
  115. # echo @ @
  116. # echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  117. # echo
  118. # else
  119. # echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT"
  120. # rm -rf "$RPM_BUILD_ROOT"
  121. # fi
  122. # make DESTDIR="$RPM_BUILD_ROOT" install
  123. #
  124. # %clean
  125. # # Call me paranoid, but I do not want to be responsible for nuking
  126. # # someone's harddrive!
  127. # if [ "$RPM_BUILD_ROOT" != "/tmp/%{pkgname}-root" ]
  128. # then
  129. # echo
  130. # echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  131. # echo @ @
  132. # echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @
  133. # echo @ @
  134. # echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  135. # echo
  136. # else
  137. # echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT"
  138. # rm -rf "$RPM_BUILD_ROOT"
  139. # fi
  140. #
  141. # %files
  142. # %defattr(-, root, root)
  143. # # Your application file list goes here
  144. # # %{prefix}/lib/lib*.so*
  145. # %doc COPYRIGHT ChangeLog README AUTHORS NEWS
  146. # %doc doc/*
  147. #
  148. # # If you install a library
  149. # %post -p /sbin/ldconfig
  150. #
  151. # # If you install a library
  152. # %postun -p /sbin/ldconfig
  153. #
  154. # %package devel
  155. # Summary: Development files for %{pkgname}
  156. # Group: Applications/Databases
  157. # %description devel
  158. # Development files for %{pkgname}.
  159. #
  160. # %files devel
  161. # %defattr(-, root, root)
  162. # # Your development files go here
  163. # # Programmers documentation goes here
  164. # %doc doc
  165. #
  166. # # end of file
  167. # ---------- >8 ----------
  168. #
  169. # LICENSE
  170. #
  171. # Copyright (c) 2008 Dale K. Hawkins <dhawkins@cdrgts.com>
  172. #
  173. # Copying and distribution of this file, with or without modification, are
  174. # permitted in any medium without royalty provided the copyright notice
  175. # and this notice are preserved. This file is offered as-is, without any
  176. # warranty.
  177. #serial 6
  178. dnl AX_RPM_INIT
  179. dnl Figure out how to create rpms for this system and setup for an
  180. dnl automake target
  181. AU_ALIAS([AM_RPM_INIT], [AX_RPM_INIT])
  182. AC_DEFUN([AX_RPM_INIT],
  183. [dnl
  184. AC_REQUIRE([AC_CANONICAL_HOST])
  185. dnl Find the RPM program
  186. AC_ARG_WITH(rpm-prog,[ --with-rpm-prog=PROG Which rpm to use (optional)],
  187. rpm_prog="$withval", rpm_prog="")
  188. AC_ARG_ENABLE(rpm-rules, [ --enable-rpm-rules Try to create rpm make rules (defaults to yes for Linux)],
  189. enable_rpm_rules="$withval",enable_rpm_rules=no)
  190. AC_ARG_WITH(rpm-extra-args, [ --with-rpm-extra-args=ARGS Run rpm with extra arguments (defaults to none)],
  191. rpm_extra_args="$withval", rpm_extra_args="")
  192. dnl AC_ARG_ENABLE(rpm-topdir, [ --enable-rpm Try to create rpm make rules (defaults to yes for Linux)],
  193. dnl enable_rpm_rules="$withval",no)
  194. dnl echo enable_rpm_rules is $enable_rpm_rules
  195. dnl echo rpm_prog is $rpm_prog
  196. RPM_TARGET=""
  197. if test x$enable_rpm_rules = xno ; then
  198. echo "Not trying to build rpms for your system (use --enable-rpm-rules to override) "
  199. no_rpm=yes
  200. else
  201. if test x$rpm_prog != x ; then
  202. if test x${RPM_PROG+set} != xset ; then
  203. RPM_PROG=$rpm_prog
  204. fi
  205. fi
  206. AC_PATH_PROG(RPM_PROG, rpm, no)
  207. no_rpm=no
  208. if test "$RPM_PROG" = "no" ; then
  209. echo *** RPM Configuration Failed
  210. echo *** Failed to find the rpm program. If you want to build rpm packages
  211. echo *** indicate the path to the rpm program using --with-rpm-prog=PROG
  212. no_rpm=yes
  213. RPM_MAKE_RULES=""
  214. else
  215. AC_MSG_CHECKING(how rpm sets %{_rpmdir})
  216. rpmdir=`rpm --eval %{_rpmdir}`
  217. if test x$rpmdir = x"%{_rpmdir}" ; then
  218. AC_MSG_RESULT([not set (cannot build rpms?)])
  219. echo *** Could not determine the value of %{_rpmdir}
  220. echo *** This could be because it is not set, or your version of rpm does not set it
  221. echo *** It must be set in order to generate the correct rpm generation commands
  222. echo ***
  223. echo *** You might still be able to create rpms, but I could not automate it for you
  224. echo *** BTW, if you know this is wrong, please help to improve the rpm.m4 module
  225. echo *** Send corrections, updates and fixes to dhawkins@cdrgts.com. Thanks.
  226. else
  227. AC_MSG_RESULT([$rpmdir])
  228. fi
  229. AC_MSG_CHECKING(how rpm sets %{_rpmfilename})
  230. rpmfilename=$rpmdir/`rpm --eval %{_rpmfilename} | sed "s/%{ARCH}/${host_cpu}/g" | sed "s/%{NAME}/$PACKAGE/g" | sed "s/%{VERSION}/${VERSION}/g" | sed "s/%{RELEASE}/${RPM_RELEASE}/g"`
  231. AC_MSG_RESULT([$rpmfilename])
  232. RPM_DIR=${rpmdir}
  233. RPM_TARGET=$rpmfilename
  234. RPM_ARGS="-ta $rpm_extra_args"
  235. RPM_TARBALL=${PACKAGE}-${VERSION}.tar.gz
  236. fi
  237. fi
  238. case "${no_rpm}" in
  239. yes) make_rpms=false;;
  240. no) make_rpms=true;;
  241. *) AC_MSG_WARN([bad value ${no_rpm} for no_rpm (not making rpms)])
  242. make_rpms=false;;
  243. esac
  244. AC_SUBST(RPM_DIR)
  245. AC_SUBST(RPM_TARGET)
  246. AC_SUBST(RPM_ARGS)
  247. AC_SUBST(RPM_TARBALL)
  248. RPM_CONFIGURE_ARGS=${ac_configure_args}
  249. AC_SUBST(RPM_CONFIGURE_ARGS)
  250. ])