2 # Copyright (C) 2007-2010 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
15 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
17 include $(INCLUDE_DIR)/package.mk
21 ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
22 TARGET:=$(TARGET)-$(PROFILE)
24 LIBGCC_VERSION:=$(GCC_VERSION)
28 ifneq ($(findstring mips64,$(ARCH)),)
32 LIBC_VERSION:=<LIBC_VERSION>
33 LIBGCC_VERSION:=<LIBGCC_VERSION>
36 define Package/base-files
39 TITLE:=Base filesystem for OpenWrt
40 URL:=http://openwrt.org/
41 VERSION:=$(PKG_RELEASE)-$(REVISION)
42 $(call Config,network.lan.proto,string,static,LAN Protocol)
43 $(call Config,network.lan.ipaddr,ip,192.168.1.1,LAN IP Address)
44 $(call Config,network.lan.netmask,netmask,255.255.255.0,LAN Network Mask)
45 $(call Config,network.lan.gateway,ip,,LAN Gateway)
46 $(call Config,network.lan.dns,ip,,LAN DNS server)
49 define Package/base-files/conffiles
58 $(call $(TARGET)/conffiles)
61 define Package/base-files/description
62 This package contains a base filesystem and system scripts for OpenWrt.
66 define Package/gcc/Default
69 URL:=http://gcc.gnu.org/
70 VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
75 $(call Package/gcc/Default)
76 TITLE:=GCC support library
77 DEPENDS+=@!(TARGET_avr32||TARGET_coldfire)
80 define Package/libgcc/config
82 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
84 config LIBGCC_ROOT_DIR
86 prompt "libgcc shared library base directory"
87 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
88 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
89 default "/" if NATIVE_TOOLCHAIN
91 config LIBGCC_FILE_SPEC
93 prompt "libgcc shared library files (use wildcards)"
94 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
95 default "./lib/libgcc_s.so.*"
101 define Package/libssp
102 $(call Package/gcc/Default)
103 DEPENDS+=@SSP_SUPPORT
104 TITLE:=GCC support library
107 define Package/libssp/config
109 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
111 config LIBSPP_ROOT_DIR
113 prompt "libssp shared library base directory"
114 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
115 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
116 default "/" if NATIVE_TOOLCHAIN
118 config LIBSSP_FILE_SPEC
120 prompt "libssp shared library files (use wildcards)"
121 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
122 default "./lib/libssp.so.*"
128 define Package/libstdcpp
129 $(call Package/gcc/Default)
131 TITLE:=GNU Standard C++ Library v3
132 DEPENDS+=@INSTALL_LIBSTDCPP
135 define Package/libstdcpp/config
137 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
139 config LIBSTDCPP_ROOT_DIR
141 prompt "libstdcpp shared library base directory"
142 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
143 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
144 default "/" if NATIVE_TOOLCHAIN
146 config LIBSTDCPP_FILE_SPEC
148 prompt "libstdc++ shared library files (use wildcards)"
149 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
150 default "./lib/libstdc++.so.*"
156 define Package/libc/Default
158 CATEGORY:=Base system
159 VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
160 ifneq ($(TARGET_avr32)$(TARGET_coldfire),)
168 $(call Package/libc/Default)
172 define Package/libc/config
174 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
178 prompt "libc shared library base directory"
179 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
180 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
181 default "/" if NATIVE_TOOLCHAIN
183 config LIBC_FILE_SPEC
185 prompt "libc shared library files (use wildcards)"
186 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
187 default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
193 define Package/libpthread
194 $(call Package/libc/Default)
195 TITLE:=POSIX thread library
199 define Package/libpthread/config
201 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
203 config LIBPTHREAD_ROOT_DIR
205 prompt "libpthread shared library base directory"
206 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
207 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
208 default "/" if NATIVE_TOOLCHAIN
210 config LIBPTHREAD_FILE_SPEC
212 prompt "libpthread shared library files (use wildcards)"
213 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
214 default "./lib/libpthread{-*.so,.so.*}"
221 $(call Package/libc/Default)
222 TITLE:=POSIX.1b RealTime extension library
225 define Package/librt/config
227 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
229 config LIBRT_ROOT_DIR
231 prompt "librt shared library base directory"
232 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
233 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
234 default "/" if NATIVE_TOOLCHAIN
236 config LIBRT_FILE_SPEC
238 prompt "librt shared library files (use wildcards)"
239 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
240 default "./lib/librt{-*.so,.so.*}"
247 $(call Package/libc/Default)
250 TITLE:=LDD trace utility
253 define Package/ldd/config
255 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
259 prompt "ldd trace utility base directory"
260 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
261 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
262 default "/" if NATIVE_TOOLCHAIN
266 prompt "ldd trace utility file"
267 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
268 default "./usr/bin/ldd"
274 define Package/ldconfig
275 $(call Package/libc/Default)
278 TITLE:=Shared library path configuration
281 define Package/ldconfig/config
283 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
285 config LDCONFIG_ROOT_DIR
287 prompt "ldconfig base directory"
288 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
289 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
290 default "/" if NATIVE_TOOLCHAIN
292 config LDCONFIG_FILE_SPEC
294 prompt "ldconfig file"
295 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
296 default "./sbin/ldconfig"
302 ifneq ($(CONFIG_PREINITOPT),)
303 define ImageConfigOptions
304 mkdir -p $(1)/lib/preinit
305 echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
306 echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
307 echo 'pi_init_path=$(if $(CONFIG_TARGET_INIT_PATH),$(CONFIG_TARGET_INIT_PATH),"/bin:/sbin:/usr/bin:/usr/sbin")' >>$(1)/lib/preinit/00_preinit.conf
308 echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
309 echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
310 echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
311 echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
312 echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
313 echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
314 echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
315 echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
316 echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
321 mkdir -p $(PKG_BUILD_DIR)
324 define Build/Compile/Default
328 $(call Build/Compile/Default)
331 define Package/base-files/install
332 $(CP) ./files/* $(1)/
333 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
334 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
336 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
337 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
339 if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
340 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
342 if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
343 $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
345 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
346 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
347 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
349 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
350 $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
352 if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
353 $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
356 # Form valid /etc/shadow entries, by copying the user:pw pairs
357 # from /etc/passwd, and adding on pw change data
358 $(if $(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS), \
359 cut -d ':' -f 1-2 $(1)/etc/passwd > $(1)/etc/shadow; \
360 $(SED) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc/shadow \
362 $(SED) 's,$$$$R,$(REVISION),g' $(1)/etc/banner
363 mkdir -p $(1)/CONTROL
365 mkdir -p $(1)/etc/crontabs
366 mkdir -p $(1)/etc/rc.d
368 mkdir -p $(1)/lib/firmware
369 $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
373 mkdir -p $(1)/usr/lib
374 $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
375 mkdir -p $(1)/usr/bin
379 ln -sf /proc/mounts $(1)/etc/mtab
383 ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
384 $(call ImageConfigOptions,$(1))
385 $(call Package/base-files/install-target,$(1))
386 for conffile in $(1)/etc/config/*; do \
387 if [ -f "$$$$conffile" ]; then \
388 grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
389 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
394 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
396 define Package/libgcc/install
397 $(INSTALL_DIR) $(1)/lib
398 $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libgcc_s.so.* $(1)/lib/
401 define Package/libssp/install
402 $(INSTALL_DIR) $(1)/lib
403 $(CP) $(TOOLCHAIN_DIR)/lib$(LIB_SUFFIX)/libssp.so.* $(1)/lib/
406 define Package/libstdcpp/install
407 $(INSTALL_DIR) $(1)/usr/lib
408 $(CP) $(TOOLCHAIN_DIR)/usr/lib$(LIB_SUFFIX)/libstdc++.so.* $(1)/usr/lib/
411 use_libutil=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
412 use_libnsl=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
413 use_nsswitch=$(if $(CONFIG_USE_GLIBC)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
415 define Package/glibc/install
416 $(INSTALL_DIR) $(1)/lib
417 $(CP) $(TOOLCHAIN_DIR)/lib/ld*.so.* $(1)/lib/
418 $(CP) $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so $(1)/lib/
419 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
420 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
421 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so $(1)/lib/; \
425 define Package/eglibc/install
426 $(call Package/glibc/install,$1)
429 define Package/uClibc/install
430 $(INSTALL_DIR) $(1)/lib
431 for file in ld$(LIB_SUFFIX)-uClibc libc libcrypt libdl libm libnsl libresolv libuClibc libutil; do \
432 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
433 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so $(1)/lib/; \
437 define Package/libc/install
438 $(call Package/$(LIBC)/install,$1)
441 define Package/libc/install_lib
442 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/usr/lib/lib*.a)) $(1)/lib/
443 $(if $(wildcard $(TOOLCHAIN_DIR)/usr/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/usr/lib/libc_so.a $(1)/lib/libc_pic.a)
444 $(if $(wildcard $(TOOLCHAIN_DIR)/usr/lib/gcc/*/*/libgcc.map), \
445 $(CP) $(TOOLCHAIN_DIR)/usr/lib/gcc/*/*/libgcc_pic.a $(1)/lib/libgcc_s_pic.a; \
446 $(CP) $(TOOLCHAIN_DIR)/usr/lib/gcc/*/*/libgcc.map $(1)/lib/libgcc_s_pic.map \
450 define Package/libpthread/install
451 $(INSTALL_DIR) $(1)/lib
452 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread.so.* $(1)/lib/
453 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so $(1)/lib/
456 define Package/libpthread/install_lib
457 $(if $(wildcard $(TOOLCHAIN_DIR)/usr/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/usr/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
460 define Package/librt/install
461 $(INSTALL_DIR) $(1)/lib
462 $(CP) $(TOOLCHAIN_DIR)/lib/librt.so.* $(1)/lib/
463 $(CP) $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so $(1)/lib/
466 define Package/ldd/install
467 $(INSTALL_DIR) $(1)/usr/bin/
468 $(CP) $(TOOLCHAIN_DIR)/usr/bin/ldd $(1)/usr/bin/
471 define Package/ldconfig/install
472 $(INSTALL_DIR) $(1)/sbin/
473 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
478 define Package/libgcc/install
479 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
480 dir=`dirname $$$$file` ; \
481 $(INSTALL_DIR) $(1)/$$$$dir ; \
482 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
486 define Package/libssp/install
487 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
488 dir=`dirname $$$$file` ; \
489 $(INSTALL_DIR) $(1)/$$$$dir ; \
490 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
494 define Package/libstdcpp/install
495 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
496 dir=`dirname $$$$file` ; \
497 $(INSTALL_DIR) $(1)/$$$$dir ; \
498 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
502 define Package/libc/install
503 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
504 dir=`dirname $$$$file` ; \
505 $(INSTALL_DIR) $(1)/$$$$dir ; \
506 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
510 define Package/libpthread/install
511 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
512 dir=`dirname $$$$file` ; \
513 $(INSTALL_DIR) $(1)/$$$$dir ; \
514 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
518 define Package/librt/install
519 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
520 dir=`dirname $$$$file` ; \
521 $(INSTALL_DIR) $(1)/$$$$dir ; \
522 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
526 define Package/ldd/install
527 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
528 dir=`dirname $$$$file` ; \
529 $(INSTALL_DIR) $(1)/$$$$dir ; \
530 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
534 define Package/ldconfig/install
535 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
536 dir=`dirname $$$$file` ; \
537 $(INSTALL_DIR) $(1)/$$$$dir ; \
538 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
545 -include $(PLATFORM_DIR)/base-files.mk
548 $(eval $(call BuildPackage,base-files))
549 $(eval $(call BuildPackage,libc))
550 $(eval $(call BuildPackage,libgcc))
551 $(eval $(call BuildPackage,libssp))
552 $(eval $(call BuildPackage,libstdcpp))
553 $(eval $(call BuildPackage,libpthread))
554 $(eval $(call BuildPackage,librt))
555 $(eval $(call BuildPackage,ldd))
556 $(eval $(call BuildPackage,ldconfig))