Root/target/imagebuilder/files/Makefile

1# Makefile for OpenWrt
2#
3# Copyright (C) 2007-2010 OpenWrt.org
4#
5# This is free software, licensed under the GNU General Public License v2.
6# See /LICENSE for more information.
7#
8
9TOPDIR:=${CURDIR}
10LC_ALL:=C
11LANG:=C
12export TOPDIR LC_ALL LANG
13export KBUILD_VERBOSE=99
14all: help
15
16include $(TOPDIR)/include/host.mk
17
18ifneq ($(OPENWRT_BUILD),1)
19  override OPENWRT_BUILD=1
20  export OPENWRT_BUILD
21endif
22
23include rules.mk
24include $(INCLUDE_DIR)/debug.mk
25include $(INCLUDE_DIR)/depends.mk
26
27include $(INCLUDE_DIR)/version.mk
28export REVISION
29
30define Helptext
31Available Commands:
32    help: This help text
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).
36
37Building images:
38    By default 'make image' will create an image with the default
39    target profile and package set. You can use the following parameters
40    to change that:
41    
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
46endef
47$(eval $(call shexport,Helptext))
48
49help: FORCE
50    echo "$$$(call shvar,Helptext)"
51
52
53# override variables from rules.mk
54PACKAGE_DIR:=$(TOPDIR)/packages
55IPKG:= \
56  IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
57  IPKG_INSTROOT="$(TARGET_DIR)" \
58  IPKG_CONF_DIR="$(TOPDIR)/tmp" \
59  IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
60  $(SCRIPT_DIR)/ipkg -force-defaults
61
62define Profile
63  $(eval $(call Profile/Default))
64  $(eval $(call Profile/$(1)))
65  ifeq ($(USER_PROFILE),)
66    USER_PROFILE:=$(1)
67  endif
68  $(1)_NAME:=$(NAME)
69  $(1)_PACKAGES:=$(PACKAGES)
70  PROFILE_LIST += \
71      echo '$(1):'; [ -z '$(NAME)' ] || echo ' $(NAME)'; echo ' Packages: $(PACKAGES)';
72endef
73
74include $(INCLUDE_DIR)/target.mk
75
76_call_info: FORCE
77    echo 'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
78    echo 'Default Packages: $(DEFAULT_PACKAGES)'
79    echo 'Available Profiles:'
80    echo; $(PROFILE_LIST)
81
82$(TOPDIR)/tmp/ipkg.conf: FORCE
83    @mkdir -p $(TOPDIR)/tmp
84    @echo 'dest root /' > $@
85    @echo 'src packages file:$(PACKAGE_DIR)' >> $@
86
87BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(USER_PACKAGES) $($(USER_PROFILE)_PACKAGES) kernel)
88# "-pkgname" in the package list means remove "pkgname" from the package list
89BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
90
91_call_image:
92    echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
93    echo 'Packages: $(BUILD_PACKAGES)'
94    echo
95    rm -rf $(TARGET_DIR)
96    mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
97    $(MAKE) package_index
98    $(MAKE) package_install
99ifneq ($(USER_FILES),)
100    $(MAKE) copy_files
101endif
102    $(MAKE) package_postinst
103    $(MAKE) build_image
104    
105package_index: $(TOPDIR)/tmp/ipkg.conf FORCE
106    @echo
107    @echo Building package index...
108    (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
109        gzip -9c Packages > Packages.gz \
110    ) >/dev/null 2>/dev/null
111    $(IPKG) update
112
113package_install: FORCE
114    @echo
115    @echo Installing packages...
116    $(IPKG) install $(BUILD_PACKAGES)
117
118copy_files: FORCE
119    @echo
120    @echo Copying extra files
121    $(CP) $(USER_FILES)/* $(TARGET_DIR)/
122
123package_postinst: FORCE
124    @echo
125    @echo Activating init scripts
126    @( \
127        cd $(TARGET_DIR); \
128        for script in ./etc/init.d/*; do \
129            grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
130            IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $$script enable; \
131        done || true; \
132    )
133
134build_image: FORCE
135    @echo
136    @echo Building images...
137    $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1
138    
139clean:
140    rm -rf tmp $(TARGET_DIR) $(BIN_DIR)
141
142
143info:
144    (unset PROFILE FILES PACKAGES MAKEFLAGS; $(MAKE) -s _call_info)
145
146image:
147    (unset PROFILE FILES PACKAGES MAKEFLAGS; \
148    $(MAKE) _call_image \
149        $(if $(PROFILE),USER_PROFILE="$(PROFILE)") \
150        $(if $(FILES),USER_FILES="$(FILES)") \
151        $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)"))
152
153.SILENT: help info image
154
155

Archive Download this file



interactive