fix download url
[openadk.git] / mk / pkg-bottom.mk
blob66d834df48c924e9f1ce8c57b669c0dc7c153353
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
3 # Comments:
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
8 # * default is "auto"
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_STATIC_LIBS),y)
17 CONFIGURE_LIB:=--enable-static --disable-shared
18 else
19 CONFIGURE_LIB:=--enable-static --enable-shared
20 endif
22 pre-configure:
23 do-configure:
24 post-configure:
25 ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
26 ifneq (,$(filter bootstrap,${AUTOTOOL_STYLE}))
27 @$(CMD_TRACE) "autotool configuring... "
28 @cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) bootstrap.sh $(MAKE_TRACE)
29 endif
30 ifneq (,$(filter autogen,${AUTOTOOL_STYLE}))
31 @$(CMD_TRACE) "autotool configuring... "
32 @cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) autogen.sh $(MAKE_TRACE)
33 endif
34 ifneq (,$(filter autoconf,${AUTOTOOL_STYLE}))
35 @$(CMD_TRACE) "autotool configuring... "
36 @cd ${WRKSRC}; env ${AUTOTOOL_ENV} autoconf $(MAKE_TRACE)
37 endif
38 ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
39 @$(CMD_TRACE) "autotool configuring... "
40 @cd ${WRKSRC}; env ${AUTOTOOL_ENV} autoreconf -vif $(MAKE_TRACE)
41 @rm -rf ${WRKSRC}/autom4te.cache
42 @touch ${WRKDIR}/.autoreconf_done
43 endif
44 mkdir -p ${WRKBUILD}
45 @${MAKE} pre-configure $(MAKE_TRACE)
46 @cd ${WRKSRC}; \
47 for i in $$(find . -name config.sub);do \
48 if [ -f $$i ]; then \
49 ${CP} ${SCRIPT_DIR}/config.sub $$i; \
50 fi; \
51 done; \
52 for i in $$(find . -name config.guess);do \
53 if [ -f $$i ]; then \
54 ${CP} ${SCRIPT_DIR}/config.guess $$i; \
55 fi; \
56 done;
58 ifneq ($(filter manual,${CONFIG_STYLE}),)
59 env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
60 else ifneq ($(filter cmake,${CONFIG_STYLE}),)
61 @$(CMD_TRACE) "configuring cmake... "
62 sed -e "s#@@TARGET_CC@@#$(TARGET_CC)#" \
63 -e "s#@@TARGET_CXX@@#$(TARGET_CXX)#" \
64 -e "s#@@TARGET_CFLAGS@@#$(TARGET_CFLAGS)#" \
65 -e "s#@@TARGET_CXXFLAGS@@#$(TARGET_CXXFLAGS)#" \
66 -e "s#@@TARGET_ARCH@@#$(ADK_TARGET_ARCH)#" \
67 -e "s#@@STAGING_TARGET_DIR@@#$(STAGING_TARGET_DIR)#" \
68 -e "s#@@STAGING_HOST_DIR@@#$(STAGING_HOST_DIR)#g" \
69 $(SCRIPT_DIR)/toolchain.cmake.in > $(SCRIPT_DIR)/toolchain.cmake
70 (cd ${WRKBUILD} && PATH='${HOST_PATH}' \
71 cmake VERBOSE=1 -Wno-dev -DCMAKE_INSTALL_PREFIX:PATH=/usr \
72 -DCMAKE_TOOLCHAIN_FILE="$(SCRIPT_DIR)/toolchain.cmake" \
73 ${CMAKE_FLAGS} ${WRKSRC}) $(MAKE_TRACE)
74 else ifneq ($(filter minimal,${CONFIG_STYLE}),)
75 @$(CMD_TRACE) "configuring... "
76 cd ${WRKBUILD}; rm -f config.{cache,status}; \
77 env ${CONFIGURE_ENV} \
78 ${BASH} ${WRKSRC}/${CONFIGURE_PROG} \
79 ${CONFIGURE_ARGS} $(MAKE_TRACE)
80 else ifneq ($(filter basic,${CONFIG_STYLE}),)
81 @$(CMD_TRACE) "configuring... "
82 cd ${WRKBUILD}; rm -f config.{cache,status}; \
83 env ${CONFIGURE_ENV} \
84 ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
85 ${CONFIGURE_ARGS} $(MAKE_TRACE)
86 else ifneq ($(filter perl,${CONFIG_STYLE}),)
87 @$(CMD_TRACE) "configuring perl module... "
88 if [ -f ${WRKBUILD}/Makefile.PL ]; then \
89 cd ${WRKBUILD}; \
90 PATH='${HOST_PATH}' \
91 PERL_MM_USE_DEFAULT=1 \
92 PERL_AUTOINSTALL=--skipdeps \
93 $(PERL_ENV) \
94 perl-host Makefile.PL ${CONFIGURE_ARGS}; \
95 else \
96 cd ${WRKBUILD}; \
97 PATH='${HOST_PATH}' \
98 $(PERL_ENV) \
99 perl-host Build.PL; \
101 else ifeq ($(strip ${CONFIG_STYLE}),)
102 @$(CMD_TRACE) "configuring... "
103 cd ${WRKBUILD}; rm -f config.{cache,status}; \
104 env ${CONFIGURE_ENV} \
105 ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
106 --program-prefix= \
107 --program-suffix= \
108 --prefix=/usr \
109 --bindir=/usr/bin \
110 --datadir=/usr/share \
111 --mandir=/usr/share/man \
112 --libexecdir=/usr/libexec \
113 --localstatedir=/var \
114 --sysconfdir=/etc \
115 --disable-dependency-tracking \
116 --disable-libtool-lock \
117 --disable-nls \
118 ${CONFIGURE_LIB} \
119 ${CONFIGURE_ARGS} $(MAKE_TRACE)
120 else
121 @echo "Invalid CONFIG_STYLE '${CONFIG_STYLE}'" >&2
122 @exit 1
123 endif
124 @${MAKE} post-configure $(MAKE_TRACE)
125 @touch $@
127 # do a parallel build if requested && package doesn't force disable it
128 ifeq (${ADK_MAKE_PARALLEL},y)
129 ifeq ($(strip ${PKG_NOPARALLEL}),)
130 MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
131 endif
132 endif
134 pre-build:
135 do-build:
136 post-build:
137 ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
138 @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
139 @$(CMD_TRACE) "compiling... "
140 ifneq ($(filter manual,${BUILD_STYLE}),)
141 env ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} do-build $(MAKE_TRACE)
142 else ifeq ($(strip ${BUILD_STYLE}),)
143 cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
144 ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
145 else
146 @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
147 @exit 1
148 endif
149 @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
150 touch $@
152 pre-install:
153 do-install:
154 post-install:
155 spkg-install: ${ALL_POSTINST}
156 ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
157 @-rm -f ${_ALL_CONTROLS}
158 @mkdir -p '${STAGING_PKG_DIR}/stamps' ${WRKINST} '${STAGING_TARGET_DIR}/scripts'
159 @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
160 @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
161 ifneq ($(filter manual,${INSTALL_STYLE}),)
162 env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
163 else ifeq ($(strip ${INSTALL_STYLE}),)
164 cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
165 DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
166 env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
167 else
168 @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
169 @exit 1
170 endif
171 env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
172 @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}.scripts'
173 @for a in ${WRKINST}/usr/bin/*-config*; do \
174 [[ -e $$a ]] || continue; \
175 sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
176 ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
177 chmod u+x ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
178 [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a) ${STAGING_TARGET_DIR}/scripts; \
179 echo "scripts/$$(basename $$a)" \
180 >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
181 done
182 ifeq (,$(filter noremove,${PKG_OPTS}))
183 @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
184 cd '${STAGING_TARGET_DIR}'; \
185 while read fn; do \
186 rm -f "$$fn"; \
187 done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
189 endif
190 @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
191 ifneq (,$(filter dev,${PKG_OPTS}))
192 @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
193 @test -d ${WRKINST}/usr/include && cd ${WRKINST}/usr/include; \
194 find . -name \*.h | \
195 $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
196 @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
197 @test -d ${WRKINST}/usr/lib/pkgconfig && cd ${WRKINST}/usr/lib/pkgconfig; \
198 find . -name \*.pc | \
199 $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
200 @for a in ${WRKINST}/usr/bin/*-config*; do \
201 [[ -e $$a ]] || continue; \
202 mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
203 cp $$a $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
204 chmod 755 $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin/$$(basename $$a); \
205 done
206 endif
207 ifeq (,$(filter nostaging,${PKG_OPTS}))
208 @-cd ${WRKINST}; \
209 find usr ! -type d 2>/dev/null | \
210 grep -E -v -e '^usr/share' -e '^usr/src' -e '^usr/doc' -e '^usr/local' -e '^usr/man' -e '^usr/info' \
211 -e '^usr/lib/libc.so' -e '^usr/bin/[a-z0-9-]+-config*' -e '^usr/lib/.*\.la$$' \
212 -e '^/usr/lib/libpthread_nonshared.a' | \
213 tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
214 $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu '${STAGING_TARGET_DIR}'
215 endif
216 ifeq (,$(filter noscripts,${PKG_OPTS}))
217 @cd '${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
218 '${STAGING_PKG_DIR}/${PKG_NAME}' | \
219 while read fn; do \
220 b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
221 [[ $$b = '#!' ]] || continue; \
222 cp "$$fn" scripts/; \
223 echo "scripts/$$(basename "$$fn")" \
224 >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
225 done
226 endif
227 -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
228 cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || :
229 touch $@
231 ${_IPKGS_COOKIE}:
232 exec ${MAKE} package
234 package: ${ALL_IPKGS}
235 ifneq ($(DEVELOPER),)
236 @cd ${WRKDIR}/fake-${ADK_TARGET_CPU_ARCH} || exit 1; \
237 y=; sp=; for x in ${ALL_IDIRS}; do \
238 y="$$y$$sp$${x#$(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/}"; \
239 sp=' '; \
240 done; ls=; ln=; x=1; [[ -z $$y ]] || \
241 md5sum $$(find $$y -type f) | sed -e "s/*//" | \
242 while read sum name; do \
243 inode=$$(ls -i "$$name"); \
244 echo "$$sum $${inode%% *} $$name"; \
245 done | sort | while read sum inode name; do \
246 if [[ $$sum = $$ls ]]; then \
247 [[ $$li = $$inode ]] && continue; \
248 case $$x in \
249 1) echo 'WARNING: duplicate files found in' \
250 'package "${PKG_NAME}"! Fix them.' >&2; \
251 echo -n "> $$ln "; \
252 ;; \
253 2) echo -n "> $$ln "; \
254 ;; \
255 3) echo -n ' '; \
256 ;; \
257 esac; \
258 echo -n "$$name"; \
259 x=3; \
260 else \
261 case $$x in \
262 3) echo; \
263 x=2; \
264 ;; \
265 esac; \
266 fi; \
267 ls=$$sum; \
268 ln=$$name; \
269 li=$$inode; \
270 done
271 endif
272 touch ${_IPKGS_COOKIE}
274 clean-targets: clean-dev-generic
276 clean-dev-generic:
277 ifeq (,$(filter noremove,${PKG_OPTS}))
278 @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
279 cd '${STAGING_TARGET_DIR}'; \
280 while read fn; do \
281 rm -f "$$fn"; \
282 done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
284 endif
285 @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
287 ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
288 DIFF_IGNOREFILES?= configure missing depcomp install-sh INSTALL \
289 aclocal.m4 config.h.in Makefile.in */Makefile.in \
290 config.sub config.guess */config.sub */config.guess
291 else
292 DIFF_IGNOREFILES?= config.sub config.guess */config.sub */config.guess
293 endif