imgtec-ci20: genimage config/ u-boot env
[openadk.git] / mk / buildhlp.mk
bloba0ae7ac7f1f3cc9a8bffc29e4da32ee0eba3371c
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 @# find any reject files and delete them
78 @find $(WRKDIST)/ -name \*.rej -delete
79 [ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
80 '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
81 [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
82 '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
83 [ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
84 $(MAKE_TRACE)
85 @${MAKE} post-patch $(MAKE_TRACE)
86 @# always use latest config.sub/config.guess from OpenADK scripts directory
87 @cd ${WRKDIST}; \
88 for i in $$(find . -name config.sub);do \
89 if [ -f $$i ]; then \
90 ${CP} ${SCRIPT_DIR}/config.sub $$i; \
91 fi; \
92 done; \
93 for i in $$(find . -name config.guess);do \
94 if [ -f $$i ]; then \
95 ${CP} ${SCRIPT_DIR}/config.guess $$i; \
96 fi; \
97 done;
98 touch $@
99 endif
101 update-patches host-update-patches:
102 ifneq (${ADK_UPDATE_PATCHES_GIT},)
103 PATH='${HOST_PATH}' ${BASH} $(SCRIPT_DIR)/update-patches-git "${WRKDIST}"
104 else
105 @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
106 @test ! -d ${WRKDIR}.orig
107 ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
108 @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: PKG_NOCHECKSUM=1
109 else
110 @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: PKG_NOCHECKSUM=1
111 endif
112 @-test ! -r ${WRKDIR}/.autoreconf_done || \
113 (wrkdist=$(WRKDIST) dir=$${wrkdist#$(WRKDIR)}; \
114 cd ${WRKDIR}.orig$${dir}; \
115 env ${AUTOTOOL_ENV} autoreconf -if > /dev/null 2>&1; \
116 rm -rf ${WRKDIR}.orig$${dir}/autom4te.cache ) $(MAKE_TRACE)
117 @# restore config.sub/config.guess
118 @WRKDIST=$(call shellescape,${WRKDIST}) \
119 WRKDIR1=$(call shellescape,${WRKDIR}) \
120 PATH=$(call shellescape,${HOST_PATH}) \
121 $(call shellexport,DIFF_IGNOREFILES) \
122 mksh ${ADK_TOPDIR}/scripts/update-patches2
123 endif
125 .PHONY: update-patches host-update-patches