33e8237819865e2debb467179e134509f06059ee
[openwrt/staging/chunkeey.git] / package / base-files / Makefile
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 # $Id$
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11
12 PKG_NAME:=base-files
13 PKG_RELEASE:=16
14
15 PKG_FILE_DEPEND:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
16
17 include $(INCLUDE_DIR)/package.mk
18
19 ifneq ($(DUMP),1)
20 TARGET:=-$(BOARD)
21 ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
22 TARGET:=$(TARGET)-$(PROFILE)
23 endif
24 LIBGCC_VERSION:=$(GCC_VERSION)
25 ifeq ($(ARCH),x86_64)
26 LIB_SUFFIX:=64
27 endif
28 else
29 LIBC_VERSION:=<LIBC_VERSION>
30 LIBGCC_VERSION:=<LIBGCC_VERSION>
31 endif
32
33 CONFIG_PACKAGE_base-files$(TARGET):=$(CONFIG_PACKAGE_base-files)
34
35 define Package/base-files$(TARGET)
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)
46 endef
47
48 define Package/base-files$(TARGET)/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)
58 endef
59
60 define Package/base-files$(TARGET)/description
61 This package contains a base filesystem and system scripts for OpenWrt.
62 endef
63
64 define 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)
70 endef
71
72 define Package/libgcc
73 $(call Package/gcc/Default)
74 TITLE:=GCC support library
75 DEPENDS+=@!TARGET_avr32
76 endef
77
78 define Package/libssp
79 $(call Package/gcc/Default)
80 DEPENDS+=@SSP_SUPPORT
81 TITLE:=GCC support library
82 endef
83
84 define Package/libstdcpp
85 $(call Package/gcc/Default)
86 NAME:=libstdc++
87 TITLE:=GNU Standard C++ Library v3
88 DEPENDS+=@INSTALL_LIBSTDCPP
89 endef
90
91 define Package/libc/Default
92 SECTION:=libs
93 CATEGORY:=Base system
94 DEPENDS:=@!NATIVE_TOOLCHAIN
95 VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
96 URL:=$(LIBC_URL)
97 endef
98
99 define Package/libc
100 $(call Package/libc/Default)
101 TITLE:=C library
102 endef
103
104 define Package/libpthread
105 $(call Package/libc/Default)
106 TITLE:=POSIX thread library
107 DEPENDS:= +librt
108 endef
109
110 define Package/librt
111 $(call Package/libc/Default)
112 TITLE:=POSIX.1b RealTime extension library
113 endef
114
115 define Package/ldd
116 $(call Package/uclibc/Default)
117 TITLE:=LDD trace utility
118 endef
119
120 define Package/ldconfig
121 $(call Package/libc/Default)
122 TITLE:=Shared library path configuration
123 endef
124
125
126 define Build/Prepare
127 mkdir -p $(PKG_BUILD_DIR)
128 endef
129
130 define Build/Compile/Default
131 endef
132
133 define Build/Compile
134 $(call Build/Compile/Default)
135 endef
136
137 define Package/base-files$(TARGET)/install
138 $(CP) ./files/* $(1)/
139 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
140 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
141 fi
142 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
143 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
144 fi
145 if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
146 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
147 fi
148 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
149 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
150 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
151 fi; \
152 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
153 $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
154 fi \
155 )
156 # Form valid /etc/shadow entries, by copying the user:pw pairs
157 # from /etc/passwd, and adding on pw change data
158 $(if $(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS), \
159 cut -d ':' -f 1-2 $(1)/etc/passwd > $(1)/etc/shadow; \
160 $(SED) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc/shadow \
161 )
162 $(SED) 's,$$$$R,$(REVISION),g' $(1)/etc/banner
163 mkdir -p $(1)/CONTROL
164 mkdir -p $(1)/dev
165 mkdir -p $(1)/etc/crontabs
166 mkdir -p $(1)/jffs
167 mkdir -p $(1)/lib/firmware
168 mkdir -p $(1)/mnt
169 mkdir -p $(1)/proc
170 mkdir -p $(1)/tmp
171 mkdir -p $(1)/usr/lib
172 mkdir -p $(1)/usr/bin
173 mkdir -p $(1)/sys
174 mkdir -p $(1)/www
175 mkdir -p $(1)/root
176 ln -sf /proc/mounts $(1)/etc/mtab
177 rm -f $(1)/var
178 ln -sf /tmp $(1)/var
179 mkdir -p $(1)/etc
180 ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
181 $(call Package/base-files/install-target,$(1))
182 for conffile in $(1)/etc/config/*; do \
183 if [ -f "$$$$conffile" ]; then \
184 grep "$$$$conffile" $(1)/CONTROL/conffiles || \
185 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
186 fi \
187 done
188 endef
189
190 define Package/libgcc/install
191 $(INSTALL_DIR) $(1)/lib
192 $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libgcc_s.so.* $(1)/lib/
193 endef
194
195 define Package/libssp/install
196 $(INSTALL_DIR) $(1)/lib
197 $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libssp.so.* $(1)/lib/
198 endef
199
200 define Package/libstdcpp/install
201 $(INSTALL_DIR) $(1)/usr/lib
202 $(CP) $(TOOLCHAIN_DIR)/usr/lib$(LIB_SUFFIX)/libstdc++.so.* $(1)/usr/lib/
203 endef
204
205 use_libutil=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
206 use_libnsl=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
207 use_nsswitch=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
208
209 define Package/glibc/install
210 $(INSTALL_DIR) $(1)/lib
211 $(CP) $(TOOLCHAIN_DIR)/lib/ld*.so.* $(1)/lib/
212 $(CP) $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_VERSION).so $(1)/lib/
213 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
214 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
215 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_VERSION).so $(1)/lib/; \
216 done
217 endef
218
219 define Package/eglibc/install
220 $(call Package/glibc/install,$1)
221 endef
222
223 define Package/uClibc/install
224 $(INSTALL_DIR) $(1)/lib
225 for file in ld$(LIB_SUFFIX)-uClibc libc libcrypt libdl libm libnsl libresolv libuClibc libutil; do \
226 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
227 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_VERSION).so $(1)/lib/; \
228 done
229 endef
230
231 define Package/libc/install
232 $(call Package/$(LIBC)/install,$1)
233 endef
234
235 define Package/libpthread/install
236 $(INSTALL_DIR) $(1)/lib
237 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread.so.* $(1)/lib/
238 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_VERSION).so $(1)/lib/
239 endef
240
241 define Package/librt/install
242 $(INSTALL_DIR) $(1)/lib
243 $(CP) $(TOOLCHAIN_DIR)/lib/librt.so.* $(1)/lib/
244 $(CP) $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_VERSION).so $(1)/lib/
245 endef
246
247 define Package/ldd/install
248 $(INSTALL_DIR) $(1)/usr/bin/
249 $(CP) $(TOOLCHAIN_DIR)/usr/bin/ldd $(1)/usr/bin/
250 endef
251
252 define Package/ldconfig/install
253 $(INSTALL_DIR) $(1)/sbin/
254 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
255 endef
256
257 ifneq ($(DUMP),1)
258 -include $(PLATFORM_DIR)/base-files.mk
259 endif
260
261 $(eval $(call BuildPackage,base-files$(TARGET)))
262 $(eval $(call BuildPackage,libc))
263 $(eval $(call BuildPackage,libgcc))
264 $(eval $(call BuildPackage,libssp))
265 $(eval $(call BuildPackage,libstdcpp))
266 $(eval $(call BuildPackage,libpthread))
267 $(eval $(call BuildPackage,librt))
268 $(eval $(call BuildPackage,ldd))
269 $(eval $(call BuildPackage,ldconfig))