3 # Copyright (C) 2007-2010 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
12 export TOPDIR LC_ALL LANG
13 export OPENWRT_VERBOSE
=s
16 include $(TOPDIR
)/include/host.mk
18 ifneq ($(OPENWRT_BUILD
),1)
19 override OPENWRT_BUILD
=1
24 include $(INCLUDE_DIR
)/debug.mk
25 include $(INCLUDE_DIR
)/depends.mk
27 include $(INCLUDE_DIR
)/version.mk
33 info: Show a list of available target profiles
34 clean: Remove images and temporary build files
35 image
: Build an image
(see below for more information
).
38 By default
'make image' will create an image with the default
39 target profile and package set. You can use the following parameters
42 make image PROFILE
="<profilename>" # override the default target profile
43 make image PACKAGES
="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
44 make image FILES
="<path>" # include extra files from <path>
45 make image BIN_DIR
="<path>" # alternative output directory for the images
48 $(eval
$(call shexport
,Helptext
))
51 echo
"$$$(call shvar,Helptext)"
54 # override variables from rules.mk
55 PACKAGE_DIR
:=$(TOPDIR
)/packages
58 IPKG_TMP
="$(TOPDIR)/tmp/ipkgtmp" \
59 IPKG_INSTROOT
="$(TARGET_DIR)" \
60 IPKG_CONF_DIR
="$(TOPDIR)/tmp" \
61 IPKG_OFFLINE_ROOT
="$(TARGET_DIR)" \
62 $(STAGING_DIR_HOST
)/bin
/opkg \
63 -f
$(TOPDIR
)/repositories.conf \
67 --cache
$(TOPDIR
)/dl \
68 --offline-root
$(TARGET_DIR
) \
71 --add-arch
$(ARCH_PACKAGES
):200
74 $(eval
$(call Profile
/Default
))
75 $(eval
$(call Profile
/$(1)))
76 ifeq ($(USER_PROFILE
),)
80 $(1)_PACKAGES
:=$(PACKAGES
)
82 echo
'$(1):'; [ -z
'$(NAME)' ] || echo
' $(NAME)'; echo
' Packages: $(PACKAGES)';
85 include $(INCLUDE_DIR
)/target.mk
88 echo
'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
89 echo
'Default Packages: $(DEFAULT_PACKAGES)'
90 echo
'Available Profiles:'
93 BUILD_PACKAGES
:=$(sort $(DEFAULT_PACKAGES
) $(USER_PACKAGES
) $($(USER_PROFILE
)_PACKAGES
) kernel
)
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
))
99 echo
'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
100 echo
'Packages: $(BUILD_PACKAGES)'
103 mkdir
-p
$(TARGET_DIR
) $(BIN_DIR
) $(TMP_DIR
)
104 if
[ ! -f
"$(PACKAGE_DIR)/Packages" ] ||
[ ! -f
"$(PACKAGE_DIR)/Packages.gz" ] ||
[ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
105 echo
"Package list missing or not up-to-date, generating it.";\
106 $(MAKE
) package_index
; \
108 mkdir
-p
$(TARGET_DIR
)/tmp
; \
111 $(MAKE
) package_install
112 ifneq ($(USER_FILES
),)
115 $(MAKE
) package_postinst
120 @echo Building package index...
121 @mkdir
-p
$(TOPDIR
)/tmp
$(TOPDIR
)/dl
$(TARGET_DIR
)/tmp
122 (cd
$(PACKAGE_DIR
); $(SCRIPT_DIR
)/ipkg-make-index.sh .
> Packages
&& \
123 gzip
-9c Packages
> Packages.gz \
124 ) >/dev
/null
2>/dev
/null
127 package_install
: FORCE
129 @echo Installing packages...
130 $(OPKG
) install $(firstword $(wildcard $(PACKAGE_DIR
)/libc_
*.ipk
$(PACKAGE_DIR
)/base
/libc_
*.ipk
))
131 $(OPKG
) install $(firstword $(wildcard $(PACKAGE_DIR
)/kernel_
*.ipk
$(PACKAGE_DIR
)/base
/kernel_
*.ipk
))
132 $(OPKG
) install $(BUILD_PACKAGES
)
133 rm -f
$(TARGET_DIR
)/usr
/lib
/opkg
/lists
/*
137 @echo Copying extra files
138 @
$(call file_copy
,$(USER_FILES
)/*,$(TARGET_DIR
)/)
140 package_postinst
: FORCE
143 @
rm -f
$(TARGET_DIR
)/tmp
/opkg.lock
145 @echo Activating init scripts
146 @mkdir
-p
$(TARGET_DIR
)/etc
/rc.d
149 for script in .
/usr
/lib
/opkg
/info/*.postinst
; do \
150 IPKG_INSTROOT
=$(TARGET_DIR
) $$(which bash
) $$script; \
153 rm -f
$(TARGET_DIR
)/usr
/lib
/opkg
/info/*.postinst
154 $(if
$(CONFIG_CLEAN_IPKG
),rm -rf
$(TARGET_DIR
)/usr
/lib
/opkg
)
158 @echo Building images...
159 $(NO_TRACE_MAKE
) -C target
/linux
/$(BOARD
)/image
install TARGET_BUILD
=1 IB
=1 \
160 $(if
$(USER_PROFILE
),PROFILE
="$(USER_PROFILE)")
163 rm -rf
$(TOPDIR
)/tmp
$(TOPDIR
)/dl
$(TARGET_DIR
) $(BIN_DIR
)
167 (unset PROFILE FILES PACKAGES MAKEFLAGS
; $(MAKE
) -s _call_info
)
170 (unset PROFILE FILES PACKAGES MAKEFLAGS
; \
171 $(MAKE
) _call_image \
172 $(if
$(PROFILE
),USER_PROFILE
="$(PROFILE)") \
173 $(if
$(FILES
),USER_FILES
="$(FILES)") \
174 $(if
$(PACKAGES
),USER_PACKAGES
="$(PACKAGES)") \
175 $(if
$(BIN_DIR
),BIN_DIR
="$(BIN_DIR)"))
177 .SILENT
: help
info image