3 # Copyright (C) 2007-2009 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
30 info: Show a list of available target profiles
31 clean: Remove images and temporary build files
32 image
: Build an image
(see below for more information
).
35 By default
'make image' will create an image with the default
36 target profile and package set. You can use the following parameters
39 make image PROFILE
="<profilename>" # override the default target profile
40 make image PACKAGES
="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
41 make image FILES
="<path>" # include extra files from <path>
44 $(eval
$(call shexport
,Helptext
))
47 echo
"$$$(call shvar,Helptext)"
50 # override variables from rules.mk
51 PACKAGE_DIR
:=$(TOPDIR
)/packages
53 IPKG_TMP
="$(TOPDIR)/tmp/ipkgtmp" \
54 IPKG_INSTROOT
="$(TARGET_DIR)" \
55 IPKG_CONF_DIR
="$(TOPDIR)/tmp" \
56 IPKG_OFFLINE_ROOT
="$(TARGET_DIR)" \
57 $(SCRIPT_DIR
)/ipkg
-force-defaults
60 $(eval
$(call Profile
/Default
))
61 $(eval
$(call Profile
/$(1)))
66 $(1)_PACKAGES
:=$(PACKAGES
)
68 echo
'$(1):'; [ -z
'$(NAME)' ] || echo
' $(NAME)'; echo
' Packages: $(PACKAGES)';
71 include $(INCLUDE_DIR
)/target.mk
74 echo
'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
75 echo
'Default Packages: $(DEFAULT_PACKAGES)'
76 echo
'Available Profiles:'
79 $(TOPDIR
)/tmp
/ipkg.conf
: FORCE
80 @mkdir
-p
$(TOPDIR
)/tmp
81 @echo
'dest root /' > $@
82 @echo
'src packages file:$(PACKAGE_DIR)' >> $@
84 BUILD_PACKAGES
:=$(sort $(DEFAULT_PACKAGES
) $($(PROFILE
)_PACKAGES
) kernel
)
85 # "-pkgname" in the package list means remove "pkgname" from the package list
86 BUILD_PACKAGES
:=$(filter-out $(filter -%,$(BUILD_PACKAGES
)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES
))),$(BUILD_PACKAGES
))
89 if
[ -z
"$($(PROFILE)_NAME)" ]; then \
90 echo Profile
$(PROFILE
) not found.
; \
91 echo
'Use "make info" to get a list of available target profiles'; \
94 echo
'Building images for $(BOARD) - $($(PROFILE)_NAME)'
95 echo
'Packages: $(BUILD_PACKAGES)'
98 mkdir
-p
$(TARGET_DIR
) $(BIN_DIR
) $(TMP_DIR
)
100 $(MAKE
) package_install
104 $(MAKE
) package_postinst
107 package_index
: $(TOPDIR
)/tmp
/ipkg.conf FORCE
109 @echo Building package index...
110 (cd
$(PACKAGE_DIR
); $(SCRIPT_DIR
)/ipkg-make-index.sh .
> Packages
&& \
111 gzip
-9c Packages
> Packages.gz \
112 ) >/dev
/null
2>/dev
/null
115 package_install
: FORCE
117 @echo Installing packages...
118 $(IPKG
) install $(BUILD_PACKAGES
)
122 @echo Copying extra files
123 $(CP
) $(FILES
)/* $(TARGET_DIR
)/
125 package_postinst
: FORCE
127 @echo Activating init scripts
130 for script in .
/etc
/init.d
/*; do \
131 grep
'#!/bin/sh /etc/rc.common' $$script >/dev
/null || continue
; \
132 IPKG_INSTROOT
=$(TARGET_DIR
) $(which bash
) .
/etc
/rc.common
$$script enable
; \
138 @echo Building images...
139 $(NO_TRACE_MAKE
) -C target
/linux
/$(BOARD
)/image
install TARGET_BUILD
=1 IB
=1
142 rm -rf tmp
$(TARGET_DIR
) $(BIN_DIR
)
145 .SILENT
: help
info image