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
/
16 PKG_BUILD_DEPENDS
:=opkg
/host
18 include $(INCLUDE_DIR
)/package.mk
22 ifneq ($(wildcard $(PLATFORM_DIR
)/base-files-
$(PROFILE
) $(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)),)
23 TARGET
:=$(TARGET
)-$(PROFILE
)
25 LIBGCC_VERSION
:=$(GCC_VERSION
)
26 ifneq ($(findstring $(ARCH
) , mips64 x86_64
),)
30 LIBC_VERSION
:=<LIBC_VERSION
>
31 LIBGCC_VERSION
:=<LIBGCC_VERSION
>
34 define Package
/base-files
37 TITLE
:=Base filesystem for OpenWrt
38 URL
:=http
://openwrt.org
/
39 VERSION
:=$(PKG_RELEASE
)-$(REVISION
)
40 $(call Config
,network.lan.proto
,string
,static
,LAN Protocol
)
41 $(call Config
,network.lan.ipaddr
,ip
,192.168.1.1,LAN IP Address
)
42 $(call Config
,network.lan.netmask
,netmask
,255.255.255.0,LAN Network Mask
)
43 $(call Config
,network.lan.gateway
,ip
,,LAN Gateway
)
44 $(call Config
,network.lan.dns
,ip
,,LAN DNS server
)
47 define Package
/base-files
/conffiles
56 $(call
$(TARGET
)/conffiles
)
59 define Package
/base-files
/description
60 This package contains a base filesystem and system scripts for OpenWrt.
64 define Package
/gcc
/Default
67 URL
:=http
://gcc.gnu.org
/
68 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
73 $(call Package
/gcc
/Default
)
74 TITLE
:=GCC support library
75 DEPENDS
+=@
!(TARGET_avr32||TARGET_coldfire
)
78 define Package
/libgcc
/config
80 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
82 config LIBGCC_ROOT_DIR
84 prompt
"libgcc shared library base directory"
85 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
86 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
87 default
"/" if NATIVE_TOOLCHAIN
89 config LIBGCC_FILE_SPEC
91 prompt
"libgcc shared library files (use wildcards)"
92 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
93 default
"./lib/libgcc_s.so.*"
100 $(call Package
/gcc
/Default
)
101 DEPENDS
+=@SSP_SUPPORT
102 TITLE
:=GCC support library
105 define Package
/libssp
/config
107 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
109 config LIBSPP_ROOT_DIR
111 prompt
"libssp shared library base directory"
112 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
113 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
114 default
"/" if NATIVE_TOOLCHAIN
116 config LIBSSP_FILE_SPEC
118 prompt
"libssp shared library files (use wildcards)"
119 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
120 default
"./lib/libssp.so.*"
126 define Package
/libstdcpp
127 $(call Package
/gcc
/Default
)
129 TITLE
:=GNU Standard C
++ Library v3
130 DEPENDS
+=@INSTALL_LIBSTDCPP
133 define Package
/libstdcpp
/config
135 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
137 config LIBSTDCPP_ROOT_DIR
139 prompt
"libstdcpp shared library base directory"
140 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
141 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
142 default
"/" if NATIVE_TOOLCHAIN
144 config LIBSTDCPP_FILE_SPEC
146 prompt
"libstdc++ shared library files (use wildcards)"
147 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
148 default
"./lib/libstdc++.so.*"
154 define Package
/libc
/Default
156 CATEGORY
:=Base system
157 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
158 ifneq ($(TARGET_avr32
)$(TARGET_coldfire
),)
166 $(call Package
/libc
/Default
)
170 define Package
/libc
/config
172 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
176 prompt
"libc shared library base directory"
177 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
178 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
179 default
"/" if NATIVE_TOOLCHAIN
181 config LIBC_FILE_SPEC
183 prompt
"libc shared library files (use wildcards)"
184 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
185 default
"./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
191 define Package
/libpthread
192 $(call Package
/libc
/Default
)
193 TITLE
:=POSIX thread library
197 define Package
/libpthread
/config
199 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
201 config LIBPTHREAD_ROOT_DIR
203 prompt
"libpthread shared library base directory"
204 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
205 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
206 default
"/" if NATIVE_TOOLCHAIN
208 config LIBPTHREAD_FILE_SPEC
210 prompt
"libpthread shared library files (use wildcards)"
211 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
212 default
"./lib/libpthread{-*.so,.so.*}"
219 $(call Package
/libc
/Default
)
220 TITLE
:=POSIX
.1b RealTime extension library
223 define Package
/librt
/config
225 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
227 config LIBRT_ROOT_DIR
229 prompt
"librt shared library base directory"
230 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
231 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
232 default
"/" if NATIVE_TOOLCHAIN
234 config LIBRT_FILE_SPEC
236 prompt
"librt shared library files (use wildcards)"
237 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
238 default
"./lib/librt{-*.so,.so.*}"
245 $(call Package
/libc
/Default
)
248 TITLE
:=LDD trace utility
251 define Package
/ldd
/config
253 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
257 prompt
"ldd trace utility base directory"
258 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
259 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
260 default
"/" if NATIVE_TOOLCHAIN
264 prompt
"ldd trace utility file"
265 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
266 default
"./usr/bin/ldd"
272 define Package
/ldconfig
273 $(call Package
/libc
/Default
)
276 TITLE
:=Shared library path configuration
279 define Package
/ldconfig
/config
281 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
283 config LDCONFIG_ROOT_DIR
285 prompt
"ldconfig base directory"
286 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
287 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
288 default
"/" if NATIVE_TOOLCHAIN
290 config LDCONFIG_FILE_SPEC
292 prompt
"ldconfig file"
293 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
294 default
"./sbin/ldconfig"
300 ifneq ($(CONFIG_PREINITOPT
),)
301 define ImageConfigOptions
302 mkdir
-p
$(1)/lib
/preinit
303 echo
'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib
/preinit
/00_preinit.conf
304 echo
'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib
/preinit
/00_preinit.conf
305 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
306 echo
'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib
/preinit
/00_preinit.conf
307 echo
'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib
/preinit
/00_preinit.conf
308 echo
'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib
/preinit
/00_preinit.conf
309 echo
'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib
/preinit
/00_preinit.conf
310 echo
'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib
/preinit
/00_preinit.conf
311 echo
'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib
/preinit
/00_preinit.conf
312 echo
'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib
/preinit
/00_preinit.conf
313 echo
'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
314 echo
'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
319 mkdir
-p
$(PKG_BUILD_DIR
)
322 define Build
/Compile
/Default
326 $(call Build
/Compile
/Default
)
329 define Package
/base-files
/install
330 $(CP
) .
/files
/* $(1)/
331 if
[ -d
$(GENERIC_PLATFORM_DIR
)/base-files
/.
]; then \
332 $(CP
) $(GENERIC_PLATFORM_DIR
)/base-files
/* $(1)/; \
334 if
[ -d
$(PLATFORM_DIR
)/base-files
/.
]; then \
335 $(CP
) $(PLATFORM_DIR
)/base-files
/* $(1)/; \
337 if
[ -d
$(PLATFORM_DIR
)/base-files-
$(PROFILE
)/.
]; then \
338 $(CP
) $(PLATFORM_DIR
)/base-files-
$(PROFILE
)/* $(1)/; \
340 if
[ -d
$(PLATFORM_DIR
)/$(PROFILE
)/base-files
/.
]; then \
341 $(CP
) $(PLATFORM_DIR
)/$(PROFILE
)/base-files
/* $(1)/; \
343 $(if
$(filter-out $(PLATFORM_DIR
),$(PLATFORM_SUBDIR
)), \
344 if
[ -d
$(PLATFORM_SUBDIR
)/base-files
/.
]; then \
345 $(CP
) $(PLATFORM_SUBDIR
)/base-files
/* $(1)/; \
347 if
[ -d
$(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)/.
]; then \
348 $(CP
) $(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)/* $(1)/; \
350 if
[ -d
$(PLATFORM_SUBDIR
)/$(PROFILE
)/base-files
/.
]; then \
351 $(CP
) $(PLATFORM_SUBDIR
)/$(PROFILE
)/base-files
/* $(1)/; \
354 # Form valid /etc/shadow entries, by copying the user:pw pairs
355 # from /etc/passwd, and adding on pw change data
356 $(if
$(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
), \
357 cut
-d
':' -f
1-2 $(1)/etc
/passwd
> $(1)/etc
/shadow
; \
358 $(SED
) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc
/shadow \
360 $(SED
) 's,$$$$R,$(REVISION),g' $(1)/etc
/banner
361 mkdir
-p
$(1)/CONTROL
363 mkdir
-p
$(1)/etc
/crontabs
364 mkdir
-p
$(1)/etc
/rc.d
365 mkdir
-p
$(1)/overlay
366 mkdir
-p
$(1)/lib
/firmware
367 $(if
$(LIB_SUFFIX
),-ln
-s lib
$(1)/lib
$(LIB_SUFFIX
))
371 mkdir
-p
$(1)/usr
/lib
372 $(if
$(LIB_SUFFIX
),-ln
-s lib
$(1)/usr
/lib
$(LIB_SUFFIX
))
373 mkdir
-p
$(1)/usr
/bin
377 ln
-sf
/proc
/mounts
$(1)/etc
/mtab
381 ln
-sf
/tmp
/resolv.conf
/tmp
/fstab
/tmp
/TZ
$(1)/etc
/
382 $(call ImageConfigOptions
,$(1))
383 $(call Package
/base-files
/install-target
,$(1))
384 for conffile in
$(1)/etc
/config
/*; do \
385 if
[ -f
"$$$$conffile" ]; then \
386 grep
"$$$${conffile##$(1)}" $(1)/CONTROL
/conffiles || \
387 echo
"$$$${conffile##$(1)}" >> $(1)/CONTROL
/conffiles
; \
392 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
394 define Package
/libgcc
/install
395 $(INSTALL_DIR
) $(1)/lib
396 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/
399 define Package
/libssp
/install
400 $(INSTALL_DIR
) $(1)/lib
401 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libssp.so.
* $(1)/lib
/
404 define Package
/libstdcpp
/install
405 $(INSTALL_DIR
) $(1)/usr
/lib
406 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
409 use_libutil
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP
),libutil
)
410 use_libnsl
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS
),libnsl
)
411 use_nsswitch
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH
),libnss_dns libnss_files
)
413 define Package
/glibc
/install
414 $(INSTALL_DIR
) $(1)/lib
416 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
417 $(TOOLCHAIN_DIR
)/lib
/ld-
$(LIBC_SO_VERSION
).so \
419 for file in libanl libc libcidn libcrypt libdl libm
$(use_libnsl
) $(use_nsswitch
) libresolv
$(use_libutil
); do \
421 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
422 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
427 define Package
/eglibc
/install
428 $(call Package
/glibc
/install,$1)
431 define Package
/uClibc
/install
432 $(INSTALL_DIR
) $(1)/lib
434 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc.so.
* \
435 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc-
$(LIBC_SO_VERSION
).so \
438 $(TOOLCHAIN_DIR
)/lib
/libc.so.
* \
439 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
$(LIBC_SO_VERSION
).so \
441 for file in libcrypt libdl libm libnsl libresolv libutil
; do \
443 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
444 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
449 define Package
/libc
/install
450 $(call Package
/$(LIBC
)/install,$1)
453 define Package
/libc
/install_lib
454 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
455 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
456 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
), \
457 $(CP
) $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
$(1)/lib
/libgcc_s_pic.a
; \
458 $(CP
) $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
$(1)/lib
/libgcc_s_pic.map \
462 define Package
/libpthread
/install
463 $(INSTALL_DIR
) $(1)/lib
465 $(TOOLCHAIN_DIR
)/lib
/libpthread.so.
* \
466 $(TOOLCHAIN_DIR
)/lib
/libpthread-
$(LIBC_SO_VERSION
).so \
470 define Package
/libpthread
/install_lib
471 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
474 define Package
/librt
/install
475 $(INSTALL_DIR
) $(1)/lib
477 $(TOOLCHAIN_DIR
)/lib
/librt.so.
* \
478 $(TOOLCHAIN_DIR
)/lib
/librt-
$(LIBC_SO_VERSION
).so \
482 define Package
/ldd
/install
483 $(INSTALL_DIR
) $(1)/usr
/bin
/
484 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
487 define Package
/ldconfig
/install
488 $(INSTALL_DIR
) $(1)/sbin
/
489 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
494 define Package
/libgcc
/install
495 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
496 dir=`dirname $$$$file` ; \
497 $(INSTALL_DIR
) $(1)/$$$$dir ; \
498 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
502 define Package
/libssp
/install
503 for file in
$(call qstrip
,$(CONFIG_LIBSSP_FILE_SPEC
)); do \
504 dir=`dirname $$$$file` ; \
505 $(INSTALL_DIR
) $(1)/$$$$dir ; \
506 $(CP
) $(call qstrip
,$(CONFIG_LIBSSP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
510 define Package
/libstdcpp
/install
511 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
512 dir=`dirname $$$$file` ; \
513 $(INSTALL_DIR
) $(1)/$$$$dir ; \
514 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
518 define Package
/libc
/install
519 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
520 dir=`dirname $$$$file` ; \
521 $(INSTALL_DIR
) $(1)/$$$$dir ; \
522 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
526 define Package
/libpthread
/install
527 for file in
$(call qstrip
,$(CONFIG_LIBPTHREAD_FILE_SPEC
)); do \
528 dir=`dirname $$$$file` ; \
529 $(INSTALL_DIR
) $(1)/$$$$dir ; \
530 $(CP
) $(call qstrip
,$(CONFIG_LIBPTHREAD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
534 define Package
/librt
/install
535 for file in
$(call qstrip
,$(CONFIG_LIBRT_FILE_SPEC
)); do \
536 dir=`dirname $$$$file` ; \
537 $(INSTALL_DIR
) $(1)/$$$$dir ; \
538 $(CP
) $(call qstrip
,$(CONFIG_LIBRT_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
542 define Package
/ldd
/install
543 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
544 dir=`dirname $$$$file` ; \
545 $(INSTALL_DIR
) $(1)/$$$$dir ; \
546 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
550 define Package
/ldconfig
/install
551 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
552 dir=`dirname $$$$file` ; \
553 $(INSTALL_DIR
) $(1)/$$$$dir ; \
554 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
561 -include $(PLATFORM_DIR
)/base-files.mk
564 $(eval
$(call BuildPackage
,base-files
))
565 $(eval
$(call BuildPackage
,libc
))
566 $(eval
$(call BuildPackage
,libgcc
))
567 $(eval
$(call BuildPackage
,libssp
))
568 $(eval
$(call BuildPackage
,libstdcpp
))
569 $(eval
$(call BuildPackage
,libpthread
))
570 $(eval
$(call BuildPackage
,librt
))
571 $(eval
$(call BuildPackage
,ldd
))
572 $(eval
$(call BuildPackage
,ldconfig
))