linux 4.15.4: add missing patches
[openadk.git] / mk / package.mk
blob96add5789e9aad6d0cf277fe9f706071cc22011f
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 all: build-all-pkgs
6 # does not change CONFIGURE_ARGS in minimal mode
7 ifeq ($(filter minimal,${CONFIG_STYLE}),)
8 ifneq ($(ADK_DEBUG),)
9 CONFIGURE_ARGS+= --enable-debug
10 endif
11 endif
13 AUTOTOOL_ENV+= PATH='${HOST_PATH}' \
14 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
15 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
16 ${COMMON_ENV}
18 MESON_ENV+= PATH='${HOST_PATH}' \
19 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
20 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}'
22 CONFIGURE_ENV+= PATH='${TARGET_PATH}' \
23 ${COMMON_ENV} \
24 ${TARGET_ENV} \
25 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
26 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
27 cross_compiling=yes
29 CONFIGURE_PROG?= configure
30 MAKE_FILE?= Makefile
31 # this is environment for 'make all' and 'make install'
32 MAKE_ENV?=
33 # this is arguments for 'make all' and 'make install'
34 XAKE_FLAGS?=
35 # this is arguments for 'make all' ONLY
36 MAKE_FLAGS?=
37 # this is arguments for 'make install' ONLY
38 FAKE_FLAGS?=
39 ALL_TARGET?= all
40 INSTALL_TARGET?= install
42 MAKE_ENV+= PATH='${TARGET_PATH}' \
43 ${COMMON_ENV} \
44 ${TARGET_ENV} \
45 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
46 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
47 WRKDIR='${WRKDIR}' WRKDIST='${WRKDIST}' \
48 WRKSRC='${WRKSRC}' WRKBUILD='${WRKBUILD}'
50 MAKE_FLAGS+= ${XAKE_FLAGS}
51 FAKE_FLAGS+= ${XAKE_FLAGS}
53 ifeq ($(strip ${WRKDIR_BSD}),)
54 WRKDIR_BASE:= ${BUILD_DIR}
55 else
56 WRKDIR_BASE:= $(shell pwd)
57 endif
59 _EXTRACT_COOKIE= ${WRKDIST}/.extract_done
60 _PATCH_COOKIE= ${WRKDIST}/.prepared
61 _CONFIGURE_COOKIE= ${WRKBUILD}/.configure_done
62 _BUILD_COOKIE= ${WRKBUILD}/.build_done
63 _FAKE_COOKIE= ${WRKINST}/.fake_done
64 _IPKGS_COOKIE= ${STAGING_PKG_DIR}/stamps/${PKG_NAME}\x01${PKG_VERSION}-${PKG_RELEASE}
66 _IN_PACKAGE:= 1
67 include ${ADK_TOPDIR}/mk/buildhlp.mk
69 # defined in buildhlp.mk ('extract' can fail, use 'patch' then)
70 extract: ${_EXTRACT_COOKIE}
71 patch: ${_PATCH_COOKIE}
73 # defined below (will be moved to pkg-bottom.mk!)
74 configure: ${_CONFIGURE_COOKIE}
75 build: ${_BUILD_COOKIE}
76 fake: ${_FAKE_COOKIE}
78 # our recursive build entry point
79 build-all-pkgs: ${_IPKGS_COOKIE}
81 # there are some parameters to the PKG_template function
82 # 1.) Config.in identifier ADK_PACKAGE_$(1)
83 # 2.) name of the package, for single package mostly $(PKG_NAME)
84 # 3.) package version (upstream version) and package release (adk version),
85 # always $(PKG_VERSION)-$(PKG_RELEASE)
86 # 4.) dependencies to other packages, $(PKG_DEPENDS)
87 # 5.) description for the package, $(PKG_DESCR)
88 # 6.) section of the package, $(PKG_SECTION)
89 # 7.) special package options $(PKG_OPTS)
90 # noscripts -> do not install scripts to $(STAGING_TARGET_DIR)/scripts
91 # (needed for example for autoconf/automake)
92 # noremove -> do not remove files from $(STAGING_TARGET_DIR) while
93 # cleaning (needed for toolchain packages like glibc)
94 # nostaging -> do not install files to $(STAGING_TARGET_DIR)
95 # nostrip -> do not strip files
96 # dev -> create a development subpackage with headers and pkg-config files
97 # devonly -> create a development package only
98 # should be package format independent and modular in the future
99 define PKG_template
100 ALL_PKGOPTS+= $(1)
101 PKGNAME_$(1)= $(2)
102 PKGDEPS_$(1)= $(4)
103 PKGDESC_$(1)= $(5)
104 PKGSECT_$(1)= $(6)
105 IPKG_$(1)= $(PACKAGE_DIR)/$(2)_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
106 IPKG_$(1)_DEV= $(PACKAGE_DIR)/$(2)-dev_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
107 IPKG_$(1)_DBG= $(PACKAGE_DIR)/$(2)-dbg_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
108 IDIR_$(1)= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)
109 IDIR_$(1)_DEV= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)-dev
110 IDIR_$(1)_DBG= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)-dbg
111 ifneq (${ADK_PACKAGE_$(1)}${DEVELOPER},)
112 ifneq (,$(filter dev,$(7)))
113 ifneq ($(ADK_TARGET_USE_STATIC_LIBS_ONLY),y)
114 ifneq ($(ADK_TARGET_BINFMT_FLAT),y)
115 ALL_IPKGS+= $$(IPKG_$(1))
116 ALL_IDIRS+= $${IDIR_$(1)}
117 ALL_POSTINST+= $(2)-install
118 $(2)-install:
119 endif
120 endif
121 else
122 ALL_IPKGS+= $$(IPKG_$(1))
123 ALL_IDIRS+= $${IDIR_$(1)}
124 ALL_POSTINST+= $(2)-install
125 $(2)-install:
126 endif
127 endif
128 INFO_$(1)= $(PKG_STATE_DIR)/info/$(2).list
129 INFO_$(1)_DEV= $(PKG_STATE_DIR)/info/$(2)-dev.list
130 INFO_$(1)_DBG= $(PKG_STATE_DIR)/info/$(2)-dbg.list
132 ifeq ($(ADK_PACKAGE_$(1)),y)
134 ifeq (,$(filter devonly,$(7)))
135 ifeq ($(ADK_PACKAGE_$(1)_DBG),y)
136 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG)
137 ifeq ($(ADK_PACKAGE_$(1)_DEV),y)
138 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG) $$(INFO_$(1)_DEV)
139 else
140 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG)
141 endif
142 else
143 ifeq ($(ADK_PACKAGE_$(1)_DEV),y)
144 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DEV)
145 else
146 install-targets: $$(INFO_$(1))
147 endif
148 endif
149 else
150 install-targets: $$(INFO_$(1))
151 endif
153 endif
155 IDEPEND_$(1):= $$(strip $(4))
157 _ALL_CONTROLS+= $$(IDIR_$(1))/CONTROL/control
158 ICONTROL_$(1)?= $(WRKDIR)/.$(2).control
159 ICONTROL_$(1)_DEV?= $(WRKDIR)/.$(2)-dev.control
160 ICONTROL_$(1)_DBG?= $(WRKDIR)/.$(2)-dbg.control
161 $$(IDIR_$(1))/CONTROL/control: ${_PATCH_COOKIE}
162 @echo "Package: $$(shell echo $(2) | tr '_' '-')" > $(WRKDIR)/.$(2).control
163 @echo "Section: $(6)" >> $(WRKDIR)/.$(2).control
164 @echo "Description: $(5)" >> $(WRKDIR)/.$(2).control
165 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)} $${ICONTROL_$(1)} $(3) ${ADK_TARGET_CPU_ARCH}
166 @adeps='$$(strip $${IDEPEND_$(1)})'; if [[ -n $$$$adeps ]]; then \
167 comma=; \
168 deps=; \
169 last=; \
170 for dep in $$$$adeps; do \
171 if [[ $$$$last = kernel && $$$$dep = \(* ]]; then \
172 deps="$$$$deps $$$$dep"; \
173 else \
174 deps="$$$$deps$$$$comma$$$$dep"; \
175 fi; \
176 comma=", "; \
177 last=$$$$dep; \
178 done; \
179 echo "Depends: $$$$deps" | tr '_' '-' >>$${IDIR_$(1)}/CONTROL/control; \
181 @for file in conffiles preinst postinst prerm postrm; do \
182 [ ! -f ./files/$(2).$$$$file ] || cp ./files/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file; \
183 done
184 ifeq ($(ADK_BUILD_WITH_DEBUG),y)
185 @echo "Package: $$(shell echo $(2) | tr '_' '-')-dbg" > $(WRKDIR)/.$(2)-dbg.control
186 @echo "Section: debug" >> $(WRKDIR)/.$(2)-dbg.control
187 @echo "Description: debugging symbols for $(2)" >> $(WRKDIR)/.$(2)-dbg.control
188 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)_DBG} $${ICONTROL_$(1)_DBG} $(3) ${ADK_TARGET_CPU_ARCH}
189 @echo "Depends: $$(shell echo $(2) | tr '_' '-')" >> $${IDIR_$(1)_DBG}/CONTROL/control
190 endif
191 ifneq (,$(filter dev,$(7)))
192 @echo "Package: $$(shell echo $(2) | tr '_' '-')-dev" > $(WRKDIR)/.$(2)-dev.control
193 @echo "Section: devel" >> $(WRKDIR)/.$(2)-dev.control
194 @echo "Description: development files for $(2)" >> $(WRKDIR)/.$(2)-dev.control
195 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)_DEV} $${ICONTROL_$(1)_DEV} $(3) ${ADK_TARGET_CPU_ARCH}
196 @echo "Depends: $$(shell echo $(2) | tr '_' '-')" >> $${IDIR_$(1)_DEV}/CONTROL/control
197 endif
199 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $${_FAKE_COOKIE}
200 ifeq (,$(filter nostrip,$(7)))
201 ifeq ($(ADK_DEBUG),)
202 @$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
203 endif
204 ifeq ($(ADK_DEBUG_STRIP),y)
205 @$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
206 endif
207 endif
208 ifeq (${ADK_LEAVE_ETC_ALONE}$(filter force_etc,$(7)),y)
209 -rm -rf $${IDIR_$(1)}/etc
210 else
211 ifeq (${ADK_INSTALL_PACKAGE_INIT_SCRIPTS},y)
212 @for file in $$$$(ls ./files/*.init 2>/dev/null); do \
213 fname=$$$$(echo $$$$file| sed -e "s#.*/##" -e "s#.init##"); \
214 check=$$$$(grep PKG $$$$file|cut -d ' ' -f 2); \
215 if [ "$$$$check" == $(2) ];then \
216 mkdir -p $$(IDIR_$(1))/etc/init.d && cp $$$$file $$(IDIR_$(1))/etc/init.d/$$$$fname; \
217 fi; \
218 done
219 @cd $${IDIR_$(1)}; for script in etc/init.d/*; do \
220 [[ -e $$$$script ]] || continue; \
221 chmod 0755 "$$$$script"; \
222 done
223 endif
224 ifneq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
225 -@rm -rf $${IDIR_$(1)}/etc/network
226 endif
227 ifeq (${ADK_RUNTIME_INIT_SYSTEMD},y)
228 @for file in $$$$(ls ./files/*.service 2>/dev/null); do \
229 fname=$$$$(echo $$$$file| sed -e "s#.*/##"); \
230 mkdir -p $$(IDIR_$(1))/usr/lib/systemd/system && cp $$$$file $$(IDIR_$(1))/usr/lib/systemd/system/$$$$fname; \
231 mkdir -p $$(IDIR_$(1))/etc/systemd/system/multi-user.target.wants; \
232 ln -sf ../../../../usr/lib/systemd/system/$$$$fname \
233 $$(IDIR_$(1))/etc/systemd/system/multi-user.target.wants; \
234 done
235 endif
236 endif
237 @mkdir -p $${PACKAGE_DIR} '$${STAGING_PKG_DIR}/stamps' \
238 '$${STAGING_TARGET_DIR}/scripts'
239 @for file in $$$$(ls ./files/*.perm 2>/dev/null); do \
240 cat $$$$file >> $${STAGING_TARGET_DIR}/scripts/permissions.sh; \
241 done
242 ifeq (,$(filter noremove,$(7)))
243 @if test -s '$${STAGING_PKG_DIR}/$(1)'; then \
244 cd '$${STAGING_TARGET_DIR}'; \
245 while read fn; do \
246 rm -f "$$$$fn"; \
247 done <'$${STAGING_PKG_DIR}/$(1)'; \
249 endif
250 @rm -f '$${STAGING_PKG_DIR}/$(1)'
251 ifeq (,$(filter nostaging,$(7)))
252 @-cd $${IDIR_$(1)}; \
253 x=$$$$(find tmp run -mindepth 1 2>/dev/null); if [[ -n $$$$x ]]; then \
254 echo 'WARNING: $${IPKG_$(1)} installs files into a' \
255 'ramdisk location:' >&2; \
256 echo "$$$$x" | sed 's/^/- /' >&2; \
257 fi; \
258 find usr ! -type d 2>/dev/null | \
259 grep -E -v -e '^usr/lib/pkgconfig' -e '^usr/share' -e '^usr/doc' -e '^usr/src' -e '^usr/man' \
260 -e '^usr/info' -e '^usr/lib/libc.so' -e '^usr/bin/[a-z0-9-]+-config' -e '^usr/lib/.*\.la$$$$' | \
261 tee '$${STAGING_PKG_DIR}/$(1)' | \
262 $(CPIO) -padlmu --quiet '$${STAGING_TARGET_DIR}'
263 endif
264 ifeq (,$(filter noscripts,$(7)))
265 @cd '$${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
266 '$${STAGING_PKG_DIR}/$(1)' | \
267 while read fn; do \
268 b="$$$$(dd if="$$$$fn" bs=2 count=1 2>/dev/null)"; \
269 [[ $$$$b = '#!' ]] || continue; \
270 cp "$$$$fn" scripts/; \
271 echo "scripts/$$$$(basename "$$$$fn")" \
272 >>'$${STAGING_PKG_DIR}/$(1)'; \
273 done
274 endif
276 ifeq (,$(filter devonly,$(7)))
277 PATH='$(HOST_PATH)' $${PKG_BUILD} $${IDIR_$(1)} $${PACKAGE_DIR} $(MAKE_TRACE)
278 ifneq ($(ADK_BUILD_WITH_DEBUG),)
279 PATH='$(HOST_PATH)' $${PKG_BUILD} $${IDIR_$(1)_DBG} $${PACKAGE_DIR} $(MAKE_TRACE)
280 endif
281 endif
282 ifneq (,$(filter dev,$(7)))
283 PATH='$(HOST_PATH)' $${PKG_BUILD} $${IDIR_$(1)_DEV} $${PACKAGE_DIR} $(MAKE_TRACE)
284 endif
286 clean-targets: clean-dev-$(1)
288 clean-dev-$(1):
289 ifeq (,$(filter noremove,$(7)))
290 @if test -s '$${STAGING_PKG_DIR}/$(1)'; then \
291 cd '$${STAGING_TARGET_DIR}'; \
292 while read fn; do \
293 rm -f "$$$$fn"; \
294 done <'$${STAGING_PKG_DIR}/$(1)'; \
296 endif
297 @rm -f '$${STAGING_PKG_DIR}/$(1)'
299 $$(INFO_$(1)): $$(IPKG_$(1))
300 $(PKG_INSTALL) $$(IPKG_$(1))
302 $$(INFO_$(1)_DBG): $$(IPKG_$(1)_DBG)
303 $(PKG_INSTALL) $$(IPKG_$(1)_DBG)
305 ifneq ($(1),UCLIBC_NG)
306 ifneq ($(1),GLIBC)
307 ifneq ($(1),MUSL)
308 $$(INFO_$(1)_DEV): $$(IPKG_$(1)_DEV)
309 $(PKG_INSTALL) $$(IPKG_$(1)_DEV)
310 endif
311 endif
312 endif
314 endef
316 install-targets:
317 install:
318 @$(CMD_TRACE) "installing.. "
319 @$(MAKE) install-targets $(MAKE_TRACE)
321 clean-targets:
322 clean:
323 @printf " ---> cleaning package build directories and files.. "
324 @$(MAKE) clean-targets $(MAKE_TRACE)
325 rm -rf ${WRKDIR} ${ALL_IPKGS} ${_IPKGS_COOKIE}
326 @printf " done\n"
328 distclean: clean
329 rm -f ${FULLDISTFILES}
331 .PHONY: all refetch extract patch configure \
332 build fake package install clean build-all-pkgs