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