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 KBUILD_VERBOSE
=99
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
57 IPKG_TMP
="$(TOPDIR)/tmp/ipkgtmp" \
58 IPKG_INSTROOT
="$(TARGET_DIR)" \
59 IPKG_CONF_DIR
="$(TOPDIR)/tmp" \
60 IPKG_OFFLINE_ROOT
="$(TARGET_DIR)" \
61 $(STAGING_DIR_HOST
)/bin
/opkg \
62 -f
$(TOPDIR
)/repositories.conf \
66 --cache
$(TOPDIR
)/dl \
67 --offline-root
$(TARGET_DIR
) \
70 --add-arch
$(ARCH_PACKAGES
):200
73 $(eval
$(call Profile
/Default
))
74 $(eval
$(call Profile
/$(1)))
75 ifeq ($(USER_PROFILE
),)
79 $(1)_PACKAGES
:=$(PACKAGES
)
81 echo
'$(1):'; [ -z
'$(NAME)' ] || echo
' $(NAME)'; echo
' Packages: $(PACKAGES)';
84 include $(INCLUDE_DIR
)/target.mk
87 echo
'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
88 echo
'Default Packages: $(DEFAULT_PACKAGES)'
89 echo
'Available Profiles:'
92 BUILD_PACKAGES
:=$(sort $(DEFAULT_PACKAGES
) $(USER_PACKAGES
) $($(USER_PROFILE
)_PACKAGES
) kernel
)
93 # "-pkgname" in the package list means remove "pkgname" from the package list
94 BUILD_PACKAGES
:=$(filter-out $(filter -%,$(BUILD_PACKAGES
)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES
))),$(BUILD_PACKAGES
))
98 echo
'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
99 echo
'Packages: $(BUILD_PACKAGES)'
102 mkdir
-p
$(TARGET_DIR
) $(BIN_DIR
) $(TMP_DIR
)
103 $(MAKE
) package_index
104 $(MAKE
) package_install
105 ifneq ($(USER_FILES
),)
108 $(MAKE
) package_postinst
113 @echo Building package index...
114 @mkdir
-p
$(TOPDIR
)/tmp
$(TOPDIR
)/dl
$(TARGET_DIR
)/tmp
115 (cd
$(PACKAGE_DIR
); $(SCRIPT_DIR
)/ipkg-make-index.sh .
2>&1 > Packages
&& \
116 gzip
-9c Packages
> Packages.gz \
117 ) >/dev
/null
2>/dev
/null
120 package_install
: FORCE
122 @echo Installing packages...
123 $(OPKG
) install $(BUILD_PACKAGES
)
127 @echo Copying extra files
128 $(CP
) $(USER_FILES
)/* $(TARGET_DIR
)/
130 package_postinst
: FORCE
133 @
rm -f
$(TARGET_DIR
)/tmp
/opkg.lock
135 @echo Activating init scripts
138 for script in .
/etc
/init.d
/*; do \
139 grep
'#!/bin/sh /etc/rc.common' $$script >/dev
/null || continue
; \
140 IPKG_INSTROOT
=$(TARGET_DIR
) $(which bash
) .
/etc
/rc.common
$$script enable
; \
146 @echo Building images...
147 $(NO_TRACE_MAKE
) -C target
/linux
/$(BOARD
)/image
install TARGET_BUILD
=1 IB
=1
150 rm -rf
$(TOPDIR
)/tmp
$(TOPDIR
)/dl
$(TARGET_DIR
) $(BIN_DIR
)
154 (unset PROFILE FILES PACKAGES MAKEFLAGS
; $(MAKE
) -s _call_info
)
157 (unset PROFILE FILES PACKAGES MAKEFLAGS
; \
158 $(MAKE
) _call_image \
159 $(if
$(PROFILE
),USER_PROFILE
="$(PROFILE)") \
160 $(if
$(FILES
),USER_FILES
="$(FILES)") \
161 $(if
$(PACKAGES
),USER_PACKAGES
="$(PACKAGES)") \
162 $(if
$(BIN_DIR
),BIN_DIR
="$(BIN_DIR)"))
164 .SILENT
: help
info image