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 # * pre/do/post-foo are always defined here, but empty. This is so
5 # that we can call it (BSD make has .if target(foo) but GNU not)
6 # and it won't error out.
7 # * ${_foo_COOKIE} are the actual targets
9 # * define "manual" if you need your own method
10 # -> define a do-foo: target in the Makefile
11 # * if you have a style -> define a pre-foo: and post-foo: if they
12 # are required, but the do-foo: magic is done here
14 PKG_LIBNAME?
= $(PKG_NAME
)
16 ifeq ($(ADK_TARGET_USE_SHARED_LIBS_ONLY
),y
)
17 CONFIGURE_LIB
:=--disable-static
--enable-shared
19 ifeq ($(ADK_TARGET_USE_STATIC_LIBS_ONLY
),y
)
20 CONFIGURE_LIB
:=--enable-static
--disable-shared
22 ifeq ($(ADK_TARGET_USE_SHARED_AND_STATIC_LIBS
)$(ADK_TARGET_USE_STATIC_AND_SHARED_LIBS
),y
)
23 CONFIGURE_LIB
:=--enable-static
--enable-shared
29 ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
30 ifneq (,$(filter bootstrap
,${AUTOTOOL_STYLE}))
31 @
$(CMD_TRACE
) "autotooling.. "
32 @cd
${WRKSRC}; env
${AUTOTOOL_ENV} $(BASH
) bootstrap
* $(MAKE_TRACE
)
34 ifneq (,$(filter autogen
,${AUTOTOOL_STYLE}))
35 @
$(CMD_TRACE
) "autotooling.. "
36 @cd
${WRKSRC}; env
${AUTOTOOL_ENV} $(BASH
) autogen.sh
$(MAKE_TRACE
)
38 ifneq (,$(filter autoconf
,${AUTOTOOL_STYLE}))
39 @
$(CMD_TRACE
) "autotooling.. "
40 @cd
${WRKSRC}; env
${AUTOTOOL_ENV} autoconf
$(MAKE_TRACE
)
42 ifneq (,$(filter autoreconf
,${AUTOTOOL_STYLE}))
43 @
$(CMD_TRACE
) "autotooling.. "
44 @cd
${WRKSRC}; env
${AUTOTOOL_ENV} autoreconf
-vif
$(MAKE_TRACE
)
45 @
rm -rf
${WRKSRC}/autom4te.cache
46 @touch
${WRKDIR}/.autoreconf_done
49 @
${MAKE} pre-configure
$(MAKE_TRACE
)
51 ifneq ($(filter manual
,${CONFIG_STYLE}),)
52 env
${CONFIGURE_ENV} ${MAKE} do-configure
$(MAKE_TRACE
)
53 else ifneq ($(filter meson
,${CONFIG_STYLE}),)
54 @
$(CMD_TRACE
) "configuring meson.. "
55 (cd
${WRKSRC} && $(MESON_ENV
) \
56 meson setup
--prefix /usr
--libdir lib \
57 --cross-file
$(STAGING_HOST_DIR
)/etc
/meson
/cross-compilation.conf \
58 --build.pkg-config-path
$(STAGING_HOST_DIR
)/usr
/lib
/pkgconfig \
59 --buildtype release
$(MESON_FLAGS
) \
60 $(WRKSRC
) $(WRKBUILD
)) $(MAKE_TRACE
)
61 else ifneq ($(filter cmake
,${CONFIG_STYLE}),)
62 @
$(CMD_TRACE
) "configuring cmake.. "
63 sed
-e
"s#@@TARGET_CC@@#$(TARGET_CC_NO_CCACHE)#" \
64 -e
"s#@@TARGET_CXX@@#$(TARGET_CXX_NO_CCACHE)#" \
65 -e
"s#@@TARGET_CFLAGS@@#$(TARGET_CFLAGS)#" \
66 -e
"s#@@TARGET_CXXFLAGS@@#$(TARGET_CXXFLAGS)#" \
67 -e
"s#@@TARGET_ARCH@@#$(ADK_TARGET_ARCH)#" \
68 -e
"s#@@STAGING_TARGET_DIR@@#$(STAGING_TARGET_DIR)#g" \
69 -e
"s#@@STAGING_HOST_DIR@@#$(STAGING_HOST_DIR)#g" \
70 $(SCRIPT_DIR
)/toolchain.cmake.in
> $(SCRIPT_DIR
)/toolchain.cmake
71 (cd
${WRKBUILD} && PATH
='${HOST_PATH}' \
72 cmake
-Wno-dev
-DCMAKE_INSTALL_PREFIX
:PATH
=/usr \
73 -DCMAKE_TOOLCHAIN_FILE
="$(SCRIPT_DIR)/toolchain.cmake" \
74 ${CMAKE_FLAGS} ${WRKSRC}) $(MAKE_TRACE
)
75 else ifneq ($(filter minimal
,${CONFIG_STYLE}),)
76 @
$(CMD_TRACE
) "configuring.. "
77 cd
${WRKBUILD}; rm -f config.
{cache
,status
}; \
78 env
${CONFIGURE_ENV} \
79 ${BASH} ${WRKSRC}/${CONFIGURE_PROG} \
80 ${CONFIGURE_ARGS} $(MAKE_TRACE
)
81 else ifneq ($(filter basic
,${CONFIG_STYLE}),)
82 @
$(CMD_TRACE
) "configuring.. "
83 cd
${WRKBUILD}; rm -f config.
{cache
,status
}; \
84 env
${CONFIGURE_ENV} \
85 ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
86 ${CONFIGURE_ARGS} $(MAKE_TRACE
)
87 else ifneq ($(filter perl
,${CONFIG_STYLE}),)
88 @
$(CMD_TRACE
) "configuring perl module.. "
89 if
[ -f
${WRKBUILD}/Makefile.PL
]; then \
92 PERL_MM_USE_DEFAULT
=1 \
93 PERL_AUTOINSTALL
=--skipdeps \
95 perl-host Makefile.PL
${CONFIGURE_ARGS}; \
100 perl-host Build.PL
; \
102 else ifeq ($(strip ${CONFIG_STYLE}),)
103 @
$(CMD_TRACE
) "configuring.. "
104 cd
${WRKBUILD}; rm -f config.
{cache
,status
}; \
105 env
${CONFIGURE_ENV} \
106 ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
111 --datadir=/usr
/share \
112 --mandir=/usr
/share
/man \
113 --libexecdir
=/usr
/libexec \
114 --localstatedir
=/var \
116 --disable-dependency-tracking \
117 --disable-libtool-lock \
119 --disable-silent-rules \
121 ${CONFIGURE_ARGS} $(MAKE_TRACE
)
123 @echo
"Invalid CONFIG_STYLE '${CONFIG_STYLE}'" >&2
126 @
${MAKE} post-configure
$(MAKE_TRACE
)
129 # do a parallel build if requested && package doesn't force disable it
130 ifeq (${ADK_MAKE_PARALLEL},y
)
131 ifeq ($(strip ${PKG_NOPARALLEL}),)
132 MAKE_FLAGS
+= -j
${ADK_MAKE_JOBS}
139 ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
140 @env
${MAKE_ENV} ${MAKE} pre-build
$(MAKE_TRACE
)
141 @
$(CMD_TRACE
) "compiling.. "
142 ifneq ($(filter meson
,${BUILD_STYLE}),)
143 PATH
='$(HOST_PATH)' ninja
-v
-C
$(WRKBUILD
) $(MAKE_TRACE
)
144 else ifneq ($(filter manual
,${BUILD_STYLE}),)
145 env
${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} do-build
$(MAKE_TRACE
)
146 else ifeq ($(strip ${BUILD_STYLE}),)
147 cd
${WRKBUILD} && env
${MAKE_ENV} ${MAKE} -f
${MAKE_FILE} \
148 ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE
)
150 @echo
"Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
153 @env
${MAKE_ENV} ${MAKE} post-build
$(MAKE_TRACE
)
159 spkg-install
: ${ALL_POSTINST}
160 ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
161 @
-rm -f
${_ALL_CONTROLS}
162 @mkdir
-p
'${STAGING_PKG_DIR}/stamps' ${WRKINST} '${STAGING_TARGET_DIR}/scripts'
163 @
${MAKE} -j
${ADK_MAKE_JOBS} ${_ALL_CONTROLS} $(MAKE_TRACE
)
164 @env
${MAKE_ENV} ${MAKE} pre-install
$(MAKE_TRACE
)
165 ifneq ($(filter meson
,${INSTALL_STYLE}),)
166 DESTDIR
='$(WRKINST)' PATH
='$(HOST_PATH)' \
167 ninja
-C
$(WRKBUILD
) install $(MAKE_TRACE
)
168 else ifneq ($(filter manual
,${INSTALL_STYLE}),)
169 env
${MAKE_ENV} ${MAKE} do-install
$(MAKE_TRACE
)
170 else ifeq ($(strip ${INSTALL_STYLE}),)
171 cd
${WRKBUILD} && env
${MAKE_ENV} ${MAKE} -f
${MAKE_FILE} \
172 DESTDIR
='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE
)
173 env
${MAKE_ENV} ${MAKE} post-install
$(MAKE_TRACE
)
175 @echo
"Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
178 env
${MAKE_ENV} ${MAKE} spkg-install
$(MAKE_TRACE
)
179 @
rm -f
'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'
180 @for a in
${WRKINST}/usr
/bin
/*-config
*; do \
181 [[ -e
$$a ]] || continue
; \
182 sed
-e
"s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
183 ${STAGING_TARGET_DIR}/usr
/bin
/$$(basename $$a); \
184 chmod u
+x
${STAGING_TARGET_DIR}/usr
/bin
/$$(basename $$a); \
185 [[ "$$(basename $$a)" != "pkg-config" ]] && cp
${STAGING_TARGET_DIR}/usr
/bin
/$$(basename $$a) ${STAGING_TARGET_DIR}/scripts
; \
186 echo
"scripts/$$(basename $$a)" \
187 >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
189 ifeq (,$(filter noremove
,${PKG_OPTS}))
190 @if
test -s
'${STAGING_PKG_DIR}/${PKG_NAME}'; then \
191 cd
'${STAGING_TARGET_DIR}'; \
194 done
<'${STAGING_PKG_DIR}/${PKG_NAME}'; \
197 @
rm -f
'${STAGING_PKG_DIR}/${PKG_NAME}'
198 ifneq (,$(filter dev
,${PKG_OPTS}))
199 @mkdir
-p
$(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/include
200 @
test -d
${WRKINST}/usr
/include && cd
${WRKINST}/usr
/include; \
201 find .
-name \
*.h | \
202 $(CPIO
) -padlmu
--quiet
$(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/include
203 @mkdir
-p
$(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/lib
/pkgconfig
204 @
test -d
${WRKINST}/usr
/lib
/pkgconfig
&& cd
${WRKINST}/usr
/lib
/pkgconfig
; \
205 find .
-name \
*.
pc | \
206 $(CPIO
) -padlmu
--quiet
$(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/lib
/pkgconfig
207 @for a in
${WRKINST}/usr
/bin
/*-config
*; do \
208 [[ -e
$$a ]] || continue
; \
209 mkdir
-p
$(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/bin
; \
210 cp
$$a $(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/bin
; \
211 chmod
755 $(WRKDIR
)/fake-
${ADK_TARGET_CPU_ARCH}/pkg-
$(PKG_LIBNAME
)-dev
/usr
/bin
/$$(basename $$a); \
214 ifeq (,$(filter nostaging
,${PKG_OPTS}))
216 find usr
! -type d
2>/dev
/null | \
217 grep
-E
-v
-e
'^usr/src' -e
'^usr/doc' -e
'^usr/local' -e
'^usr/man' -e
'^usr/info' \
218 -e
'^usr/lib/libc.so' -e
'^usr/bin/[a-z0-9-]+-config*' -e
'^usr/lib/.*\.la$$' \
219 -e
'^/usr/lib/libpthread_nonshared.a' | \
220 tee
'${STAGING_PKG_DIR}/${PKG_NAME}' | \
221 $(CPIO
) -padlmu
--quiet
'${STAGING_TARGET_DIR}'
223 ifeq (,$(filter noscripts
,${PKG_OPTS}))
224 @cd
'${STAGING_TARGET_DIR}'; grep
'usr/s*bin/' \
225 '${STAGING_PKG_DIR}/${PKG_NAME}' | \
227 b
="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
228 [[ $$b = '#!' ]] || continue
; \
229 cp
"$$fn" scripts
/; \
230 echo
"scripts/$$(basename "$$fn")" \
231 >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
234 -@
test -e
'${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
235 cat
'${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' ||
:
241 package
: ${ALL_IPKGS}
242 ifneq ($(DEVELOPER
),)
243 @cd
${WRKDIR}/fake-
${ADK_TARGET_CPU_ARCH} || exit
1; \
244 y
=; sp
=; for x in
${ALL_IDIRS}; do \
245 y
="$$y$$sp$${x#$(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/}"; \
247 done
; ls
=; ln
=; x
=1; [[ -z
$$y ]] || \
248 md5sum
$$(find
$$y -type f
) | sed
-e
"s/*//" | \
249 while read sum name
; do \
250 inode
=$$(ls
-i
"$$name"); \
251 echo
"$$sum $${inode%% *} $$name"; \
252 done |
sort | while read sum inode name
; do \
253 if
[[ $$sum = $$ls ]]; then \
254 [[ $$li = $$inode ]] && continue
; \
256 1) echo
'WARNING: duplicate files found in' \
257 'package "${PKG_NAME}"! Fix them.' >&2; \
260 2) echo
-n
"> $$ln "; \
279 touch
${_IPKGS_COOKIE}
281 clean-targets
: clean-dev-generic
284 ifeq (,$(filter noremove
,${PKG_OPTS}))
285 @if
test -s
'${STAGING_PKG_DIR}/${PKG_NAME}'; then \
286 cd
'${STAGING_TARGET_DIR}'; \
289 done
<'${STAGING_PKG_DIR}/${PKG_NAME}'; \
292 @
rm -f
'${STAGING_PKG_DIR}/${PKG_NAME}'
294 ifneq (,$(filter autoreconf
,${AUTOTOOL_STYLE}))
295 DIFF_IGNOREFILES?
= configure missing depcomp install-sh INSTALL \
296 aclocal.m4 config.h.in Makefile.in
*/Makefile.in \
297 config.sub config.guess
*/config.sub
*/config.guess
299 DIFF_IGNOREFILES?
= config.sub config.guess
*/config.sub
*/config.guess