Tidy up Makefiles
[openwrt/svn-archive/archive.git] / package / Makefile
1 #
2 # Copyright (C) 2006 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 include $(TOPDIR)/rules.mk
10 include $(TOPDIR)/.config
11 include $(INCLUDE_DIR)/host.mk
12
13 all: compile
14
15 include $(TMP_DIR)/.packagedeps
16
17 PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m))
18 DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m))
19 COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
20 INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))
21
22 $(STAMP_DIR) $(TARGET_DIR):
23 mkdir -p $@
24
25 %-prereq %-download %-clean %-compile %-install: FORCE
26 $(MAKE) -C $* $(patsubst $*-%,%,$@)
27
28 %-prereq: $(STAMP_DIR) $(TARGET_DIR)
29 %-prepare: $(TARGET_DIR)
30 %-compile: %-prepare
31
32 $(TMP_DIR)/.packagedeps: $(TMP_DIR)/.packageinfo
33 @$(TOPDIR)/scripts/metadata.pl package_mk < $< > $@ || rm -f $@
34
35 preconfig:
36 clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
37 prereq: $(PREREQ_PACKAGES)
38 download: $(DOWNLOAD_PACKAGES)
39 compile: $(COMPILE_PACKAGES)
40
41 install-targets: $(INSTALL_PACKAGES)
42 install:
43 rm -rf $(BUILD_DIR)/root
44 $(MAKE) install-targets
45 $(MAKE) preconfig
46 @if [ -d $(TOPDIR)/files ]; then \
47 $(CP) $(TOPDIR)/files/. $(BUILD_DIR)/root; \
48 fi
49 @( \
50 cd $(BUILD_DIR)/root; \
51 for script in ./etc/init.d/*; do \
52 grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
53 IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \
54 done || true \
55 )
56
57 index: $(PACKAGE_DIR)/Packages
58
59 $(PACKAGE_DIR)/Packages: $(PACKAGE_DIR)/*.ipk
60 (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages)
61
62 symlinks:
63 ../scripts/feeds.sh $(CONFIG_SOURCE_FEEDS)
64
65 ifeq ($(MAKECMDGOALS),compile)
66 MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL)
67 else
68 .NOTPARALLEL:
69 endif