[toolchain] add external toolchain support, enhance native toolchain support (special...
[openwrt/svn-archive/archive.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:=31
13
14 PKG_FILE_DEPENDS:=$(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 ifneq ($(findstring mips64,$(ARCH)),)
28 LIB_SUFFIX:=64
29 endif
30 else
31 LIBC_VERSION:=<LIBC_VERSION>
32 LIBGCC_VERSION:=<LIBGCC_VERSION>
33 endif
34
35 define 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)
46 endef
47
48 define 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)
58 endef
59
60 define Package/base-files/description
61 This package contains a base filesystem and system scripts for OpenWrt.
62 endef
63
64
65 define Package/gcc/Default
66 SECTION:=libs
67 CATEGORY:=Base system
68 URL:=http://gcc.gnu.org/
69 VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
70 endef
71
72
73 define Package/libgcc
74 $(call Package/gcc/Default)
75 TITLE:=GCC support library
76 DEPENDS+=@!(TARGET_avr32||TARGET_coldfire)
77 endef
78
79 define Package/libgcc/config
80 menu "Configuration"
81 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
82
83 config LIBGCC_ROOT_DIR
84 string
85 prompt "libgcc shared library base directory"
86 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
87 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
88 default "/" if NATIVE_TOOLCHAIN
89
90 config LIBGCC_FILE_SPEC
91 string
92 prompt "libgcc shared library files (use wildcards)"
93 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
94 default "./lib/libgcc_s.so.*"
95
96 endmenu
97 endef
98
99
100 define Package/libssp
101 $(call Package/gcc/Default)
102 DEPENDS+=@SSP_SUPPORT
103 TITLE:=GCC support library
104 endef
105
106 define Package/libssp/config
107 menu "Configuration"
108 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
109
110 config LIBSPP_ROOT_DIR
111 string
112 prompt "libssp shared library base directory"
113 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
114 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
115 default "/" if NATIVE_TOOLCHAIN
116
117 config LIBSSP_FILE_SPEC
118 string
119 prompt "libssp shared library files (use wildcards)"
120 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
121 default "./lib/libssp.so.*"
122
123 endmenu
124 endef
125
126
127 define Package/libstdcpp
128 $(call Package/gcc/Default)
129 NAME:=libstdc++
130 TITLE:=GNU Standard C++ Library v3
131 DEPENDS+=@INSTALL_LIBSTDCPP
132 endef
133
134 define Package/libstdcpp/config
135 menu "Configuration"
136 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
137
138 config LIBSTDCPP_ROOT_DIR
139 string
140 prompt "libstdcpp shared library base directory"
141 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
142 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
143 default "/" if NATIVE_TOOLCHAIN
144
145 config LIBSTDCPP_FILE_SPEC
146 string
147 prompt "libstdc++ shared library files (use wildcards)"
148 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
149 default "./lib/libstdc++.so.*"
150
151 endmenu
152 endef
153
154
155 define Package/libc/Default
156 SECTION:=libs
157 CATEGORY:=Base system
158 VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
159 URL:=$(LIBC_URL)
160 endef
161
162
163 define Package/libc
164 $(call Package/libc/Default)
165 TITLE:=C library
166 endef
167
168 define Package/libc/config
169 menu "Configuration"
170 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
171
172 config LIBC_ROOT_DIR
173 string
174 prompt "libc shared library base directory"
175 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
176 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
177 default "/" if NATIVE_TOOLCHAIN
178
179 config LIBC_FILE_SPEC
180 string
181 prompt "libc shared library files (use wildcards)"
182 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
183 default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
184
185 endmenu
186 endef
187
188
189 define Package/libpthread
190 $(call Package/libc/Default)
191 TITLE:=POSIX thread library
192 DEPENDS:= +librt
193 endef
194
195 define Package/libpthread/config
196 menu "Configuration"
197 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
198
199 config LIBPTHREAD_ROOT_DIR
200 string
201 prompt "libpthread shared library base directory"
202 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
203 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
204 default "/" if NATIVE_TOOLCHAIN
205
206 config LIBPTHREAD_FILE_SPEC
207 string
208 prompt "libpthread shared library files (use wildcards)"
209 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
210 default "./lib/libpthread{-*.so,.so.*}"
211
212 endmenu
213 endef
214
215
216 define Package/librt
217 $(call Package/libc/Default)
218 TITLE:=POSIX.1b RealTime extension library
219 endef
220
221 define Package/librt/config
222 menu "Configuration"
223 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
224
225 config LIBRT_ROOT_DIR
226 string
227 prompt "librt shared library base directory"
228 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
229 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
230 default "/" if NATIVE_TOOLCHAIN
231
232 config LIBRT_FILE_SPEC
233 string
234 prompt "librt shared library files (use wildcards)"
235 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
236 default "./lib/librt{-*.so,.so.*}"
237
238 endmenu
239 endef
240
241
242 define Package/ldd
243 $(call Package/libc/Default)
244 SECTION:=utils
245 CATEGORY:=Utilities
246 TITLE:=LDD trace utility
247 endef
248
249 define Package/ldd/config
250 menu "Configuration"
251 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
252
253 config LDD_ROOT_DIR
254 string
255 prompt "ldd trace utility base directory"
256 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
257 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
258 default "/" if NATIVE_TOOLCHAIN
259
260 config LDD_FILE_SPEC
261 string
262 prompt "ldd trace utility file"
263 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
264 default "./usr/bin/ldd"
265
266 endmenu
267 endef
268
269
270 define Package/ldconfig
271 $(call Package/libc/Default)
272 SECTION:=utils
273 CATEGORY:=Utilities
274 TITLE:=Shared library path configuration
275 endef
276
277 define Package/ldconfig/config
278 menu "Configuration"
279 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
280
281 config LDCONFIG_ROOT_DIR
282 string
283 prompt "ldconfig base directory"
284 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
285 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
286 default "/" if NATIVE_TOOLCHAIN
287
288 config LDCONFIG_FILE_SPEC
289 string
290 prompt "ldconfig file"
291 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
292 default "./sbin/ldconfig"
293
294 endmenu
295 endef
296
297
298 define Build/Prepare
299 mkdir -p $(PKG_BUILD_DIR)
300 endef
301
302 define Build/Compile/Default
303 endef
304
305 define Build/Compile
306 $(call Build/Compile/Default)
307 endef
308
309 define Package/base-files/install
310 $(CP) ./files/* $(1)/
311 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
312 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
313 fi
314 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
315 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
316 fi
317 if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
318 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
319 fi
320 if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
321 $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
322 fi
323 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
324 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
325 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
326 fi; \
327 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
328 $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
329 fi; \
330 if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
331 $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
332 fi \
333 )
334 # Form valid /etc/shadow entries, by copying the user:pw pairs
335 # from /etc/passwd, and adding on pw change data
336 $(if $(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS), \
337 cut -d ':' -f 1-2 $(1)/etc/passwd > $(1)/etc/shadow; \
338 $(SED) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc/shadow \
339 )
340 $(SED) 's,$$$$R,$(REVISION),g' $(1)/etc/banner
341 mkdir -p $(1)/CONTROL
342 mkdir -p $(1)/dev
343 mkdir -p $(1)/etc/crontabs
344 mkdir -p $(1)/etc/rc.d
345 mkdir -p $(1)/jffs
346 mkdir -p $(1)/lib/firmware
347 $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
348 mkdir -p $(1)/mnt
349 mkdir -p $(1)/proc
350 mkdir -p $(1)/tmp
351 mkdir -p $(1)/usr/lib
352 $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
353 mkdir -p $(1)/usr/bin
354 mkdir -p $(1)/sys
355 mkdir -p $(1)/www
356 mkdir -p $(1)/root
357 ln -sf /proc/mounts $(1)/etc/mtab
358 rm -f $(1)/var
359 ln -sf /tmp $(1)/var
360 mkdir -p $(1)/etc
361 ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
362 $(call Package/base-files/install-target,$(1))
363 for conffile in $(1)/etc/config/*; do \
364 if [ -f "$$$$conffile" ]; then \
365 grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
366 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
367 fi \
368 done
369 endef
370
371 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
372
373 define Package/libgcc/install
374 $(INSTALL_DIR) $(1)/lib
375 $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libgcc_s.so.* $(1)/lib/
376 endef
377
378 define Package/libssp/install
379 $(INSTALL_DIR) $(1)/lib
380 $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libssp.so.* $(1)/lib/
381 endef
382
383 define Package/libstdcpp/install
384 $(INSTALL_DIR) $(1)/usr/lib
385 $(CP) $(TOOLCHAIN_DIR)/usr/lib$(LIB_SUFFIX)/libstdc++.so.* $(1)/usr/lib/
386 endef
387
388 use_libutil=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
389 use_libnsl=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
390 use_nsswitch=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
391
392 define Package/glibc/install
393 $(INSTALL_DIR) $(1)/lib
394 $(CP) $(TOOLCHAIN_DIR)/lib/ld*.so.* $(1)/lib/
395 $(CP) $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so $(1)/lib/
396 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
397 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
398 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so $(1)/lib/; \
399 done
400 endef
401
402 define Package/eglibc/install
403 $(call Package/glibc/install,$1)
404 endef
405
406 define Package/uClibc/install
407 $(INSTALL_DIR) $(1)/lib
408 for file in ld$(LIB_SUFFIX)-uClibc libc libcrypt libdl libm libnsl libresolv libuClibc libutil; do \
409 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
410 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so $(1)/lib/; \
411 done
412 endef
413
414 define Package/libc/install
415 $(call Package/$(LIBC)/install,$1)
416 endef
417
418 define Package/libc/install_lib
419 $(CP) $(filter-out %/libdl_pic.a,$(wildcard $(TOOLCHAIN_DIR)/usr/lib/lib*.a)) $(1)/lib/
420 $(if $(wildcard $(TOOLCHAIN_DIR)/usr/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/usr/lib/libc_so.a $(1)/lib/libc_pic.a)
421 $(CP) $(TOOLCHAIN_DIR)/usr/lib/gcc/*/*/libgcc.a $(1)/lib/libgcc_s_pic.a
422 endef
423
424 define Package/libpthread/install
425 $(INSTALL_DIR) $(1)/lib
426 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread.so.* $(1)/lib/
427 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so $(1)/lib/
428 endef
429
430 define Package/librt/install
431 $(INSTALL_DIR) $(1)/lib
432 $(CP) $(TOOLCHAIN_DIR)/lib/librt.so.* $(1)/lib/
433 $(CP) $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so $(1)/lib/
434 endef
435
436 define Package/ldd/install
437 $(INSTALL_DIR) $(1)/usr/bin/
438 $(CP) $(TOOLCHAIN_DIR)/usr/bin/ldd $(1)/usr/bin/
439 endef
440
441 define Package/ldconfig/install
442 $(INSTALL_DIR) $(1)/sbin/
443 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
444 endef
445
446 else
447
448 define Package/libgcc/install
449 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
450 dir=`dirname $$$$file` ; \
451 $(INSTALL_DIR) $(1)/$$$$dir ; \
452 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
453 done
454 endef
455
456 define Package/libssp/install
457 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
458 dir=`dirname $$$$file` ; \
459 $(INSTALL_DIR) $(1)/$$$$dir ; \
460 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
461 done
462 endef
463
464 define Package/libstdcpp/install
465 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
466 dir=`dirname $$$$file` ; \
467 $(INSTALL_DIR) $(1)/$$$$dir ; \
468 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
469 done
470 endef
471
472 define Package/libc/install
473 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
474 dir=`dirname $$$$file` ; \
475 $(INSTALL_DIR) $(1)/$$$$dir ; \
476 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
477 done
478 endef
479
480 define Package/libpthread/install
481 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
482 dir=`dirname $$$$file` ; \
483 $(INSTALL_DIR) $(1)/$$$$dir ; \
484 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
485 done
486 endef
487
488 define Package/librt/install
489 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
490 dir=`dirname $$$$file` ; \
491 $(INSTALL_DIR) $(1)/$$$$dir ; \
492 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
493 done
494 endef
495
496 define Package/ldd/install
497 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
498 dir=`dirname $$$$file` ; \
499 $(INSTALL_DIR) $(1)/$$$$dir ; \
500 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
501 done
502 endef
503
504 define Package/ldconfig/install
505 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
506 dir=`dirname $$$$file` ; \
507 $(INSTALL_DIR) $(1)/$$$$dir ; \
508 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
509 done
510 endef
511
512 endif
513
514 ifneq ($(DUMP),1)
515 -include $(PLATFORM_DIR)/base-files.mk
516 endif
517
518 $(eval $(call BuildPackage,base-files))
519 $(eval $(call BuildPackage,libc))
520 $(eval $(call BuildPackage,libgcc))
521 $(eval $(call BuildPackage,libssp))
522 $(eval $(call BuildPackage,libstdcpp))
523 $(eval $(call BuildPackage,libpthread))
524 $(eval $(call BuildPackage,librt))
525 $(eval $(call BuildPackage,ldd))
526 $(eval $(call BuildPackage,ldconfig))