1 # Makefile for the OpenWrt Image Builder
3 # Copyright (C) 2006-2007 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 export TOPDIR
=${CURDIR}
16 SHELL
:=/usr
/bin
/env bash
19 ifeq ($(KBUILD_VERBOSE
),99)
20 MAKE
:=3>/dev
/null
$(MAKE
)
22 export IS_TTY
=$(shell tty
-s
&& echo
1 || echo
0)
24 # override variables from rules.mk
25 PACKAGE_DIR
:=$(TOPDIR
)/packages
27 IPKG_TMP
="$(TOPDIR)/tmp/ipkgtmp" \
28 IPKG_INSTROOT
="$(TARGET_DIR)" \
29 IPKG_CONF_DIR
="$(TOPDIR)/tmp" \
30 IPKG_OFFLINE_ROOT
="$(TARGET_DIR)" \
31 $(SCRIPT_DIR
)/ipkg
-force-defaults
34 define Profile
/Default
41 $(eval
$(call Profile
/Default
))
42 $(eval
$(call Profile
/$(1)))
48 $(ID
)_PACKAGES
:=$(PACKAGES
)
50 echo
'$(ID):'; [ -z
'$(NAME)' ] || echo
' $(NAME)'; echo
' Packages: $(PACKAGES)';
59 info: Show a list of available target profiles
60 clean: Remove images and temporary build files
61 image
: Build an image
(see below for more information
).
64 By default
'make image' will create an image with the default
65 target profile and package set. You can use the following parameters
68 make image PROFILE
="<profilename>" # override the default target profile
69 make image PACKAGES
="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
70 make image FILES
="<path>" # include extra files from <path>
73 $(eval
$(call shexport
,Helptext
))
76 echo
"$$$(call shvar,Helptext)"
79 echo
'Current Target: "$(BOARDNAME)"'
80 echo
'Available Profiles:'
83 $(TOPDIR
)/tmp
/ipkg.conf
: FORCE
84 @mkdir
-p
$(TOPDIR
)/tmp
85 @echo
'dest root /' > $@
86 @echo
'src packages file:$(TOPDIR)/packages' >> $@
88 BUILD_PACKAGES
:=$(sort $(DEFAULT_PACKAGES
) $(PACKAGES
) $($(PROFILE
)_PACKAGES
) kernel
)
89 BUILD_PACKAGES
:=$(patsubst base-files
,base-files-
$(BOARD
)-$(KERNEL
),$(BUILD_PACKAGES
))
90 # "-pkgname" in the package list means remove "pkgname" from the package list
91 BUILD_PACKAGES
:=$(filter-out $(filter -%,$(BUILD_PACKAGES
)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES
))),$(BUILD_PACKAGES
))
94 if
[ -z
"$($(PROFILE)_NAME)" ]; then \
95 echo Profile
$(PROFILE
) not found.
; \
96 echo
'Use "make info" to get a list of available target profiles'; \
99 echo
'Building images for $(BOARDNAME) - $($(PROFILE)_NAME)'
100 echo
'Packages: $(BUILD_PACKAGES)'
103 mkdir
-p
$(TARGET_DIR
) $(BIN_DIR
) $(TMP_DIR
)
104 $(MAKE
) package_index
105 $(MAKE
) package_install
109 $(MAKE
) package_postinst
112 package_index
: $(TOPDIR
)/tmp
/ipkg.conf FORCE
114 @echo Building package index...
115 (cd
$(PACKAGE_DIR
); $(SCRIPT_DIR
)/ipkg-make-index.sh .
> Packages
) >/dev
/null
2>/dev
/null
118 package_install
: FORCE
120 @echo Installing packages...
121 $(IPKG
) install $(BUILD_PACKAGES
)
125 @echo Copying extra files
126 $(CP
) $(FILES
)/* $(TARGET_DIR
)/
128 package_postinst
: FORCE
130 @echo Activating init scripts
132 cd
$(BUILD_DIR
)/root
; \
133 for script in .
/etc
/init.d
/*; do \
134 grep
'#!/bin/sh /etc/rc.common' $$script >/dev
/null || continue
; \
135 IPKG_INSTROOT
=$(BUILD_DIR
)/root
$(which bash
) .
/etc
/rc.common
$$script enable
; \
141 @echo Building images...
142 $(NO_TRACE_MAKE
) -C target
/linux
/$(BOARD
)-$(KERNEL
)/image
install IB
=1
145 rm -rf tmp
$(TARGET_DIR
) $(BIN_DIR
)
148 .SILENT
: help
info image