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