mac80211: update to wireless-testing 2013-06-27, fix ATH_USER_REGD handling
[openwrt/svn-archive/archive.git] / package / Makefile
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 curdir:=package
9
10 -include $(TMP_DIR)/.packagedeps
11 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
12 $(curdir)/builddirs-install:=.
13 ifeq ($(SDK),1)
14 else
15 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
16 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
17 endif
18 ifneq ($(IGNORE_ERRORS),)
19 $(curdir)/builddirs-ignore-compile:= $(if $(filter n m y, $(IGNORE_ERRORS)),$(foreach m,$(IGNORE_ERRORS),$(package-$(subst n,,$(m)))),$(package-m) $(package-))
20 endif
21
22 ifdef CONFIG_USE_MKLIBS
23 define mklibs
24 rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
25 # first find all programs and add them to the mklibs list
26 find $(STAGING_DIR_ROOT) -type f -perm +100 -exec \
27 file -r -N -F '' {} + | \
28 awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
29 # find all loadable objects that are not regular libraries and add them to the list as well
30 find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
31 file -r -N -F '' {} + | \
32 awk ' /shared object/ { print $$1 }' >> $(TMP_DIR)/mklibs-progs
33 mkdir -p $(TMP_DIR)/mklibs-out
34 $(STAGING_DIR_HOST)/bin/mklibs -D \
35 -d $(TMP_DIR)/mklibs-out \
36 --sysroot $(STAGING_DIR_ROOT) \
37 -L /lib \
38 -L /usr/lib \
39 -L /usr/lib/ebtables \
40 --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
41 $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
42 $(STAGING_DIR_ROOT)/lib/$(name) \
43 )))) \
44 --target $(REAL_GNU_TARGET_NAME) \
45 `cat $(TMP_DIR)/mklibs-progs` 2>&1
46 $(RSTRIP) $(TMP_DIR)/mklibs-out
47 for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
48 LIB="$${lib##*/}"; \
49 DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
50 [ -n "$$DEST" ] || continue; \
51 echo "Copying stripped library $$lib to $$DEST"; \
52 cp "$$lib" "$$DEST" || exit 1; \
53 done
54 endef
55 endif
56
57 # where to build (and put) .ipk packages
58 OPKG:= \
59 IPKG_TMP=$(TMP_DIR)/ipkg \
60 IPKG_INSTROOT=$(TARGET_DIR) \
61 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
62 IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
63 $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
64 --offline-root $(TARGET_DIR) \
65 --force-depends \
66 --force-overwrite \
67 --force-postinstall \
68 --force-maintainer \
69 --add-dest root:/ \
70 --add-arch all:100 \
71 --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
72
73 PACKAGE_INSTALL_FILES:= \
74 $(foreach pkg,$(sort $(package-y)), \
75 $(foreach variant, \
76 $(if $(package/$(pkg)/variants), \
77 $(package/$(pkg)/variants), \
78 $(if $(package/$(pkg)/default-variant), \
79 $(package/$(pkg)/default-variant), \
80 default \
81 ) \
82 ), \
83 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
84 ) \
85 )
86
87 $(curdir)/cleanup: $(TMP_DIR)/.build
88 rm -rf $(STAGING_DIR_ROOT)
89
90 $(curdir)/install: $(TMP_DIR)/.build
91 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
92 rm -rf $(TARGET_DIR)
93 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
94 @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
95 @for file in $(PACKAGE_INSTALL_FILES); do \
96 [ -s $$file.flags ] || continue; \
97 for flag in `cat $$file.flags`; do \
98 $(OPKG) flag $$flag < $$file; \
99 done; \
100 done || true
101 @-$(MAKE) package/preconfig
102 @if [ -d $(TOPDIR)/files ]; then \
103 $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
104 fi
105 @mkdir -p $(TARGET_DIR)/etc/rc.d
106 @( \
107 cd $(TARGET_DIR); \
108 for script in ./etc/init.d/*; do \
109 grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
110 IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
111 done || true \
112 )
113 @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
114 @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
115 @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
116 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
117 $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
118 $(call mklibs)
119
120 $(curdir)/index: FORCE
121 @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
122 gzip -9c Packages > Packages.gz \
123 )
124
125 $(curdir)/preconfig:
126
127 $(curdir)/flags-install:= -j1
128
129 $(eval $(call stampfile,$(curdir),package,prereq,.config))
130 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
131 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
132 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
133
134 $(eval $(call subdir,$(curdir)))