libpcap: update to 1.10.5
[openadk.git] / mk / package.mk
blob2a3e1f414f5cf3df1ea162b625e2ab64bc762b5c
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 all: build-all-pkgs
6 # does not change CONFIGURE_ARGS in minimal mode
7 ifeq ($(filter minimal,${CONFIG_STYLE}),)
8 ifneq ($(ADK_DEBUG),)
9 CONFIGURE_ARGS+= --enable-debug
10 endif
11 endif
13 AUTOTOOL_ENV+= PATH='${HOST_PATH}' \
14 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
15 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
16 ${COMMON_ENV}
18 MESON_ENV+= PATH='${HOST_PATH}' \
19 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
20 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}'
22 CONFIGURE_ENV+= PATH='${TARGET_PATH}' \
23 ${COMMON_ENV} \
24 ${TARGET_ENV} \
25 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
26 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
27 cross_compiling=yes
29 CONFIGURE_PROG?= configure
30 MAKE_FILE?= Makefile
31 # this is environment for 'make all' and 'make install'
32 MAKE_ENV?=
33 # this is arguments for 'make all' and 'make install'
34 XAKE_FLAGS?=
35 # this is arguments for 'make all' ONLY
36 MAKE_FLAGS?=
37 # this is arguments for 'make install' ONLY
38 FAKE_FLAGS?=
39 ALL_TARGET?= all
40 INSTALL_TARGET?= install
42 MAKE_ENV+= PATH='${TARGET_PATH}' \
43 ${COMMON_ENV} \
44 ${TARGET_ENV} \
45 PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
46 PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
47 WRKDIR='${WRKDIR}' WRKDIST='${WRKDIST}' \
48 WRKSRC='${WRKSRC}' WRKBUILD='${WRKBUILD}'
50 MAKE_FLAGS+= ${XAKE_FLAGS}
51 FAKE_FLAGS+= ${XAKE_FLAGS}
53 ifeq ($(strip ${WRKDIR_BSD}),)
54 WRKDIR_BASE:= ${BUILD_DIR}
55 else
56 WRKDIR_BASE:= $(shell pwd)
57 endif
59 _EXTRACT_COOKIE= ${WRKDIST}/.extract_done
60 _PATCH_COOKIE= ${WRKDIST}/.prepared
61 _CONFIGURE_COOKIE= ${WRKBUILD}/.configure_done
62 _BUILD_COOKIE= ${WRKBUILD}/.build_done
63 _FAKE_COOKIE= ${WRKINST}/.fake_done
64 _IPKGS_COOKIE= ${STAGING_PKG_DIR}/stamps/${PKG_NAME}\x01${PKG_VERSION}-${PKG_RELEASE}
66 _IN_PACKAGE:= 1
67 include ${ADK_TOPDIR}/mk/buildhlp.mk
69 # defined in buildhlp.mk ('extract' can fail, use 'patch' then)
70 extract: ${_EXTRACT_COOKIE}
71 patch: ${_PATCH_COOKIE}
73 # defined below (will be moved to pkg-bottom.mk!)
74 configure: ${_CONFIGURE_COOKIE}
75 build: ${_BUILD_COOKIE}
76 fake: ${_FAKE_COOKIE}
78 # our recursive build entry point
79 build-all-pkgs: ${_IPKGS_COOKIE}
81 # there are some parameters to the PKG_template function
82 # 1.) Config.in identifier ADK_PACKAGE_$(1)
83 # 2.) name of the package, for single package mostly $(PKG_NAME)
84 # 3.) package version (upstream version) and package release (adk version),
85 # always $(PKG_VERSION)-$(PKG_RELEASE)
86 # 4.) dependencies to other packages, $(PKG_DEPENDS)
87 # 5.) description for the package, $(PKG_DESCR)
88 # 6.) section of the package, $(PKG_SECTION)
89 # 7.) special package options $(PKG_OPTS)
90 # noscripts -> do not install scripts to $(STAGING_TARGET_DIR)/scripts
91 # (needed for example for autoconf/automake)
92 # noremove -> do not remove files from $(STAGING_TARGET_DIR) while
93 # cleaning (needed for toolchain packages like glibc)
94 # nostaging -> do not install files to $(STAGING_TARGET_DIR)
95 # nostrip -> do not strip files
96 # dev -> create a development subpackage with headers and pkg-config files
97 # devonly -> create a development package only
98 # should be package format independent and modular in the future
99 define PKG_template
100 ALL_PKGOPTS+= $(1)
101 PKGNAME_$(1)= $(2)
102 PKGDEPS_$(1)= $(4)
103 PKGDESC_$(1)= $(5)
104 PKGSECT_$(1)= $(6)
105 IPKG_$(1)= $(PACKAGE_DIR)/$(2)_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
106 IPKG_$(1)_DEV= $(PACKAGE_DIR)/$(2)-dev_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
107 IPKG_$(1)_DBG= $(PACKAGE_DIR)/$(2)-dbg_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
108 IDIR_$(1)= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)
109 IDIR_$(1)_DEV= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)-dev
110 IDIR_$(1)_DBG= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)-dbg
111 ifneq (${ADK_PACKAGE_$(1)}${DEVELOPER},)
112 ifneq (,$(filter dev,$(7)))
113 ifneq ($(ADK_TARGET_USE_STATIC_LIBS_ONLY),y)
114 ifneq ($(ADK_TARGET_BINFMT_FLAT),y)
115 ALL_IPKGS+= $$(IPKG_$(1))
116 ALL_IDIRS+= $${IDIR_$(1)}
117 ALL_POSTINST+= $(2)-install
118 $(2)-install:
119 endif
120 endif
121 else
122 ALL_IPKGS+= $$(IPKG_$(1))
123 ALL_IDIRS+= $${IDIR_$(1)}
124 ALL_POSTINST+= $(2)-install
125 $(2)-install:
126 endif
127 endif
128 INFO_$(1)= $(PKG_STATE_DIR)/info/$(2).list
129 INFO_$(1)_DEV= $(PKG_STATE_DIR)/info/$(2)-dev.list
130 INFO_$(1)_DBG= $(PKG_STATE_DIR)/info/$(2)-dbg.list
132 ifeq ($(ADK_PACKAGE_$(1)),y)
134 ifeq (,$(filter devonly,$(7)))
135 ifeq ($(ADK_PACKAGE_$(1)_DBG),y)
136 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG)
137 ifeq ($(ADK_PACKAGE_$(1)_DEV),y)
138 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG) $$(INFO_$(1)_DEV)
139 else
140 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG)
141 endif
142 else
143 ifeq ($(ADK_PACKAGE_$(1)_DEV),y)
144 install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DEV)
145 else
146 install-targets: $$(INFO_$(1))
147 endif
148 endif
149 else
150 install-targets: $$(INFO_$(1))
151 endif
153 endif
155 IDEPEND_$(1):= $$(strip $(4))
157 _ALL_CONTROLS+= $$(IDIR_$(1))/CONTROL/control
158 ICONTROL_$(1)?= $(WRKDIR)/.$(2).control
159 ICONTROL_$(1)_DEV?= $(WRKDIR)/.$(2)-dev.control
160 ICONTROL_$(1)_DBG?= $(WRKDIR)/.$(2)-dbg.control
161 $$(IDIR_$(1))/CONTROL/control: ${_PATCH_COOKIE}
162 @echo "Package: $$(shell echo $(2) | tr '_' '-')" > $(WRKDIR)/.$(2).control
163 @echo "Section: $(6)" >> $(WRKDIR)/.$(2).control
164 @echo "Description: $(5)" >> $(WRKDIR)/.$(2).control
165 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)} $${ICONTROL_$(1)} $(3) ${ADK_TARGET_CPU_ARCH}
166 @adeps='$$(strip $${IDEPEND_$(1)})'; if [[ -n $$$$adeps ]]; then \
167 comma=; \
168 deps=; \
169 last=; \
170 for dep in $$$$adeps; do \
171 if [[ $$$$last = kernel && $$$$dep = \(* ]]; then \
172 deps="$$$$deps $$$$dep"; \
173 else \
174 deps="$$$$deps$$$$comma$$$$dep"; \
175 fi; \
176 comma=", "; \
177 last=$$$$dep; \
178 done; \
179 echo "Depends: $$$$deps" | tr '_' '-' >>$${IDIR_$(1)}/CONTROL/control; \
181 @for file in conffiles preinst postinst prerm postrm; do \
182 [ ! -f ./files/$(2).$$$$file ] || cp ./files/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file; \
183 done
184 ifeq ($(ADK_BUILD_WITH_DEBUG),y)
185 @echo "Package: $$(shell echo $(2) | tr '_' '-')-dbg" > $(WRKDIR)/.$(2)-dbg.control
186 @echo "Section: debug" >> $(WRKDIR)/.$(2)-dbg.control
187 @echo "Description: debugging symbols for $(2)" >> $(WRKDIR)/.$(2)-dbg.control
188 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)_DBG} $${ICONTROL_$(1)_DBG} $(3) ${ADK_TARGET_CPU_ARCH}
189 @echo "Depends: $$(shell echo $(2) | tr '_' '-')" >> $${IDIR_$(1)_DBG}/CONTROL/control
190 endif
191 ifneq (,$(filter dev,$(7)))
192 @echo "Package: $$(shell echo $(2) | tr '_' '-')-dev" > $(WRKDIR)/.$(2)-dev.control
193 @echo "Section: devel" >> $(WRKDIR)/.$(2)-dev.control
194 @echo "Description: development files for $(2)" >> $(WRKDIR)/.$(2)-dev.control
195 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)_DEV} $${ICONTROL_$(1)_DEV} $(3) ${ADK_TARGET_CPU_ARCH}
196 @echo "Depends: $$(shell echo $(2) | tr '_' '-')" >> $${IDIR_$(1)_DEV}/CONTROL/control
197 endif
199 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $${_FAKE_COOKIE}
200 ifeq (,$(filter nostrip,$(7)))
201 ifeq ($(ADK_DEBUG),)
202 @$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
203 endif
204 ifeq ($(ADK_DEBUG_STRIP),y)
205 @$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
206 endif
207 endif
208 ifeq (${ADK_LEAVE_ETC_ALONE}$(filter force_etc,$(7)),y)
209 -rm -rf $${IDIR_$(1)}/etc
210 else
211 ifeq (${ADK_INSTALL_PACKAGE_INIT_SCRIPTS},y)
212 @for file in $$$$(ls ./files/*.init 2>/dev/null); do \
213 fname=$$$$(echo $$$$file| sed -e "s#.*/##" -e "s#.init##"); \
214 check=$$$$(grep PKG $$$$file|cut -d ' ' -f 2); \
215 if [ "$$$$check" == $(2) ];then \
216 mkdir -p $$(IDIR_$(1))/etc/init.d && cp $$$$file $$(IDIR_$(1))/etc/init.d/$$$$fname; \
217 fi; \
218 done
219 @cd $${IDIR_$(1)}; for script in etc/init.d/*; do \
220 [[ -e $$$$script ]] || continue; \
221 chmod 0755 "$$$$script"; \
222 done
223 endif
224 ifneq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
225 -@rm -rf $${IDIR_$(1)}/etc/network
226 endif
227 endif
228 @mkdir -p $${PACKAGE_DIR} '$${STAGING_PKG_DIR}/stamps' \
229 '$${STAGING_TARGET_DIR}/scripts'
230 @for file in $$$$(ls ./files/*.perm 2>/dev/null); do \
231 cat $$$$file >> $${STAGING_TARGET_DIR}/scripts/permissions.sh; \
232 done
233 ifeq (,$(filter noremove,$(7)))
234 @if test -s '$${STAGING_PKG_DIR}/$(1)'; then \
235 cd '$${STAGING_TARGET_DIR}'; \
236 while read fn; do \
237 rm -f "$$$$fn"; \
238 done <'$${STAGING_PKG_DIR}/$(1)'; \
240 endif
241 @rm -f '$${STAGING_PKG_DIR}/$(1)'
242 ifeq (,$(filter nostaging,$(7)))
243 @-cd $${IDIR_$(1)}; \
244 x=$$$$(find tmp run -mindepth 1 2>/dev/null); if [[ -n $$$$x ]]; then \
245 echo 'WARNING: $${IPKG_$(1)} installs files into a' \
246 'ramdisk location:' >&2; \
247 echo "$$$$x" | sed 's/^/- /' >&2; \
248 fi; \
249 find usr ! -type d 2>/dev/null | \
250 grep -E -v -e '^usr/lib/pkgconfig' -e '^usr/share' -e '^usr/doc' -e '^usr/src' -e '^usr/man' \
251 -e '^usr/info' -e '^usr/lib/libc.so' -e '^usr/bin/[a-z0-9-]+-config' -e '^usr/lib/.*\.la$$$$' | \
252 tee '$${STAGING_PKG_DIR}/$(1)' | \
253 $(CPIO) -padlmu --quiet '$${STAGING_TARGET_DIR}'
254 endif
255 ifeq (,$(filter noscripts,$(7)))
256 @cd '$${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
257 '$${STAGING_PKG_DIR}/$(1)' | \
258 while read fn; do \
259 b="$$$$(dd if="$$$$fn" bs=2 count=1 2>/dev/null)"; \
260 [[ $$$$b = '#!' ]] || continue; \
261 cp "$$$$fn" scripts/; \
262 echo "scripts/$$$$(basename "$$$$fn")" \
263 >>'$${STAGING_PKG_DIR}/$(1)'; \
264 done
265 endif
267 ifeq (,$(filter devonly,$(7)))
268 PATH='$(HOST_PATH)' $${PKG_BUILD} $${IDIR_$(1)} $${PACKAGE_DIR} $(MAKE_TRACE)
269 ifneq ($(ADK_BUILD_WITH_DEBUG),)
270 PATH='$(HOST_PATH)' $${PKG_BUILD} $${IDIR_$(1)_DBG} $${PACKAGE_DIR} $(MAKE_TRACE)
271 endif
272 endif
273 ifneq (,$(filter dev,$(7)))
274 PATH='$(HOST_PATH)' $${PKG_BUILD} $${IDIR_$(1)_DEV} $${PACKAGE_DIR} $(MAKE_TRACE)
275 endif
277 clean-targets: clean-dev-$(1)
279 clean-dev-$(1):
280 ifeq (,$(filter noremove,$(7)))
281 @if test -s '$${STAGING_PKG_DIR}/$(1)'; then \
282 cd '$${STAGING_TARGET_DIR}'; \
283 while read fn; do \
284 rm -f "$$$$fn"; \
285 done <'$${STAGING_PKG_DIR}/$(1)'; \
287 endif
288 @rm -f '$${STAGING_PKG_DIR}/$(1)'
290 $$(INFO_$(1)): $$(IPKG_$(1))
291 $(PKG_INSTALL) $$(IPKG_$(1))
293 $$(INFO_$(1)_DBG): $$(IPKG_$(1)_DBG)
294 $(PKG_INSTALL) $$(IPKG_$(1)_DBG)
296 ifneq ($(1),UCLIBC_NG)
297 ifneq ($(1),GLIBC)
298 ifneq ($(1),MUSL)
299 $$(INFO_$(1)_DEV): $$(IPKG_$(1)_DEV)
300 $(PKG_INSTALL) $$(IPKG_$(1)_DEV)
301 endif
302 endif
303 endif
305 endef
307 install-targets:
308 install:
309 @$(CMD_TRACE) "installing.. "
310 @$(MAKE) install-targets $(MAKE_TRACE)
312 clean-targets:
313 clean:
314 @printf " ---> cleaning package build directories and files.. "
315 @$(MAKE) clean-targets $(MAKE_TRACE)
316 rm -rf ${WRKDIR} ${ALL_IPKGS} ${_IPKGS_COOKIE}
317 @printf " done\n"
319 distclean: clean
320 rm -f ${FULLDISTFILES}
322 .PHONY: all refetch extract patch configure \
323 build fake package install clean build-all-pkgs