Makefile 14 KB

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