e618a90b698795d53a5d1b87cccf6b084cbb7d86
[openwrt.git] / package / Makefile
1
2 # Copyright (C) 2006-2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 curdir:=package
10
11 -include $(TMP_DIR)/.packagedeps
12 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
13 ifeq ($(SDK),1)
14   $(curdir)/builddirs-install:=.
15 else
16   $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
17   $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
18   $(curdir)/builddirs-install:=. $(sort $(package-y))
19 endif
20
21 $(curdir)/install:=$(curdir)/install-cleanup
22
23 $(curdir)/cleanup: $(TMP_DIR)/.build
24         rm -rf $(TARGET_DIR)
25
26 $(curdir)/rootfs-prepare: $(TMP_DIR)/.build
27         @-$(MAKE) package/preconfig
28         @if [ -d $(TOPDIR)/files ]; then \
29                 $(CP) $(TOPDIR)/files/. $(TARGET_DIR); \
30         fi
31         @mkdir -p $(TARGET_DIR)/etc/rc.d
32         @( \
33                 cd $(TARGET_DIR); \
34                 for script in ./etc/init.d/*; do \
35                         grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
36                         IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $$script enable; \
37                 done || true \
38         )
39         @-find $(TARGET_DIR) -name CVS   | $(XARGS) rm -rf
40         @-find $(TARGET_DIR) -name .svn  | $(XARGS) rm -rf
41         @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
42         $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/ipkg)
43
44 $(curdir)/index: FORCE
45         @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages)
46
47 $(curdir)/flags-install:= -j1
48
49 $(eval $(call stampfile,$(curdir),package,prereq,.config))
50 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
51 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
52 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
53 $(eval $(call stampfile,$(curdir),package,rootfs-prepare,$(TMP_DIR)/.build))
54
55 $(eval $(call subdir,$(curdir)))