ar71xx: sync 2.6.31 kernel config
[openwrt.git] / target / imagebuilder / files / Makefile
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2007-2009 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 TOPDIR:=${CURDIR}
10 LC_ALL:=C
11 LANG:=C
12 export TOPDIR LC_ALL LANG
13 export KBUILD_VERBOSE=99
14 all: help
15
16 include $(TOPDIR)/include/host.mk
17
18 ifneq ($(OPENWRT_BUILD),1)
19 override OPENWRT_BUILD=1
20 export OPENWRT_BUILD
21 endif
22
23 include rules.mk
24 include $(INCLUDE_DIR)/debug.mk
25 include $(INCLUDE_DIR)/depends.mk
26
27 define Helptext
28 Available Commands:
29 help: This help text
30 info: Show a list of available target profiles
31 clean: Remove images and temporary build files
32 image: Build an image (see below for more information).
33
34 Building images:
35 By default 'make image' will create an image with the default
36 target profile and package set. You can use the following parameters
37 to change that:
38
39 make image PROFILE="<profilename>" # override the default target profile
40 make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
41 make image FILES="<path>" # include extra files from <path>
42
43 endef
44 $(eval $(call shexport,Helptext))
45
46 help: FORCE
47 echo "$$$(call shvar,Helptext)"
48
49
50 # override variables from rules.mk
51 PACKAGE_DIR:=$(TOPDIR)/packages
52 IPKG:= \
53 IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
54 IPKG_INSTROOT="$(TARGET_DIR)" \
55 IPKG_CONF_DIR="$(TOPDIR)/tmp" \
56 IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
57 $(SCRIPT_DIR)/ipkg -force-defaults
58
59 define Profile
60 $(eval $(call Profile/Default))
61 $(eval $(call Profile/$(1)))
62 ifeq ($(PROFILE),)
63 PROFILE:=$(1)
64 endif
65 $(1)_NAME:=$(NAME)
66 $(1)_PACKAGES:=$(PACKAGES)
67 PROFILE_LIST += \
68 echo '$(1):'; [ -z '$(NAME)' ] || echo ' $(NAME)'; echo ' Packages: $(PACKAGES)';
69 endef
70
71 include $(INCLUDE_DIR)/target.mk
72
73 info: FORCE
74 echo 'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
75 echo 'Default Packages: $(DEFAULT_PACKAGES)'
76 echo 'Available Profiles:'
77 echo; $(PROFILE_LIST)
78
79 $(TOPDIR)/tmp/ipkg.conf: FORCE
80 @mkdir -p $(TOPDIR)/tmp
81 @echo 'dest root /' > $@
82 @echo 'src packages file:$(PACKAGE_DIR)' >> $@
83
84 BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $($(PROFILE)_PACKAGES) kernel)
85 # "-pkgname" in the package list means remove "pkgname" from the package list
86 BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
87
88 image:
89 echo 'Building images for $(BOARD)$(if $($(PROFILE)_NAME), - $($(PROFILE)_NAME))'
90 echo 'Packages: $(BUILD_PACKAGES)'
91 echo
92 rm -rf $(TARGET_DIR)
93 mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
94 $(MAKE) package_index
95 $(MAKE) package_install
96 ifneq ($(FILES),)
97 $(MAKE) copy_files
98 endif
99 $(MAKE) package_postinst
100 $(MAKE) build_image
101
102 package_index: $(TOPDIR)/tmp/ipkg.conf FORCE
103 @echo
104 @echo Building package index...
105 (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
106 gzip -9c Packages > Packages.gz \
107 ) >/dev/null 2>/dev/null
108 $(IPKG) update
109
110 package_install: FORCE
111 @echo
112 @echo Installing packages...
113 $(IPKG) install $(BUILD_PACKAGES)
114
115 copy_files: FORCE
116 @echo
117 @echo Copying extra files
118 $(CP) $(FILES)/* $(TARGET_DIR)/
119
120 package_postinst: FORCE
121 @echo
122 @echo Activating init scripts
123 @( \
124 cd $(TARGET_DIR); \
125 for script in ./etc/init.d/*; do \
126 grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
127 IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $$script enable; \
128 done || true; \
129 )
130
131 build_image: FORCE
132 @echo
133 @echo Building images...
134 $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1
135
136 clean:
137 rm -rf tmp $(TARGET_DIR) $(BIN_DIR)
138
139
140 .SILENT: help info image
141
This page took 0.042196 seconds and 5 git commands to generate.