source: trunk/package/base-files/Makefile @ 17571

Last change on this file since 17571 was 17571, checked in by jow, 7 years ago

[package] base-files: introduce a ready-to-use /etc/rc.local to let users run custom commands on init without creating custom init scripts

  • Property svn:copyright set to Copyright (C) 2006 OpenWrt.org
  • Property svn:eol-style set to native
File size: 7.7 KB
Line 
1#
2# Copyright (C) 2007-2009 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6#
7
8include $(TOPDIR)/rules.mk
9include $(INCLUDE_DIR)/kernel.mk
10
11PKG_NAME:=base-files
12PKG_RELEASE:=29
13
14PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
15
16include $(INCLUDE_DIR)/package.mk
17
18ifneq ($(DUMP),1)
19  TARGET:=-$(BOARD)
20  ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
21    TARGET:=$(TARGET)-$(PROFILE)
22  endif
23  LIBGCC_VERSION:=$(GCC_VERSION)
24  ifeq ($(ARCH),x86_64)
25    LIB_SUFFIX:=64
26  endif
27  ifneq ($(findstring mips64,$(ARCH)),)
28    LIB_SUFFIX:=64
29  endif
30else
31  LIBC_VERSION:=<LIBC_VERSION>
32  LIBGCC_VERSION:=<LIBGCC_VERSION>
33endif
34
35define Package/base-files
36  SECTION:=base
37  CATEGORY:=Base system
38  TITLE:=Base filesystem for OpenWrt
39  URL:=http://openwrt.org/
40  VERSION:=$(PKG_RELEASE)-$(REVISION)
41  $(call Config,network.lan.proto,string,static,LAN Protocol)
42  $(call Config,network.lan.ipaddr,ip,192.168.1.1,LAN IP Address)
43  $(call Config,network.lan.netmask,netmask,255.255.255.0,LAN Network Mask)
44  $(call Config,network.lan.gateway,ip,,LAN Gateway)
45  $(call Config,network.lan.dns,ip,,LAN DNS server)
46endef
47
48define Package/base-files/conffiles
49/etc/banner
50/etc/hosts
51/etc/inittab
52/etc/group
53/etc/passwd
54/etc/profile
55/etc/shells
56/etc/sysctl.conf
57$(call $(TARGET)/conffiles)
58endef
59
60define Package/base-files/description
61 This package contains a base filesystem and system scripts for OpenWrt.
62endef
63
64define Package/gcc/Default
65  SECTION:=libs
66  CATEGORY:=Base system
67  DEPENDS:=@!NATIVE_TOOLCHAIN
68  URL:=http://gcc.gnu.org/
69  VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
70endef
71
72define Package/libgcc
73$(call Package/gcc/Default)
74  TITLE:=GCC support library
75  DEPENDS+=@!(TARGET_avr32||TARGET_coldfire)
76endef
77
78define Package/libssp
79$(call Package/gcc/Default)
80  DEPENDS+=@SSP_SUPPORT
81  TITLE:=GCC support library
82endef
83
84define Package/libstdcpp
85$(call Package/gcc/Default)
86  NAME:=libstdc++
87  TITLE:=GNU Standard C++ Library v3
88  DEPENDS+=@INSTALL_LIBSTDCPP
89endef
90
91define Package/libc/Default
92  SECTION:=libs
93  CATEGORY:=Base system
94  DEPENDS:=@!NATIVE_TOOLCHAIN
95  VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
96  URL:=$(LIBC_URL)
97endef
98
99define Package/libc
100$(call Package/libc/Default)
101  TITLE:=C library
102endef
103
104define Package/libpthread
105$(call Package/libc/Default)
106  TITLE:=POSIX thread library
107  DEPENDS:= +librt
108endef
109
110define Package/librt
111$(call Package/libc/Default)
112  TITLE:=POSIX.1b RealTime extension library
113endef
114
115define Package/ldd
116$(call Package/libc/Default)
117  SECTION:=utils
118  CATEGORY:=Utilities
119  TITLE:=LDD trace utility
120endef
121
122define Package/ldconfig
123$(call Package/libc/Default)
124  SECTION:=utils
125  CATEGORY:=Utilities
126  TITLE:=Shared library path configuration
127endef
128
129
130define Build/Prepare
131        mkdir -p $(PKG_BUILD_DIR)
132endef
133
134define Build/Compile/Default
135endef
136
137define Build/Compile
138        $(call Build/Compile/Default)
139endef
140
141define Package/base-files/install
142        $(CP) ./files/* $(1)/
143        if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
144                $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
145        fi
146        if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
147                $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
148        fi
149        if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
150                $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
151        fi
152        if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
153                $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
154        fi
155        $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
156                if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
157                        $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
158                fi; \
159                if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
160                        $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
161                fi; \
162                if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
163                        $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
164                fi \
165        )
166# Form valid /etc/shadow entries, by copying the user:pw pairs
167# from /etc/passwd, and adding on pw change data
168        $(if $(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS), \
169                cut -d ':' -f 1-2 $(1)/etc/passwd > $(1)/etc/shadow; \
170                $(SED) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc/shadow \
171        )
172        $(SED) 's,$$$$R,$(REVISION),g' $(1)/etc/banner
173        mkdir -p $(1)/CONTROL
174        mkdir -p $(1)/dev
175        mkdir -p $(1)/etc/crontabs
176        mkdir -p $(1)/etc/rc.d
177        mkdir -p $(1)/jffs
178        mkdir -p $(1)/lib/firmware
179        $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
180        mkdir -p $(1)/mnt
181        mkdir -p $(1)/proc
182        mkdir -p $(1)/tmp
183        mkdir -p $(1)/usr/lib
184        $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
185        mkdir -p $(1)/usr/bin
186        mkdir -p $(1)/sys
187        mkdir -p $(1)/www
188        mkdir -p $(1)/root
189        ln -sf /proc/mounts $(1)/etc/mtab
190        rm -f $(1)/var
191        ln -sf /tmp $(1)/var
192        mkdir -p $(1)/etc
193        ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
194        $(call Package/base-files/install-target,$(1))
195        for conffile in $(1)/etc/config/*; do \
196                if [ -f "$$$$conffile" ]; then \
197                        grep "$$$$conffile" $(1)/CONTROL/conffiles || \
198                                echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
199                fi \
200        done
201endef
202
203define Package/libgcc/install
204        $(INSTALL_DIR) $(1)/lib
205        $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libgcc_s.so.* $(1)/lib/
206endef
207
208define Package/libssp/install
209        $(INSTALL_DIR) $(1)/lib
210        $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libssp.so.* $(1)/lib/
211endef
212
213define Package/libstdcpp/install
214        $(INSTALL_DIR) $(1)/usr/lib
215        $(CP) $(TOOLCHAIN_DIR)/usr/lib$(LIB_SUFFIX)/libstdc++.so.* $(1)/usr/lib/
216endef
217
218use_libutil=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
219use_libnsl=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
220use_nsswitch=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
221
222define Package/glibc/install
223        $(INSTALL_DIR) $(1)/lib
224        $(CP) $(TOOLCHAIN_DIR)/lib/ld*.so.* $(1)/lib/
225        $(CP) $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so $(1)/lib/
226        for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
227                $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
228                $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so $(1)/lib/; \
229        done
230endef
231
232define Package/eglibc/install
233$(call Package/glibc/install,$1)
234endef
235
236define Package/uClibc/install
237        $(INSTALL_DIR) $(1)/lib
238        for file in ld$(LIB_SUFFIX)-uClibc libc libcrypt libdl libm libnsl libresolv libuClibc libutil; do \
239                $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
240                $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so $(1)/lib/; \
241        done
242endef
243
244define Package/libc/install
245$(call Package/$(LIBC)/install,$1)
246endef
247
248define Package/libc/install_lib
249        $(CP) $(filter-out %/libdl_pic.a,$(wildcard $(TOOLCHAIN_DIR)/usr/lib/lib*.a)) $(1)/lib/
250        $(if $(wildcard $(TOOLCHAIN_DIR)/usr/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/usr/lib/libc_so.a $(1)/lib/libc_pic.a)
251        $(CP) $(TOOLCHAIN_DIR)/usr/lib/gcc/*/*/libgcc.a $(1)/lib/libgcc_s_pic.a
252endef
253
254define Package/libpthread/install
255        $(INSTALL_DIR) $(1)/lib
256        $(CP) $(TOOLCHAIN_DIR)/lib/libpthread.so.* $(1)/lib/
257        $(CP) $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so $(1)/lib/
258endef
259
260define Package/librt/install
261        $(INSTALL_DIR) $(1)/lib
262        $(CP) $(TOOLCHAIN_DIR)/lib/librt.so.* $(1)/lib/
263        $(CP) $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so $(1)/lib/
264endef
265
266define Package/ldd/install
267        $(INSTALL_DIR) $(1)/usr/bin/
268        $(CP) $(TOOLCHAIN_DIR)/usr/bin/ldd $(1)/usr/bin/
269endef
270
271define Package/ldconfig/install
272        $(INSTALL_DIR) $(1)/sbin/
273        $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
274endef
275
276ifneq ($(DUMP),1)
277  -include $(PLATFORM_DIR)/base-files.mk
278endif
279
280$(eval $(call BuildPackage,base-files))
281$(eval $(call BuildPackage,libc))
282$(eval $(call BuildPackage,libgcc))
283$(eval $(call BuildPackage,libssp))
284$(eval $(call BuildPackage,libstdcpp))
285$(eval $(call BuildPackage,libpthread))
286$(eval $(call BuildPackage,librt))
287$(eval $(call BuildPackage,ldd))
288$(eval $(call BuildPackage,ldconfig))
Note: See TracBrowser for help on using the repository browser.