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