next round of build system cleanup - convert package/ to new structure
[openwrt-10.03/.git] / package / Makefile
index adeb238d437ecbc4165146393e831e128b865bfa..31f03c01bbc878e3973f76c148325fa15fc4021f 100644 (file)
@@ -1,31 +1,43 @@
-# Main makefile for the packages
-include $(TOPDIR)/rules.mk
-include $(TOPDIR)/.config
-include $(TOPDIR)/.pkgdeps
-
-COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
-INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))
-
-$(STAMP_DIR) $(TARGET_DIR):
-       mkdir -p $@
-
-%-prepare: $(STAMP_DIR) $(TARGET_DIR)
-       $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
-
-%-compile: $(STAMP_DIR) $(TARGET_DIR)
-       @echo "-> make $@"
-       $(MAKE) -C $(patsubst %-compile,%,$@) compile
-
-%-clean: $(STAMP_DIR) $(TARGET_DIR)
-       $(MAKE) -C $(patsubst %-clean,%,$@) clean
-
-
-$(TOPDIR)/.pkgdeps: $(TOPDIR)/.pkginfo
-       @$(TOPDIR)/scripts/gen_deps.pl < $< > $@ || rm -f $@
-
-all: compile
-clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
-compile: $(COMPILE_PACKAGES)
-install: base-files-install $(INSTALL_PACKAGES)
-
-
+# 
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id$
+
+curdir:=package
+
+include .config
+-include $(TMP_DIR)/.packagedeps
+$(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
+$(curdir)/builddirs-compile:=$(sort $(package-y) $(package-m))
+$(curdir)/builddirs-install:=. $(sort $(package-y))
+$(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
+
+$(curdir)//compile:=.config prereq
+$(curdir)/install:=$(curdir)/install-cleanup
+$(curdir)/install-cleanup:
+       rm -rf $(BUILD_DIR)/root
+       $(MAKE) install-targets
+       $(MAKE) preconfig
+       @if [ -d $(TOPDIR)/files ]; then \
+               $(CP) $(TOPDIR)/files/. $(BUILD_DIR)/root; \
+       fi
+       @mkdir -p $(BUILD_DIR)/root/etc/rc.d
+       @( \
+               cd $(BUILD_DIR)/root; \
+               for script in ./etc/init.d/*; do \
+                       grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+                       IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \
+               done || true \
+       )
+       @-find $(BUILD_DIR)/root -name CVS   | $(XARGS) rm -rf
+       @-find $(BUILD_DIR)/root -name .svn  | $(XARGS) rm -rf
+       @-find $(BUILD_DIR)/root -name '.#*' | $(XARGS) rm -f
+
+$(curdir)/index: FORCE
+       (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages)
+
+$(eval $(call stampfile,$(curdir),package,prereq))
+$(eval $(call subdir,$(curdir)))