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