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