qtbase: add new package, use device method like buildroot for cross-compile
[openadk.git] / mk / buildhlp.mk
blobc2aeb3800a727219ea8706022fe628091c6aa6d3
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 shellescape='$(subst ','\'',$(1))'
5 shellexport=$(1)=$(call shellescape,${$(1)})
7 ifneq ($(strip ${PKG_SITES}),)
8 ifeq ($(strip ${DISTFILES}),)
9 DISTFILES:= ${PKG_NAME}-${PKG_VERSION}.tar.xz
10 endif
11 endif
13 # This is where all package operation is done in
14 WRKDIR?= ${WRKDIR_BASE}/w-${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}
15 # This is where source code is extracted and patched
16 WRKDIST?= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION}
17 # This is where the configure script is seeked (localed)
18 WRKSRC?= ${WRKDIST}
19 # This is where configure, make and make install (fake) run from
20 WRKBUILD?= ${WRKSRC}
21 # This is where make install (fake) writes to
22 WRKINST?= ${WRKDIR}/fake-${ADK_TARGET_CPU_ARCH}/root
24 ifeq ($(strip ${PKG_NOCHECKSUM}),)
25 _CHECKSUM_COOKIE= ${WRKDIR}/.checksum_done
26 else
27 _CHECKSUM_COOKIE=
28 endif
30 post-extract:
31 ifeq ($(strip ${NO_DISTFILES}),1)
32 ${WRKDIST}/.extract_done:
33 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
34 @mkdir -p ${WRKDIR} ${WRKDIST}
35 ${MAKE} do-extract
36 @${MAKE} post-extract $(MAKE_TRACE)
37 touch $@
39 fetch refetch checksum do-extract:
41 __use_generic_patch_target:=42
42 else ifneq ($(strip ${DISTFILES}),)
43 include ${ADK_TOPDIR}/mk/fetch.mk
45 ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
46 ifeq (${_CHECKSUM_COOKIE},)
47 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
48 endif
49 ifeq ($(EXTRACT_OVERRIDE),1)
50 ${MAKE} do-extract
51 else
52 ${EXTRACT_CMD}
53 endif
54 @${MAKE} post-extract $(MAKE_TRACE)
55 touch $@
57 __use_generic_patch_target:=42
58 else
59 include ${ADK_TOPDIR}/mk/fetch.mk
60 ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
61 $(MAKE) fetch
62 ifeq (${_CHECKSUM_COOKIE},)
63 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
64 endif
65 ifeq ($(EXTRACT_OVERRIDE),1)
66 ${MAKE} do-extract
67 else
68 ${EXTRACT_CMD}
69 endif
70 @${MAKE} post-extract $(MAKE_TRACE)
71 touch $@
72 endif
74 ifeq ($(strip ${__use_generic_patch_target}),42)
75 post-patch:
76 ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
77 [ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
78 '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
79 [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
80 '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
81 [ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
82 $(MAKE_TRACE)
83 @${MAKE} post-patch $(MAKE_TRACE)
84 @# always use latest config.sub/config.guess from OpenADK scripts directory
85 @cd ${WRKDIST}; \
86 for i in $$(find . -name config.sub);do \
87 if [ -f $$i ]; then \
88 ${CP} ${SCRIPT_DIR}/config.sub $$i; \
89 fi; \
90 done; \
91 for i in $$(find . -name config.guess);do \
92 if [ -f $$i ]; then \
93 ${CP} ${SCRIPT_DIR}/config.guess $$i; \
94 fi; \
95 done;
96 touch $@
97 endif
99 update-patches host-update-patches:
100 ifneq (${ADK_UPDATE_PATCHES_GIT},)
101 PATH='${HOST_PATH}' ${BASH} $(SCRIPT_DIR)/update-patches-git "${WRKDIST}"
102 else
103 @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
104 @test ! -d ${WRKDIR}.orig
105 ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
106 @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: PKG_NOCHECKSUM=1
107 else
108 @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: PKG_NOCHECKSUM=1
109 endif
110 @-test ! -r ${WRKDIR}/.autoreconf_done || \
111 (wrkdist=$(WRKDIST) dir=$${wrkdist#$(WRKDIR)}; \
112 cd ${WRKDIR}.orig$${dir}; \
113 env ${AUTOTOOL_ENV} autoreconf -if > /dev/null 2>&1; \
114 rm -rf ${WRKDIR}.orig$${dir}/autom4te.cache ) $(MAKE_TRACE)
115 @# restore config.sub/config.guess
116 @WRKDIST=$(call shellescape,${WRKDIST}) \
117 WRKDIR1=$(call shellescape,${WRKDIR}) \
118 PATH=$(call shellescape,${HOST_PATH}) \
119 $(call shellexport,DIFF_IGNOREFILES) \
120 mksh ${ADK_TOPDIR}/scripts/update-patches2
121 endif
123 .PHONY: update-patches host-update-patches