fix target system names
[openadk.git] / mk / buildhlp.mk
blob2cb4f17149b9d91df25eed0051cbb1e6c71d916b
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 ${PACKAGE_DIR}/.stamps:
28 @mkdir -p ${PACKAGE_DIR}/.stamps
30 post-extract: ${PACKAGE_DIR}/.stamps
32 ifeq ($(strip ${NO_DISTFILES}),1)
33 ${WRKDIST}/.extract_done:
34 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
35 @mkdir -p ${WRKDIR} ${WRKDIST}
36 ${MAKE} do-extract
37 @${MAKE} post-extract $(MAKE_TRACE)
38 touch $@
40 fetch refetch checksum do-extract:
42 __use_generic_patch_target:=42
43 else ifneq ($(strip ${DISTFILES}),)
44 include ${TOPDIR}/mk/fetch.mk
46 ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
47 ifeq (${_CHECKSUM_COOKIE},)
48 rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
49 endif
50 ${EXTRACT_CMD}
51 @${MAKE} post-extract $(MAKE_TRACE)
52 touch $@
54 __use_generic_patch_target:=42
55 else ifeq ($(strip ${_IN_PACKAGE}),1)
56 $(warning This package does not use the generic extraction and patch target; it's most likely to fail.)
57 endif
59 ifeq ($(strip ${__use_generic_patch_target}),42)
60 post-patch:
61 ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
62 [ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
63 '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
64 [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
65 '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
66 [ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
67 $(MAKE_TRACE)
68 @${MAKE} post-patch $(MAKE_TRACE)
69 touch $@
70 endif
72 update-patches:
73 @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
74 @test ! -d ${WRKDIR}.orig
75 ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
76 @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
77 else
78 @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
79 endif
80 @# restore config.sub/config.guess
81 @for i in $$(find ${WRKDIR} -name config.sub);do \
82 if [ -f $$i.bak ];then \
83 mv $$i.bak $$i; \
84 fi;\
85 done
86 @for i in $$(find ${WRKDIR} -name config.guess);do \
87 if [ -f $$i.bak ];then \
88 mv $$i.bak $$i; \
89 fi;\
90 done
91 @toedit=$$(WRKDIST='${WRKDIST}' CURDIR=$$(pwd) \
92 PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \
93 ${BASH} ${TOPDIR}/scripts/update-patches); \
94 if [[ -n $$toedit && $$toedit != FAIL ]]; then \
95 echo -n 'edit patches: '; read i; \
96 cd patches && $${VISUAL:-$${EDITOR:-vi}} $$toedit; \
97 fi; \
98 rm -rf ${WRKDIR}.orig; \
99 [[ $$toedit != FAIL ]]
101 .PHONY: update-patches