summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros399
1 files changed, 399 insertions, 0 deletions
diff --git a/macros b/macros
new file mode 100644
index 0000000..cc74f6f
--- /dev/null
+++ b/macros
@@ -0,0 +1,399 @@
+# Per-platform rpm configuration file.
+
+%_vendor @VENDOR@
+%_os linux
+%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu}
+
+#==============================================================================
+# ---- configure macros. note that most of these are inherited
+# from the defaults.
+#
+%_localstatedir /var
+
+%_pkgdocdir %{_docdir}/%{name}
+%_docdir_fmt %%{NAME}
+
+%_fmoddir %{_libdir}/gfortran/modules
+
+%_enable_debug_packages 1
+#%_include_minidebuginfo 1
+%_include_gdb_index 1
+%_debugsource_packages 1
+#%_debuginfo_subpackages 1
+
+%_build_id_links none
+
+# GCC toolchain
+%__cc_gcc gcc
+%__cxx_gcc g++
+%__cpp_gcc gcc -E
+
+# Clang toolchain
+%__cc_clang clang
+%__cxx_clang clang++
+%__cpp_clang clang-cpp
+
+# Default to the GCC toolchain
+#
+# It is enough to override `toolchain` macro and all relevant macro for C/C++
+# compilers will be switched. Either in the spec or in the command-line.
+#
+# %global toolchain clang
+#
+# or:
+#
+# rpmbuild -D "toolchain clang" …
+#
+# Inside a spec file it is also possible to determine which toolchain is in use
+# by testing the same macro. For example:
+#
+# %if "%{toolchain}" == "gcc"
+# BuildRequires: gcc
+# %endif
+#
+# or:
+#
+# %if "%{toolchain}" == "clang"
+# BuildRequires: clang compiler-rt
+# %endif
+#
+%toolchain gcc
+
+%__cc %{expand:%%{__cc_%{toolchain}}}
+%__cxx %{expand:%%{__cxx_%{toolchain}}}
+%__cpp %{expand:%%{__cpp_%{toolchain}}}
+
+#==============================================================================
+# ---- compiler flags.
+
+%build_cflags %{optflags}
+%build_cxxflags %{optflags} -fexceptions
+%build_fflags %{optflags} -fexceptions -I%{_fmoddir}
+%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags}
+
+%set_build_cc \
+ CC=%{__cc}; export CC ; \
+ CXX=%{__cxx}; export CXX ; \
+ CCC="${CCC:-%{__cxx}}" ; export CCC
+
+%set_build_flags \
+ %[ "%{toolchain}" == "gcc" ? "" : "%{set_build_cc};" ] \
+ CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
+ CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
+ FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
+ FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
+ LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS
+
+# Automatically use set_build_flags macro for build, check, and
+# install phases.
+# Use "%undefine _auto_set_build_flags" to disable"
+# Automatically use set_build_cc macro for build, check, and
+# install phases.
+# Use "%undefine _auto_set_build_cc" to disable"
+%_auto_set_build_cc %["%{toolchain}" == "gcc" ? 0 : 1]
+%_auto_set_build_flags 0
+
+%__spec_build_pre %{___build_pre} \
+ %[0%{?_auto_set_build_cc} ? "%{set_build_cc}" : ""] \
+ %[0%{?_auto_set_build_flags} ? "%{set_build_flags}" : ""]
+%__spec_check_pre %{___build_pre} \
+ %[0%{?_auto_set_build_cc} ? "%{set_build_cc}" : ""] \
+ %[0%{?_auto_set_build_flags} ? "%{set_build_flags}" : ""]
+
+#For backwards compatibility only.
+%__global_cflags %{build_cflags}
+%__global_cxxflags %{build_cxxflags}
+%__global_fflags %{build_fflags}
+%__global_fcflags %{build_fflags}
+%__global_ldflags %{build_ldflags}
+
+#==============================================================================
+# ---- configure and makeinstall.
+%_configure_gnuconfig_hack 1
+%_configure_libtool_hardening_hack 1
+
+#update config.guess and config.sub
+%_update_config_guess \
+ [ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find . -name config.guess) ; do \
+ [ -f /usr/lib/rpm/%{_vendor}/$(basename $i) ] && \
+ %{__rm} -f $i && \
+ %{__cp} -fv /usr/lib/rpm/%{_vendor}/$(basename $i) $i ; \
+ done ;
+
+%_update_config_sub \
+ [ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find . -name config.sub) ; do \
+ [ -f /usr/lib/rpm/%{_vendor}/$(basename $i) ] && \
+ %{__rm} -f $i && \
+ %{__cp} -fv /usr/lib/rpm/%{_vendor}/$(basename $i) $i ; \
+ done ;
+
+%configure \
+ %{set_build_flags}; \
+ [ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \
+ [ -f /usr/lib/rpm/%{_vendor}/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/%{_vendor}/$(basename $i) $i ; \
+ done ; \
+ [ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \
+ for i in $(find . -name ltmain.sh) ; do \
+ %{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \
+ done ; \
+ %{_configure} --build=%{_build} --host=%{_host} \\\
+ --program-prefix=%{?_program_prefix} \\\
+ --disable-dependency-tracking \\\
+ %{?_configure_disable_silent_rules:--disable-silent-rules} \\\
+ --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}
+
+# ---- Build policy macros.
+
+%__spec_install_pre %{___build_pre}\
+ [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
+ mkdir -p `dirname "$RPM_BUILD_ROOT"`\
+ mkdir "$RPM_BUILD_ROOT"\
+ %[0%{?_auto_set_build_cc} ? "%{set_build_cc}" : ""]\
+ %[0%{?_auto_set_build_flags} ? "%{set_build_flags}" : ""]\
+%{nil}
+
+# ---- Expanded at end of %install scriptlet.
+%__arch_install_post /usr/lib/rpm/check-buildroot
+
+# Build root policy macros. Standard naming:
+# convert all '-' in basename to '_', add two leading underscores.
+%__brp_chrpath /usr/lib/rpm/brp-chrpath %{buildroot}
+%__brp_ldconfig /usr/lib/rpm/brp-ldconfig
+%__brp_compress /usr/lib/rpm/brp-compress
+%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
+%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
+%__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip}
+%__brp_check_elf_files /usr/lib/rpm/brp-check-elf-files
+%__brp_python_bytecompile /usr/lib/rpm/brp-python-bytecompile "%{__python}" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}"
+%__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink
+%__brp_remove_la_files /usr/lib/rpm/brp-remove-la-files
+%__brp_remove_info_dir /usr/lib/rpm/brp-remove-info-dir
+
+%__os_install_post \
+ %{?__brp_ldconfig} \
+ %{?__brp_compress} \
+ %{!?__debug_package:\
+ %{?__brp_strip} \
+ %{?__brp_strip_comment_note} \
+ } \
+ %{?__brp_strip_static_archive} \
+ %{?__brp_check_elf_files} \
+ %{?__brp_remove_la_files} \
+ %{?__brp_remove_info_dir} \
+ %{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \
+ %{?__brp_python_hardlink} \
+%{nil}
+
+%__spec_install_post\
+ %{?__debug_package:%{__debug_install_post}}\
+ %{?@VENDOR@_delete_rpath:%{?__brp_chrpath}} \
+ %{__arch_install_post}\
+ %{__os_install_post}\
+%{nil}
+
+%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
+%%install\
+%{nil}
+
+#
+# Should missing buildids terminate a build?
+%_missing_build_ids_terminate_build 1
+
+#
+## Automatically compile python files
+%py_auto_byte_compile 1
+
+#
+## Should python bytecompilation errors terminate a build?
+%_python_bytecompile_errors_terminate_build 1
+## Should python bytecompilation compile outisde python specific directories?
+%_python_bytecompile_extra 1
+
+# Use SHA-256 for FILEDIGESTS instead of default MD5
+%_source_filedigest_algorithm 8
+%_binary_filedigest_algorithm 8
+
+# Use XZ compression for binary payloads
+%_binary_payload w2.xzdio
+
+
+# secure options for rpmbuild
+#
+# #hardened options
+%_hardening_gcc_cflags -specs=/usr/lib/rpm/generic-hardened-cc1
+%_hardening_clang_cflags --config /usr/lib/rpm/generic-hardened-clang.cfg
+%_hardening_cflags %{expand:%%{_hardening_%{toolchain}_cflags}}
+%_hardening_ldflags -Wl,-z,now %[ "%{toolchain}" == "gcc" ? "-specs=/usr/lib/rpm/generic-hardened-ld" : "" ]
+# Use "%undefine _hardened_build" to disable.
+%_hardened_build 1
+%_hardened_cflags %{?_hardened_build:%{_hardening_cflags}}
+%_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}}
+
+#secure options pie
+%_sec_opt_build 1
+#Use "%undefine _sec_opt_build" to disable.
+#Use "%undefine _pie_build" to disable.
+%_pie_build 1
+%_pie_pre_cflags -specs=/usr/lib/rpm/generic-pie-cc1
+%_pie_pre_ldflags -Wl,-z,now -specs=/usr/lib/rpm/generic-pie-ld
+%_pie_cflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_cflags}}
+%_pie_ldflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_ldflags}}
+
+#Use "%undefine _fs_build" to disable.
+%_fs_build 1
+%_fs_pre_cflags -specs=/usr/lib/rpm/generic-fs-cc1
+%_fs_cflags %{?_fs_build:%{_fs_pre_cflags}}
+
+
+# Fail linking if there are undefined symbols. Required for proper
+# ELF symbol versioning support. Disabled by default.
+# Use "%define _ld_strict_symbol_defs 1" to enable.
+#%_ld_strict_symbol_defs 1
+%_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs}
+
+# use "%undefine _ld_as_needed" to disable.
+%_ld_as_needed 1
+%_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed}
+
+%_general_options -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong %[ "%{toolchain}" == "clang" ? "-fgcc-compatible" : "" ]
+%_warning_options -Wall -Werror=format-security
+%_preprocessor_defines -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
+
+%__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags}
+
+# Automatically trim changelog entries after 2 years
+%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)}
+
+#==============================================================================
+# ---- Generic auto req/prov filtering macros
+
+# prevent anything matching from being scanned for provides
+%filter_provides_in(P) %{expand: \
+%global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
+}
+
+# prevent anything matching from being scanned for requires
+%filter_requires_in(P) %{expand: \
+%global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
+}
+
+# filter anything matching out of the provides stream
+%filter_from_provides() %{expand: \
+%global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
+}
+
+# filter anything matching out of the requires stream
+%filter_from_requires() %{expand: \
+%global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
+}
+
+# actually set up the filtering bits
+%filter_setup %{expand: \
+%global _use_internal_dependency_generator 0 \
+%global __deploop() while read FILE; do echo "${FILE}" | /usr/lib/rpm/rpmdeps -%{1}; done | /bin/sort -u \
+%global __find_provides /bin/sh -c "%{?__filter_prov_cmd} %{__deploop P} %{?__filter_from_prov}" \
+%global __find_requires /bin/sh -c "%{?__filter_req_cmd} %{__deploop R} %{?__filter_from_req}" \
+}
+
+# compare two versions, returns -1, 0, 1, ~~~
+%rpm_vercmp() %{lua:print(rpm.expand('%1') == '~~~' and '~~~' or rpm.vercmp(rpm.expand('%1'), rpm.expand('%2')))}
+# expand to the installed version of a package/provides
+%pkg_version() %(LC_ALL=C rpm -q --whatprovides --qf "%%{version}" "%1" | sed -e "s/^no package provides .*/~~~/")
+# compare the installed version to a value. returns -1, 0, 1, ~~~
+%pkg_version_cmp() %{expand:%{expand:%%%%{rpm_vercmp %%{pkg_version %1} %%2}}}
+# convenience/readability
+%pkg_vcmp() (%{expand:%%{pkg_version_cmp %1 %3}} %2 0)
+
+#arches macros
+%generic_arches %{ix86} x86_64 %{arm} aarch64 loongarch64 powerpc64le ppc64le
+%ldc_arches %{generic_arches}
+%valgrind_arches %{generic_arches}
+%nodejs_arches %{generic_arches} riscv64
+%ldc_arches %{generic_arches}
+%mono_arches %{generic_arches}
+%fpc_arches %{generic_arches}
+%ghc_arches_with_ghci %{generic_arches}
+%ghc_arches %{generic_arches}
+%GNAT_arches %{GPRbuild_arches} %{generic_arches}
+%GPRbuild_arches %{generic_arches}
+%nim_arches %{generic_arches}
+%ocaml_native_compiler %{generic_arches} riscv64
+%ocaml_natdynlink %{generic_arches} riscv64
+%ocaml_native_profiling %{generic_arches} riscv64
+%openblas_arches %{generic_arches} riscv64
+
+#%ldconfig /sbin/ldconfig
+%ldconfig_post(n:) %{?ldconfig:%post -p %ldconfig %{?*} %{-n:-n %{-n*}}\
+%end}
+%ldconfig_postun(n:) %{?ldconfig:%postun -p %ldconfig %{?*} %{-n:-n %{-n*}}\
+%end}
+%ldconfig_scriptlets(n:) %{?ldconfig:\
+%ldconfig_post %{?*} %{-n:-n %{-n*}}\
+%ldconfig_postun %{?*} %{-n:-n %{-n*}}\
+}
+
+# Some miscellaneous macros
+%_metainfodir %{_datadir}/metainfo
+%rpmmacrodir /usr/lib/rpm/macros.d
+
+# arches that mono builds on
+%_monogacdir %{_monodir}/gac
+%_monodir %{_prefix}/lib/mono
+
+# ---- VPATH default settings
+%_vpath_builddir %_target_platform
+%_vpath_srcdir .
+
+
+# ---- custom macros
+%disable_rpath \
+sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool \
+sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
+
+%delete_la_and_a \
+find $RPM_BUILD_ROOT -type f -name "*.la" -delete \
+find $RPM_BUILD_ROOT -type f -name "*.a" -delete
+
+%delete_la %{nil}
+
+%chrpath_delete find $RPM_BUILD_ROOT/ -type f -exec file {} ';' | grep "\\<ELF\\>" | awk -F ':' '{print $1}' | xargs -i chrpath --delete {}
+
+%package_help \
+%package help \
+Summary: Documents for %{name} \
+Buildarch: noarch \
+Requires: man info \
+\
+%description help \
+Man pages and other related documents for %{name}.
+
+#%sbin_installinfo_rm bc.info
+#%sbin_installinfo_rm bc.info.gz
+
+%install_info() \
+/sbin/install-info %1 %{_infodir}/dir || :
+
+%install_info_rm() \
+/sbin/install-info --remove %1 %{_infodir}/dir || :
+
+# macros that used for perl
+%__perl /usr/bin/perl
+%requires_eq() %(LC_ALL="C" echo '%*' | xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
+%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
+%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
+%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
+%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
+%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
+%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)