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
57 $(call
$(TARGET
)/conffiles
)
60 define Package
/base-files
/description
61 This package contains a base filesystem and system scripts for OpenWrt.
65 define Package
/gcc
/Default
68 URL
:=http
://gcc.gnu.org
/
69 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
74 $(call Package
/gcc
/Default
)
75 TITLE
:=GCC support library
76 DEPENDS
+=@
!(TARGET_avr32||TARGET_coldfire
)
79 define Package
/libgcc
/config
81 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
83 config LIBGCC_ROOT_DIR
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
90 config LIBGCC_FILE_SPEC
92 prompt
"libgcc shared library files (use wildcards)"
93 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
94 default
"./lib/libgcc_s.so.*"
100 define Package
/libssp
101 $(call Package
/gcc
/Default
)
102 DEPENDS
+=@SSP_SUPPORT
103 TITLE
:=GCC support library
106 define Package
/libssp
/config
108 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
110 config LIBSPP_ROOT_DIR
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
117 config LIBSSP_FILE_SPEC
119 prompt
"libssp shared library files (use wildcards)"
120 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
121 default
"./lib/libssp.so.*"
127 define Package
/libstdcpp
128 $(call Package
/gcc
/Default
)
130 TITLE
:=GNU Standard C
++ Library v3
131 DEPENDS
+=@INSTALL_LIBSTDCPP
134 define Package
/libstdcpp
/config
136 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
138 config LIBSTDCPP_ROOT_DIR
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
145 config LIBSTDCPP_FILE_SPEC
147 prompt
"libstdc++ shared library files (use wildcards)"
148 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
149 default
"./lib/libstdc++.so.*"
155 define Package
/libc
/Default
157 CATEGORY
:=Base system
158 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
159 ifneq ($(TARGET_avr32
)$(TARGET_coldfire
),)
167 $(call Package
/libc
/Default
)
171 define Package
/libc
/config
173 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
177 prompt
"libc shared library base directory"
178 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
179 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
180 default
"/" if NATIVE_TOOLCHAIN
182 config LIBC_FILE_SPEC
184 prompt
"libc shared library files (use wildcards)"
185 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
186 default
"./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
192 define Package
/libpthread
193 $(call Package
/libc
/Default
)
194 TITLE
:=POSIX thread library
198 define Package
/libpthread
/config
200 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
202 config LIBPTHREAD_ROOT_DIR
204 prompt
"libpthread shared library base directory"
205 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
206 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
207 default
"/" if NATIVE_TOOLCHAIN
209 config LIBPTHREAD_FILE_SPEC
211 prompt
"libpthread shared library files (use wildcards)"
212 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
213 default
"./lib/libpthread{-*.so,.so.*}"
220 $(call Package
/libc
/Default
)
221 TITLE
:=POSIX
.1b RealTime extension library
224 define Package
/librt
/config
226 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
228 config LIBRT_ROOT_DIR
230 prompt
"librt shared library base directory"
231 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
232 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
233 default
"/" if NATIVE_TOOLCHAIN
235 config LIBRT_FILE_SPEC
237 prompt
"librt shared library files (use wildcards)"
238 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
239 default
"./lib/librt{-*.so,.so.*}"
246 $(call Package
/libc
/Default
)
249 TITLE
:=LDD trace utility
252 define Package
/ldd
/config
254 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
258 prompt
"ldd trace utility base directory"
259 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
260 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
261 default
"/" if NATIVE_TOOLCHAIN
265 prompt
"ldd trace utility file"
266 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
267 default
"./usr/bin/ldd"
273 define Package
/ldconfig
274 $(call Package
/libc
/Default
)
277 TITLE
:=Shared library path configuration
280 define Package
/ldconfig
/config
282 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
284 config LDCONFIG_ROOT_DIR
286 prompt
"ldconfig base directory"
287 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
288 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
289 default
"/" if NATIVE_TOOLCHAIN
291 config LDCONFIG_FILE_SPEC
293 prompt
"ldconfig file"
294 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
295 default
"./sbin/ldconfig"
301 ifneq ($(CONFIG_PREINITOPT
),)
302 define ImageConfigOptions
303 mkdir
-p
$(1)/lib
/preinit
304 echo
'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib
/preinit
/00_preinit.conf
305 echo
'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib
/preinit
/00_preinit.conf
306 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
307 echo
'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib
/preinit
/00_preinit.conf
308 echo
'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib
/preinit
/00_preinit.conf
309 echo
'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib
/preinit
/00_preinit.conf
310 echo
'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib
/preinit
/00_preinit.conf
311 echo
'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib
/preinit
/00_preinit.conf
312 echo
'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib
/preinit
/00_preinit.conf
313 echo
'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib
/preinit
/00_preinit.conf
314 echo
'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
315 echo
'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
320 mkdir
-p
$(PKG_BUILD_DIR
)
323 define Build
/Compile
/Default
327 $(call Build
/Compile
/Default
)
330 define Package
/base-files
/install
331 $(CP
) .
/files
/* $(1)/
332 if
[ -d
$(GENERIC_PLATFORM_DIR
)/base-files
/.
]; then \
333 $(CP
) $(GENERIC_PLATFORM_DIR
)/base-files
/* $(1)/; \
335 if
[ -d
$(PLATFORM_DIR
)/base-files
/.
]; then \
336 $(CP
) $(PLATFORM_DIR
)/base-files
/* $(1)/; \
338 if
[ -d
$(PLATFORM_DIR
)/base-files-
$(PROFILE
)/.
]; then \
339 $(CP
) $(PLATFORM_DIR
)/base-files-
$(PROFILE
)/* $(1)/; \
341 if
[ -d
$(PLATFORM_DIR
)/$(PROFILE
)/base-files
/.
]; then \
342 $(CP
) $(PLATFORM_DIR
)/$(PROFILE
)/base-files
/* $(1)/; \
344 $(if
$(filter-out $(PLATFORM_DIR
),$(PLATFORM_SUBDIR
)), \
345 if
[ -d
$(PLATFORM_SUBDIR
)/base-files
/.
]; then \
346 $(CP
) $(PLATFORM_SUBDIR
)/base-files
/* $(1)/; \
348 if
[ -d
$(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)/.
]; then \
349 $(CP
) $(PLATFORM_SUBDIR
)/base-files-
$(PROFILE
)/* $(1)/; \
351 if
[ -d
$(PLATFORM_SUBDIR
)/$(PROFILE
)/base-files
/.
]; then \
352 $(CP
) $(PLATFORM_SUBDIR
)/$(PROFILE
)/base-files
/* $(1)/; \
355 # Form valid /etc/shadow entries, by copying the user:pw pairs
356 # from /etc/passwd, and adding on pw change data
357 $(if
$(CONFIG_BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
), \
358 cut
-d
':' -f
1-2 $(1)/etc
/passwd
> $(1)/etc
/shadow
; \
359 $(SED
) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc
/shadow \
361 $(SED
) 's,$$$$R,$(REVISION),g' $(1)/etc
/banner
362 mkdir
-p
$(1)/CONTROL
364 mkdir
-p
$(1)/etc
/crontabs
365 mkdir
-p
$(1)/etc
/rc.d
366 mkdir
-p
$(1)/overlay
367 mkdir
-p
$(1)/lib
/firmware
368 $(if
$(LIB_SUFFIX
),-ln
-s lib
$(1)/lib
$(LIB_SUFFIX
))
372 mkdir
-p
$(1)/usr
/lib
373 $(if
$(LIB_SUFFIX
),-ln
-s lib
$(1)/usr
/lib
$(LIB_SUFFIX
))
374 mkdir
-p
$(1)/usr
/bin
378 ln
-sf
/proc
/mounts
$(1)/etc
/mtab
382 ln
-sf
/tmp
/resolv.conf
/tmp
/fstab
/tmp
/TZ
$(1)/etc
/
383 $(call ImageConfigOptions
,$(1))
384 $(call Package
/base-files
/install-target
,$(1))
385 for conffile in
$(1)/etc
/config
/*; do \
386 if
[ -f
"$$$$conffile" ]; then \
387 grep
"$$$${conffile##$(1)}" $(1)/CONTROL
/conffiles || \
388 echo
"$$$${conffile##$(1)}" >> $(1)/CONTROL
/conffiles
; \
393 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
395 define Package
/libgcc
/install
396 $(INSTALL_DIR
) $(1)/lib
397 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/
400 define Package
/libssp
/install
401 $(INSTALL_DIR
) $(1)/lib
402 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libssp.so.
* $(1)/lib
/
405 define Package
/libstdcpp
/install
406 $(INSTALL_DIR
) $(1)/usr
/lib
407 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
410 use_libutil
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP
),libutil
)
411 use_libnsl
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS
),libnsl
)
412 use_nsswitch
=$(if
$(CONFIG_USE_GLIBC
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH
),libnss_dns libnss_files
)
414 define Package
/glibc
/install
415 $(INSTALL_DIR
) $(1)/lib
417 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
418 $(TOOLCHAIN_DIR
)/lib
/ld-
$(LIBC_SO_VERSION
).so \
420 for file in libanl libc libcidn libcrypt libdl libm
$(use_libnsl
) $(use_nsswitch
) libresolv
$(use_libutil
); do \
422 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
423 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
428 define Package
/eglibc
/install
429 $(call Package
/glibc
/install,$1)
432 define Package
/uClibc
/install
433 $(INSTALL_DIR
) $(1)/lib
435 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc.so.
* \
436 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc-
$(LIBC_SO_VERSION
).so \
439 $(TOOLCHAIN_DIR
)/lib
/libc.so.
* \
440 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
$(LIBC_SO_VERSION
).so \
442 for file in libcrypt libdl libm libnsl libresolv libutil
; do \
444 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
445 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
450 define Package
/libc
/install
451 $(call Package
/$(LIBC
)/install,$1)
454 define Package
/libc
/install_lib
455 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
456 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
457 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
), \
458 $(CP
) $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
$(1)/lib
/libgcc_s_pic.a
; \
459 $(CP
) $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
$(1)/lib
/libgcc_s_pic.map \
463 define Package
/libpthread
/install
464 $(INSTALL_DIR
) $(1)/lib
466 $(TOOLCHAIN_DIR
)/lib
/libpthread.so.
* \
467 $(TOOLCHAIN_DIR
)/lib
/libpthread-
$(LIBC_SO_VERSION
).so \
471 define Package
/libpthread
/install_lib
472 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
475 define Package
/librt
/install
476 $(INSTALL_DIR
) $(1)/lib
478 $(TOOLCHAIN_DIR
)/lib
/librt.so.
* \
479 $(TOOLCHAIN_DIR
)/lib
/librt-
$(LIBC_SO_VERSION
).so \
483 define Package
/ldd
/install
484 $(INSTALL_DIR
) $(1)/usr
/bin
/
485 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
488 define Package
/ldconfig
/install
489 $(INSTALL_DIR
) $(1)/sbin
/
490 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
495 define Package
/libgcc
/install
496 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
497 dir=`dirname $$$$file` ; \
498 $(INSTALL_DIR
) $(1)/$$$$dir ; \
499 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
503 define Package
/libssp
/install
504 for file in
$(call qstrip
,$(CONFIG_LIBSSP_FILE_SPEC
)); do \
505 dir=`dirname $$$$file` ; \
506 $(INSTALL_DIR
) $(1)/$$$$dir ; \
507 $(CP
) $(call qstrip
,$(CONFIG_LIBSSP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
511 define Package
/libstdcpp
/install
512 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
513 dir=`dirname $$$$file` ; \
514 $(INSTALL_DIR
) $(1)/$$$$dir ; \
515 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
519 define Package
/libc
/install
520 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
521 dir=`dirname $$$$file` ; \
522 $(INSTALL_DIR
) $(1)/$$$$dir ; \
523 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
527 define Package
/libpthread
/install
528 for file in
$(call qstrip
,$(CONFIG_LIBPTHREAD_FILE_SPEC
)); do \
529 dir=`dirname $$$$file` ; \
530 $(INSTALL_DIR
) $(1)/$$$$dir ; \
531 $(CP
) $(call qstrip
,$(CONFIG_LIBPTHREAD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
535 define Package
/librt
/install
536 for file in
$(call qstrip
,$(CONFIG_LIBRT_FILE_SPEC
)); do \
537 dir=`dirname $$$$file` ; \
538 $(INSTALL_DIR
) $(1)/$$$$dir ; \
539 $(CP
) $(call qstrip
,$(CONFIG_LIBRT_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
543 define Package
/ldd
/install
544 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
545 dir=`dirname $$$$file` ; \
546 $(INSTALL_DIR
) $(1)/$$$$dir ; \
547 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
551 define Package
/ldconfig
/install
552 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
553 dir=`dirname $$$$file` ; \
554 $(INSTALL_DIR
) $(1)/$$$$dir ; \
555 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
562 -include $(PLATFORM_DIR
)/base-files.mk
565 $(eval
$(call BuildPackage
,base-files
))
566 $(eval
$(call BuildPackage
,libc
))
567 $(eval
$(call BuildPackage
,libgcc
))
568 $(eval
$(call BuildPackage
,libssp
))
569 $(eval
$(call BuildPackage
,libstdcpp
))
570 $(eval
$(call BuildPackage
,libpthread
))
571 $(eval
$(call BuildPackage
,librt
))
572 $(eval
$(call BuildPackage
,ldd
))
573 $(eval
$(call BuildPackage
,ldconfig
))