xref: /OK3568_Linux_fs/buildroot/system/system.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun################################################################################
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# system-related variables and macros
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun################################################################################
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun# This file exists to define variables and macros that pertain to the system
8*4882a593Smuzhiyun# settings, like rsyncing a directory for skeletons, or the /lib vs. /usr/lib
9*4882a593Smuzhiyun# symlink handling.
10*4882a593Smuzhiyun#
11*4882a593Smuzhiyun# Some variables may be used as conditions in Makefile code, so they must be
12*4882a593Smuzhiyun# defined properly before they are used; this file is included early, before
13*4882a593Smuzhiyun# any package is.
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun# - SYSTEM_USR_SYMLINKS_OR_DIRS
16*4882a593Smuzhiyun#   create /lib, /bin and /sbin, either as directories or as symlinks to
17*4882a593Smuzhiyun#   their /usr conterparts
18*4882a593Smuzhiyun#
19*4882a593Smuzhiyun# - SYSTEM_RSYNC
20*4882a593Smuzhiyun#   rsync $(1) to $(2), with proper exclusions and rights
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# - SYSTEM_LIB_SYMLINK
23*4882a593Smuzhiyun#   create the appropriate /lib{32,64} symlinks
24*4882a593Smuzhiyun#
25*4882a593Smuzhiyun# - SYSTEM_GETTY_PORT
26*4882a593Smuzhiyun# - SYSTEM_GETTY_BAUDRATE
27*4882a593Smuzhiyun# - SYSTEM_GETTY_TERM
28*4882a593Smuzhiyun# - SYSTEM_GETTY_OPTIONS
29*4882a593Smuzhiyun#   the un-quoted getty setting
30*4882a593Smuzhiyun#
31*4882a593Smuzhiyun# - SYSTEM_REMOUNT_ROOT_INITTAB
32*4882a593Smuzhiyun#   set inittab to remount root read-write or read-only
33*4882a593Smuzhiyun#
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun# This function handles the merged or non-merged /usr cases
36*4882a593Smuzhiyunifeq ($(BR2_ROOTFS_MERGED_USR),y)
37*4882a593Smuzhiyundefine SYSTEM_USR_SYMLINKS_OR_DIRS
38*4882a593Smuzhiyun	ln -snf usr/bin $(1)/bin
39*4882a593Smuzhiyun	ln -snf usr/sbin $(1)/sbin
40*4882a593Smuzhiyun	ln -snf usr/lib $(1)/lib
41*4882a593Smuzhiyunendef
42*4882a593Smuzhiyunelse
43*4882a593Smuzhiyundefine SYSTEM_USR_SYMLINKS_OR_DIRS
44*4882a593Smuzhiyun	$(INSTALL) -d -m 0755 $(1)/bin
45*4882a593Smuzhiyun	$(INSTALL) -d -m 0755 $(1)/sbin
46*4882a593Smuzhiyun	$(INSTALL) -d -m 0755 $(1)/lib
47*4882a593Smuzhiyunendef
48*4882a593Smuzhiyunendif
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun# This function rsyncs the skeleton directory in $(1) to the destination
51*4882a593Smuzhiyun# in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
52*4882a593Smuzhiyundefine SYSTEM_RSYNC
53*4882a593Smuzhiyun	rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
54*4882a593Smuzhiyun		--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
55*4882a593Smuzhiyun		$(1)/ $(2)/
56*4882a593Smuzhiyunendef
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun# Make a symlink lib32->lib or lib64->lib as appropriate.
59*4882a593Smuzhiyun# MIPS64/n32 requires lib32 even though it's a 64-bit arch. However, since gcc
60*4882a593Smuzhiyun# 5.1.0 internal compiler paths in sysroot are relative to lib64, so we must
61*4882a593Smuzhiyun# create both.
62*4882a593Smuzhiyun# $(1): base dir (either staging or target)
63*4882a593Smuzhiyunifeq ($(BR2_MIPS_NABI32),y)
64*4882a593Smuzhiyundefine SYSTEM_LIB_SYMLINK
65*4882a593Smuzhiyun	ln -snf lib $(1)/lib64
66*4882a593Smuzhiyun	ln -snf lib $(1)/usr/lib64
67*4882a593Smuzhiyun	ln -snf lib $(1)/lib32
68*4882a593Smuzhiyun	ln -snf lib $(1)/usr/lib32
69*4882a593Smuzhiyunendef
70*4882a593Smuzhiyunelse ifeq ($(BR2_ARCH_IS_64),y)
71*4882a593Smuzhiyundefine SYSTEM_LIB_SYMLINK
72*4882a593Smuzhiyun	ln -snf lib $(1)/lib64
73*4882a593Smuzhiyun	ln -snf lib $(1)/usr/lib64
74*4882a593Smuzhiyunendef
75*4882a593Smuzhiyunelse
76*4882a593Smuzhiyundefine SYSTEM_LIB_SYMLINK
77*4882a593Smuzhiyun	ln -snf lib $(1)/lib32
78*4882a593Smuzhiyun	ln -snf lib $(1)/usr/lib32
79*4882a593Smuzhiyunendef
80*4882a593Smuzhiyunendif
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunSYSTEM_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
83*4882a593SmuzhiyunSYSTEM_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
84*4882a593SmuzhiyunSYSTEM_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
85*4882a593SmuzhiyunSYSTEM_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
86*4882a593Smuzhiyun
87*4882a593Smuzhiyunifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
88*4882a593Smuzhiyun# Find commented line, if any, and remove leading '#'s
89*4882a593Smuzhiyundefine SYSTEM_REMOUNT_ROOT_INITTAB
90*4882a593Smuzhiyun	$(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
91*4882a593Smuzhiyunendef
92*4882a593Smuzhiyunelse
93*4882a593Smuzhiyun# Find uncommented line, if any, and add a leading '#'
94*4882a593Smuzhiyundefine SYSTEM_REMOUNT_ROOT_INITTAB
95*4882a593Smuzhiyun	$(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
96*4882a593Smuzhiyunendef
97*4882a593Smuzhiyunendif
98*4882a593Smuzhiyun
99*4882a593Smuzhiyunifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
100*4882a593Smuzhiyun$(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
101*4882a593Smuzhiyunendif
102