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
59 $(call
$(TARGET
)/conffiles
)
62 define Package
/base-files
/description
63 This package contains a base filesystem and system scripts for OpenWrt.
67 define Package
/gcc
/Default
70 URL
:=http
://gcc.gnu.org
/
71 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
76 $(call Package
/gcc
/Default
)
77 TITLE
:=GCC support library
78 DEPENDS
+=@
!(TARGET_avr32||TARGET_coldfire
)
81 define Package
/libgcc
/config
83 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
85 config LIBGCC_ROOT_DIR
87 prompt
"libgcc shared library base directory"
88 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
89 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
90 default
"/" if NATIVE_TOOLCHAIN
92 config LIBGCC_FILE_SPEC
94 prompt
"libgcc shared library files (use wildcards)"
95 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
96 default
"./lib/libgcc_s.so.*"
102 define Package
/libssp
103 $(call Package
/gcc
/Default
)
104 DEPENDS
+=@SSP_SUPPORT
105 TITLE
:=GCC support library
108 define Package
/libssp
/config
110 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
112 config LIBSPP_ROOT_DIR
114 prompt
"libssp shared library base directory"
115 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
116 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
117 default
"/" if NATIVE_TOOLCHAIN
119 config LIBSSP_FILE_SPEC
121 prompt
"libssp shared library files (use wildcards)"
122 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
123 default
"./lib/libssp.so.*"
129 define Package
/libstdcpp
130 $(call Package
/gcc
/Default
)
132 TITLE
:=GNU Standard C
++ Library v3
133 DEPENDS
+=@INSTALL_LIBSTDCPP
136 define Package
/libstdcpp
/config
138 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
140 config LIBSTDCPP_ROOT_DIR
142 prompt
"libstdcpp shared library base directory"
143 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
144 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
145 default
"/" if NATIVE_TOOLCHAIN
147 config LIBSTDCPP_FILE_SPEC
149 prompt
"libstdc++ shared library files (use wildcards)"
150 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
151 default
"./lib/libstdc++.so.*"
157 define Package
/libc
/Default
159 CATEGORY
:=Base system
160 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
161 ifneq ($(TARGET_avr32
)$(TARGET_coldfire
),)
169 $(call Package
/libc
/Default
)
173 define Package
/libc
/config
175 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
179 prompt
"libc shared library base directory"
180 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
181 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
182 default
"/" if NATIVE_TOOLCHAIN
184 config LIBC_FILE_SPEC
186 prompt
"libc shared library files (use wildcards)"
187 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
188 default
"./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
194 define Package
/libpthread
195 $(call Package
/libc
/Default
)
196 TITLE
:=POSIX thread library
200 define Package
/libpthread
/config
202 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
204 config LIBPTHREAD_ROOT_DIR
206 prompt
"libpthread shared library base directory"
207 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
208 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
209 default
"/" if NATIVE_TOOLCHAIN
211 config LIBPTHREAD_FILE_SPEC
213 prompt
"libpthread shared library files (use wildcards)"
214 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
215 default
"./lib/libpthread{-*.so,.so.*}"
222 $(call Package
/libc
/Default
)
223 TITLE
:=POSIX
.1b RealTime extension library
226 define Package
/librt
/config
228 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
230 config LIBRT_ROOT_DIR
232 prompt
"librt shared library base directory"
233 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
234 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
235 default
"/" if NATIVE_TOOLCHAIN
237 config LIBRT_FILE_SPEC
239 prompt
"librt shared library files (use wildcards)"
240 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
241 default
"./lib/librt{-*.so,.so.*}"
248 $(call Package
/libc
/Default
)
251 TITLE
:=LDD trace utility
254 define Package
/ldd
/config
256 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
260 prompt
"ldd trace utility base directory"
261 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
262 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
263 default
"/" if NATIVE_TOOLCHAIN
267 prompt
"ldd trace utility file"
268 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
269 default
"./usr/bin/ldd"
275 define Package
/ldconfig
276 $(call Package
/libc
/Default
)
279 TITLE
:=Shared library path configuration
282 define Package
/ldconfig
/config
284 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
286 config LDCONFIG_ROOT_DIR
288 prompt
"ldconfig base directory"
289 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
290 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
291 default
"/" if NATIVE_TOOLCHAIN
293 config LDCONFIG_FILE_SPEC
295 prompt
"ldconfig file"
296 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
297 default
"./sbin/ldconfig"
303 ifneq ($(CONFIG_PREINITOPT
),)
304 define ImageConfigOptions
305 mkdir
-p
$(1)/lib
/preinit
306 echo
'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib
/preinit
/00_preinit.conf
307 echo
'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib
/preinit
/00_preinit.conf
308 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
309 echo
'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib
/preinit
/00_preinit.conf
310 echo
'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib
/preinit
/00_preinit.conf
311 echo
'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib
/preinit
/00_preinit.conf
312 echo
'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib
/preinit
/00_preinit.conf
313 echo
'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib
/preinit
/00_preinit.conf
314 echo
'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib
/preinit
/00_preinit.conf
315 echo
'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib
/preinit
/00_preinit.conf
316 echo
'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
317 echo
'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
322 mkdir
-p
$(PKG_BUILD_DIR
)
325 define Build
/Compile
/Default
329 $(call Build
/Compile
/Default
)
332 define Package
/base-files
/install
333 $(CP
) .
/files
/* $(1)/
334 if
[ -d
$(GENERIC_PLATFORM_DIR
)/base-files
/.
]; then \
335 $(CP
) $(GENERIC_PLATFORM_DIR
)/base-files
/* $(1)/; \
337 if
[ -d
$(PLATFORM_DIR
)/base-files
/.
]; then \
338 $(CP
) $(PLATFORM_DIR
)/base-files
/* $(1)/; \
340 if
[ -d
$(PLATFORM_DIR
)/base-files-
$(PROFILE
)/.
]; then \
341 $(CP
) $(PLATFORM_DIR
)/base-files-
$(PROFILE
)/* $(1)/; \
343 if
[ -d
$(PLATFORM_DIR
)/$(PROFILE
)/base-files
/.
]; then \
344 $(CP
) $(PLATFORM_DIR
)/$(PROFILE
)/base-files
/* $(1)/; \
346 $(if
$(filter-out $(PLATFORM_DIR
),$(PLATFORM_SUBDIR
)), \
347 if
[ -d
$(PLATFORM_SUBDIR
)/base-files
/.
]; then \
348 $(CP
) $(PLATFORM_SUBDIR
)/base-files
/* $(1)/; \
350 if
[ -d
$(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)/.
]; then \
351 $(CP
) $(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)/* $(1)/; \
353 if
[ -d
$(PLATFORM_SUBDIR
)/$(PROFILE
)/base-files
/.
]; then \
354 $(CP
) $(PLATFORM_SUBDIR
)/$(PROFILE
)/base-files
/* $(1)/; \
357 # Form valid /etc/shadow entries, by copying the user:pw pairs
358 # from /etc/passwd, and adding on pw change data
359 $(if
$(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
), \
360 cut
-d
':' -f
1-2 $(1)/etc
/passwd
> $(1)/etc
/shadow
; \
361 $(SED
) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc
/shadow \
363 $(SED
) 's,$$$$R,$(REVISION),g' $(1)/etc
/banner
364 mkdir
-p
$(1)/CONTROL
366 mkdir
-p
$(1)/etc
/crontabs
367 mkdir
-p
$(1)/etc
/rc.d
368 mkdir
-p
$(1)/overlay
369 mkdir
-p
$(1)/lib
/firmware
370 $(if
$(LIB_SUFFIX
),-ln
-s lib
$(1)/lib
$(LIB_SUFFIX
))
374 mkdir
-p
$(1)/usr
/lib
375 $(if
$(LIB_SUFFIX
),-ln
-s lib
$(1)/usr
/lib
$(LIB_SUFFIX
))
376 mkdir
-p
$(1)/usr
/bin
380 ln
-sf
/proc
/mounts
$(1)/etc
/mtab
384 ln
-sf
/tmp
/resolv.conf
/tmp
/fstab
/tmp
/TZ
$(1)/etc
/
385 $(call ImageConfigOptions
,$(1))
386 $(call Package
/base-files
/install-target
,$(1))
387 for conffile in
$(1)/etc
/config
/*; do \
388 if
[ -f
"$$$$conffile" ]; then \
389 grep
"$$$${conffile##$(1)}" $(1)/CONTROL
/conffiles || \
390 echo
"$$$${conffile##$(1)}" >> $(1)/CONTROL
/conffiles
; \
395 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
397 define Package
/libgcc
/install
398 $(INSTALL_DIR
) $(1)/lib
399 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/
402 define Package
/libssp
/install
403 $(INSTALL_DIR
) $(1)/lib
404 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libssp.so.
* $(1)/lib
/
407 define Package
/libstdcpp
/install
408 $(INSTALL_DIR
) $(1)/usr
/lib
409 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
412 use_libutil
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP
),libutil
)
413 use_libnsl
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS
),libnsl
)
414 use_nsswitch
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH
),libnss_dns libnss_files
)
416 define Package
/glibc
/install
417 $(INSTALL_DIR
) $(1)/lib
419 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
420 $(TOOLCHAIN_DIR
)/lib
/ld-
$(LIBC_SO_VERSION
).so \
422 for file in libanl libc libcidn libcrypt libdl libm
$(use_libnsl
) $(use_nsswitch
) libresolv
$(use_libutil
); do \
424 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
425 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
430 define Package
/eglibc
/install
431 $(call Package
/glibc
/install,$1)
434 define Package
/uClibc
/install
435 $(INSTALL_DIR
) $(1)/lib
437 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc.so.
* \
438 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc-
$(LIBC_SO_VERSION
).so \
441 $(TOOLCHAIN_DIR
)/lib
/libc.so.
* \
442 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
$(LIBC_SO_VERSION
).so \
444 for file in libcrypt libdl libm libnsl libresolv libutil
; do \
446 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
447 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
452 define Package
/libc
/install
453 $(call Package
/$(LIBC
)/install,$1)
456 define Package
/libc
/install_lib
457 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
458 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
459 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
), \
460 $(CP
) $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
$(1)/lib
/libgcc_s_pic.a
; \
461 $(CP
) $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
$(1)/lib
/libgcc_s_pic.map \
465 define Package
/libpthread
/install
466 $(INSTALL_DIR
) $(1)/lib
468 $(TOOLCHAIN_DIR
)/lib
/libpthread.so.
* \
469 $(TOOLCHAIN_DIR
)/lib
/libpthread-
$(LIBC_SO_VERSION
).so \
473 define Package
/libpthread
/install_lib
474 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
477 define Package
/librt
/install
478 $(INSTALL_DIR
) $(1)/lib
480 $(TOOLCHAIN_DIR
)/lib
/librt.so.
* \
481 $(TOOLCHAIN_DIR
)/lib
/librt-
$(LIBC_SO_VERSION
).so \
485 define Package
/ldd
/install
486 $(INSTALL_DIR
) $(1)/usr
/bin
/
487 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
490 define Package
/ldconfig
/install
491 $(INSTALL_DIR
) $(1)/sbin
/
492 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
497 define Package
/libgcc
/install
498 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
499 dir=`dirname $$$$file` ; \
500 $(INSTALL_DIR
) $(1)/$$$$dir ; \
501 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
505 define Package
/libssp
/install
506 for file in
$(call qstrip
,$(CONFIG_LIBSSP_FILE_SPEC
)); do \
507 dir=`dirname $$$$file` ; \
508 $(INSTALL_DIR
) $(1)/$$$$dir ; \
509 $(CP
) $(call qstrip
,$(CONFIG_LIBSSP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
513 define Package
/libstdcpp
/install
514 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
515 dir=`dirname $$$$file` ; \
516 $(INSTALL_DIR
) $(1)/$$$$dir ; \
517 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
521 define Package
/libc
/install
522 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
523 dir=`dirname $$$$file` ; \
524 $(INSTALL_DIR
) $(1)/$$$$dir ; \
525 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
529 define Package
/libpthread
/install
530 for file in
$(call qstrip
,$(CONFIG_LIBPTHREAD_FILE_SPEC
)); do \
531 dir=`dirname $$$$file` ; \
532 $(INSTALL_DIR
) $(1)/$$$$dir ; \
533 $(CP
) $(call qstrip
,$(CONFIG_LIBPTHREAD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
537 define Package
/librt
/install
538 for file in
$(call qstrip
,$(CONFIG_LIBRT_FILE_SPEC
)); do \
539 dir=`dirname $$$$file` ; \
540 $(INSTALL_DIR
) $(1)/$$$$dir ; \
541 $(CP
) $(call qstrip
,$(CONFIG_LIBRT_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
545 define Package
/ldd
/install
546 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
547 dir=`dirname $$$$file` ; \
548 $(INSTALL_DIR
) $(1)/$$$$dir ; \
549 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
553 define Package
/ldconfig
/install
554 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
555 dir=`dirname $$$$file` ; \
556 $(INSTALL_DIR
) $(1)/$$$$dir ; \
557 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
564 -include $(PLATFORM_DIR
)/base-files.mk
567 $(eval
$(call BuildPackage
,base-files
))
568 $(eval
$(call BuildPackage
,libc
))
569 $(eval
$(call BuildPackage
,libgcc
))
570 $(eval
$(call BuildPackage
,libssp
))
571 $(eval
$(call BuildPackage
,libstdcpp
))
572 $(eval
$(call BuildPackage
,libpthread
))
573 $(eval
$(call BuildPackage
,librt
))
574 $(eval
$(call BuildPackage
,ldd
))
575 $(eval
$(call BuildPackage
,ldconfig
))