cosmetic changes
[openadk.git] / mk / buildhlp.mk
blob68480161770ef6ecbf9a0895684792860b1ed7db
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 ifneq ($(strip ${PKG_SITES}),)
5 ifeq ($(strip ${DISTFILES}),)
6 DISTFILES:= ${PKG_NAME}-${PKG_VERSION}.tar.gz
7 endif
8 endif
10 # This is where all package operation is done in
11 WRKDIR?= ${WRKDIR_BASE}/w-${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}
12 # This is where source code is extracted and patched
13 WRKDIST?= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION}
14 # This is where the configure script is seeked (localed)
15 WRKSRC?= ${WRKDIST}
16 # This is where configure, make and make install (fake) run from
17 WRKBUILD?= ${WRKSRC}
18 # This is where make install (fake) writes to
19 WRKINST?= ${WRKDIR}/fake-${CPU_ARCH}/root
21 ifeq ($(strip ${NO_CHECKSUM}),)
22 _CHECKSUM_COOKIE= ${WRKDIR}/.checksum_done
23 else
24 _CHECKSUM_COOKIE=
25 endif
27 post-extract:
29 ifeq ($(strip ${NO_DISTFILES}),1)
30 ${WRKDIST}/.extract_done:
31 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
32 mkdir -p ${WRKDIR} ${WRKDIST}
33 ${MAKE} do-extract
34 @${MAKE} post-extract
35 touch $@
37 fetch refetch checksum do-extract:
39 __use_generic_patch_target:=42
40 else ifneq ($(strip ${DISTFILES}),)
41 include ${TOPDIR}/mk/fetch.mk
43 ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
44 ifeq (${_CHECKSUM_COOKIE},)
45 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
46 endif
47 ${EXTRACT_CMD}
48 @${MAKE} post-extract
49 touch $@
51 __use_generic_patch_target:=42
52 else ifeq ($(strip ${_IN_PACKAGE}),1)
53 $(warning This package does not use the generic extraction and patch target; it's most likely to fail.)
54 endif
56 ifeq ($(strip ${__use_generic_patch_target}),42)
57 post-patch:
58 ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
59 [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
60 '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
61 [ ! -d ./extra ] || (cd extra; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
62 $(MAKE_TRACE)
63 @${MAKE} post-patch $(MAKE_TRACE)
64 touch $@
65 endif
67 update-patches:
68 @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
69 @test ! -d ${WRKDIR}.orig
70 ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
71 @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
72 else
73 @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
74 endif
75 @# restore config.sub/config.guess
76 @for i in $$(find ${WRKDIR} -name config.sub);do \
77 if [ -f $$i.bak ];then \
78 mv $$i.bak $$i; \
79 fi;\
80 done
81 @for i in $$(find ${WRKDIR} -name config.guess);do \
82 if [ -f $$i.bak ];then \
83 mv $$i.bak $$i; \
84 fi;\
85 done
86 @toedit=$$(WRKDIST='${WRKDIST}' CURDIR=$$(pwd) \
87 PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \
88 ${BASH} ${TOPDIR}/scripts/update-patches); \
89 if [[ -n $$toedit && $$toedit != FAIL ]]; then \
90 echo -n 'edit patches: '; read i; \
91 cd patches && $${VISUAL:-$${EDITOR:-vi}} $$toedit; \
92 fi; \
93 rm -rf ${WRKDIR}.orig; \
94 [[ $$toedit != FAIL ]]
96 .PHONY: update-patches