]> git.ipfire.org Git - people/ms/pakfire.git/blob - macros/build.macro
Automatically update autotools for aarch64 compatibility
[people/ms/pakfire.git] / macros / build.macro
1
2
3 def MACRO_EXTRACT_TARBALL
4 for source in %{sources}; do
5 %{MACRO_EXTRACT} %{DIR_DL}/${source} || exit 1
6 done
7 unset source
8
9 [ -d "%{DIR_APP}" ] && cd %{DIR_APP}
10 end
11
12 def MACRO_INSTALL_FILES
13 %{MACRO_INSTALL_DEFAULT_FILES}
14 %{MACRO_INSTALL_SYSTEMD_FILES}
15 %{MACRO_INSTALL_SYSTEMD_TMPFILES}
16 %{MACRO_INSTALL_PAM_FILES}
17 %{MACRO_INSTALL_LOGROTATE_FILES}
18 end
19
20 # XXX to be removed soon
21 def MACRO_INSTALL_DEFAULT_FILES
22 for file in %{DIR_SOURCE}/default/*; do
23 [ -e "${file}" ] || continue
24 mkdir -p %{BUILDROOT}/etc/default
25 cp -vf ${file} %{BUILDROOT}/etc/default/$(basename ${file})
26 done
27 unset file
28 end
29
30 def MACRO_INSTALL_PAM_FILES
31 for file in %{DIR_SOURCE}/{*.pam,pam.d/*}; do
32 [ -e "${file}" ] || continue
33 mkdir -p %{BUILDROOT}/etc/pam.d
34 cp -vf ${file} %{BUILDROOT}/etc/pam.d/$(basename ${file%*.pam})
35 done
36 unset file
37 end
38
39 def MACRO_INSTALL_LOGROTATE_FILES
40 for file in %{DIR_SOURCE}/{*.logrotate,logrotate/*}; do
41 [ -e "${file}" ] || continue
42 mkdir -p %{BUILDROOT}/etc/logrotate.d
43 cp -vf ${file} %{BUILDROOT}/etc/logrotate.d/$(basename ${file%*.logrotate})
44 done
45 unset file
46 end
47
48 def MACRO_PYTHON_COMPILE
49 if [ -x "%{python3}" ]; then
50 %{python3_bytecompile} \
51 %{BUILDROOT}%{python3_sitearch} \
52 %{BUILDROOT}%{python3_sitelib}
53 fi
54
55 if [ -x "%{python}" ]; then
56 %{python_bytecompile} \
57 %{BUILDROOT}%{python_sitearch} \
58 %{BUILDROOT}%{python_sitelib}
59 fi
60 end
61
62 def MACRO_FIX_AUTOTOOLS
63 if [ "%{DISTRO_ARCH}" = "aarch64" ]; then
64 for i in $(find %{DIR_SRC} -name config.guess -or -name config.sub); do
65 if ! grep -q "aarch64" ${i}; then
66 if [ -e "%{datadir}/pakfire/$(basename ${i})" ]; then
67 cp -vf %{datadir}/pakfire/$(basename ${i}) $(dirname ${i})
68 fi
69 fi
70 done
71 fi
72 end
73
74 MACRO_PATCHES = /usr/lib/pakfire/patch --search-path=%{DIR_PATCHES} "%{patches}"
75
76 # Pre-defined build scripts.
77 build
78 # These variables are used if you have to add some targets
79 # directly to the make command.
80 make_build_targets =
81 make_install_targets = install
82
83 def _prepare
84 rm -rf %{BUILDROOT}/*
85 mkdir -p %{DIR_SRC} && cd %{DIR_SRC}
86
87 %{prepare}
88 end
89
90 def prepare
91 # Extract source tarball.
92 %{MACRO_EXTRACT_TARBALL}
93
94 # Apply all patches.
95 %{MACRO_PATCHES}
96
97 # Run custom commands.
98 %{prepare_cmds}
99
100 # Fix outdated autotools on aarch64
101 %{MACRO_FIX_AUTOTOOLS}
102 end
103
104 def prepare_cmds
105 end
106
107 def _build
108 [ -d "%{DIR_APP}" ] && cd %{DIR_APP}
109
110 %{build}
111 end
112
113 def build
114 if [ -e "%{CONFIGURE_SCRIPT}" ]; then
115 ./%{CONFIGURE_SCRIPT} \
116 %{configure_options}
117
118 %{MACRO_FIX_LIBTOOL}
119 fi
120
121 # Run custom commands.
122 %{configure_cmds}
123
124 make %{PARALLELISMFLAGS} %{make_build_targets}
125
126 # Run more custom commands.
127 %{build_cmds}
128 end
129
130 def configure_cmds
131 end
132
133 def build_cmds
134 end
135
136 def _test
137 [ -d "%{DIR_APP}" ] && cd %{DIR_APP}
138
139 %{test}
140 end
141
142 def test
143 end
144
145 def _install
146 [ -d "%{DIR_APP}" ] && cd %{DIR_APP}
147
148 mkdir -pv %{BUILDROOT}
149
150 %{install}
151
152 %{MACRO_INSTALL_FILES}
153 %{MACRO_PYTHON_COMPILE}
154
155 # Cleanup perl modules.
156 %{perl_cleanup}
157
158 %{install_post}
159
160 %{MACRO_QUALITY_AGENT}
161 end
162
163 def install
164 make DESTDIR=%{BUILDROOT} %{make_install_targets}
165
166 # Run custom commands.
167 %{install_cmds}
168 end
169
170 # XXX to be removed soon
171 def install_post
172 end
173
174 # Enable strict processing of build-id by default.
175 # The build will fail if a file is missing its build-id.
176 debuginfo_strict_build_id = true
177 debuginfo_options =
178 end