root/trunk/freewrt/target/Makefile

Revision 3860, 3.7 kB (checked in by n0-1, 3 years ago)

clarify docs a bit

Line 
1 # $FreeWRT$
2 #-
3 # This file is part of the FreeWRT project. FreeWRT is copyrighted
4 # material, please see the LICENCE file in the top-level directory
5 # or at http://www.freewrt.org/licence for details.
6
7 include $(TOPDIR)/rules.mk
8 include $(TOPDIR)/mk/targets.mk
9
10 all: install
11
12 $(BIN_DIR):
13         mkdir -p $(BIN_DIR)
14
15 linux-compile: 
16 linux-install: $(BIN_DIR)
17
18 ### Kernel .config Creation
19 # The following target combines all kernel-related variables and
20 # config files into a single one to be used as the final kernel
21 # configuration when building. This is how it's done:
22 # 1) fetch all FWRT_KPACKAGE_KMOD_* vars into
23 #    .fwrtkernelconfig.modules and set them to "m"
24 # 2) fetch all enabled FWRT_KERNEL_* vars into
25 #    .fwrtkernelconfig.kernel (no conversion, as they are booleans)
26 # 3) repeat 2) for the disabled ones and save them into
27 #    .fwrtkernelconfig.nokernel (for some obscure reason)
28 # 4) get the board-specific static kernel config and place it into
29 #    .fwrtkernelconfig.board
30 # 5) prepare for merging:
31 #    * if a variable is disabled in .fwrtkernelconfig.board and
32 #      enabled in either of .fwrtkernelconfig.{modules,kernel},
33 #      remove it from .fwrtkernelconfig.board
34 #    * append ${FS_CMDLINE} to the kernel commandline inside
35 #      .fwrtkernelconfig.board
36 # 6) merge (cat) .fwrtkernelconfig.board, .fwrtkernelconfig.kernel and
37 #    .fwrtkernelconfig.modules together into .fwrtkernelconfig.tmp
38 # 7) check if .fwrtkernelconfig.tmp differs from the current one
39 #    (.fwrtkernelconfig) at all, overwriting the current one
40 #    only if it does (so the timestamp stays intact)
41 # 8) remove the temporary .fwrtkernelconfig.tmp
42 ###
43 config-prepare: $(TOPDIR)/.config
44         sed -n '/^FWRT_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
45             sed 's/=y/=m/' >${BUILD_DIR}/.fwrtkernelconfig.modules
46         sed -n '/^FWRT_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
47             >${BUILD_DIR}/.fwrtkernelconfig.kernel
48         sed -n '/^# FWRT_KERNEL/s//# CONFIG/p' ${TOPDIR}/.config \
49             >${BUILD_DIR}/.fwrtkernelconfig.nokernel
50         cp linux/${BOARD}-${KERNEL}/kernelconfig \
51             ${BUILD_DIR}/.fwrtkernelconfig.board
52         (cat ${BUILD_DIR}/.fwrtkernelconfig.{modules,kernel} | \
53             while IFS='=' read symbol value; do \
54                 echo ",g/^# $$symbol/d"; \
55         done; \
56         echo ',g^\(CONFIG_CMDLINE="\)\(.*\)"s\1\2 ${FS_CMDLINE}"'; \
57         echo wq) | ed -s ${BUILD_DIR}/.fwrtkernelconfig.board
58         cd ${BUILD_DIR} && cat .fwrtkernelconfig.board \
59             .fwrtkernelconfig.kernel .fwrtkernelconfig.modules \
60             >.fwrtkernelconfig.tmp
61         cd ${BUILD_DIR} && cmp -s .fwrtkernelconfig.tmp .fwrtkernelconfig || \
62             cp .fwrtkernelconfig.tmp .fwrtkernelconfig
63         -rm -f ${BUILD_DIR}/.fwrtkernelconfig.tmp
64
65 prepare: linux-prepare
66 compile: linux-compile
67 ifneq ($(strip ${FWRT_TARGET_NOKERNEL})$(strip ${FWRT_TARGET_ROOTFS_INITRAMFS}),)
68 install: image_clean linux-noinstall image_install
69 else
70 install: image_clean linux-install image_install
71 endif
72 clean: linux-clean image_clean
73
74 image_clean:
75         rm -f $(BIN_DIR)/$(FWRT_PREFIX)-*
76
77 image_install:
78 ifneq ($(strip ${FWRT_TARGET_NOKERNEL}),)
79         ${MAKE} -C image/nokernel install-prepare install
80 else
81         $(MAKE) -C image/$(BOARD) install-prepare
82         $(MAKE) -C image/$(BOARD) install
83 endif
84
85 %-clean:
86         $(TRACE) target/$(patsubst %-clean,%,$@)-clean
87         $(MAKE) -C $(patsubst %-clean,%,$@) clean
88 %-prepare:
89         $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
90         $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
91 %-compile: %-prepare
92         $(TRACE) target/$(patsubst %-compile,%,$@)-compile
93         $(MAKE) -C $(patsubst %-compile,%,$@) compile
94 %-install: %-compile
95         $(TRACE) target/$(patsubst %-install,%,$@)-install
96         $(MAKE) -C $(patsubst %-install,%,$@) install
97 %-noinstall:
98         $(TRACE) target/$(patsubst %-noinstall,%,$@)-noinstall
99         $(MAKE) -C $(patsubst %-noinstall,%,$@) noinstall
100
Note: See TracBrowser for help on using the browser.