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)
25 # override variables from rules.mk
26 PACKAGE_DIR
:=$(TOPDIR
)/packages
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
35 define Profile
/Default
43 $(eval
$(call Profile
/Default
))
44 $(eval
$(call Profile
/$(1)))
50 $(ID
)_PACKAGES
:=$(PACKAGES
)
53 echo
'$(ID):'; [ -z
'$(NAME)' ] || echo
' $(NAME)'; echo
' Packages: $(PACKAGES)';
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
).
68 By default
'make image' will create an image with the default
69 target profile and package set. You can use the following parameters
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>
77 $(eval
$(call shexport
,Helptext
))
80 echo
"$$$(call shvar,Helptext)"
83 echo
'Current Target: "$(BOARDNAME)"'
84 echo
'Available Profiles:'
87 $(TOPDIR
)/tmp
/ipkg.conf
: FORCE
88 @mkdir
-p
$(TOPDIR
)/tmp
89 @echo
'dest root /' > $@
90 @echo
'src packages file:$(TOPDIR)/packages' >> $@
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
))
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'; \
103 echo
'Building images for $(BOARDNAME) - $($(PROFILE)_NAME)'
104 echo
'Packages: $(BUILD_PACKAGES)'
107 mkdir
-p
$(TARGET_DIR
) $(BIN_DIR
) $(TMP_DIR
)
108 $(MAKE
) package_index
109 $(MAKE
) package_install
113 $(MAKE
) package_postinst
116 package_index
: $(TOPDIR
)/tmp
/ipkg.conf FORCE
118 @echo Building package index...
119 (cd
$(PACKAGE_DIR
); $(SCRIPT_DIR
)/ipkg-make-index.sh .
> Packages
) >/dev
/null
2>/dev
/null
122 package_install
: FORCE
124 @echo Installing packages...
125 $(IPKG
) install $(BUILD_PACKAGES
)
129 @echo Copying extra files
130 $(CP
) $(FILES
)/* $(TARGET_DIR
)/
132 package_postinst
: FORCE
134 @echo Activating init scripts
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
; \
145 @echo Building images...
146 $(NO_TRACE_MAKE
) -C target
/linux
/$(BOARD
)-$(KERNEL
)/image
install IB
=1
149 rm -rf tmp
$(TARGET_DIR
) $(BIN_DIR
)
152 .SILENT
: help
info image