create /etc/fstab on boot (closes #3458)
[openwrt/staging/chunkeey.git] / package / base-files / Makefile
1 #
2 # Copyright (C) 2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11
12 PKG_NAME:=base-files
13 PKG_RELEASE:=13
14
15 PKG_FILE_DEPEND:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
16
17 include $(INCLUDE_DIR)/package.mk
18
19 ifneq ($(DUMP),1)
20 TARGET:=-$(BOARD)
21 ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
22 TARGET:=$(TARGET)-$(PROFILE)
23 endif
24 LIBGCC_VERSION:=$(GCC_VERSION)
25 else
26 UCLIBC_VERSION:=<UCLIBC_VERSION>
27 LIBGCC_VERSION:=<LIBGCC_VERSION>
28 endif
29
30 CONFIG_PACKAGE_base-files$(TARGET):=$(CONFIG_PACKAGE_base-files)
31
32 define Package/base-files$(TARGET)
33 SECTION:=base
34 CATEGORY:=Base system
35 TITLE:=Base filesystem for OpenWrt
36 URL:=http://openwrt.org/
37 VERSION:=$(PKG_RELEASE)-$(REVISION)
38 $(call Config,network.lan.proto,string,static,LAN Protocol)
39 $(call Config,network.lan.ipaddr,ip,192.168.1.1,LAN IP Address)
40 $(call Config,network.lan.netmask,netmask,255.255.255.0,LAN Network Mask)
41 $(call Config,network.lan.gateway,ip,,LAN Gateway)
42 $(call Config,network.lan.dns,ip,,LAN DNS server)
43 endef
44
45 define Package/base-files$(TARGET)/conffiles
46 /etc/banner
47 /etc/hosts
48 /etc/inittab
49 /etc/group
50 /etc/passwd
51 /etc/profile
52 /etc/shells
53 /etc/ipkg.conf
54 /etc/sysctl.conf
55 $(call $(TARGET)/conffiles)
56 endef
57
58 define Package/base-files$(TARGET)/description
59 This package contains a base filesystem and system scripts for OpenWrt.
60 endef
61
62 define Package/gcc/Default
63 SECTION:=libs
64 CATEGORY:=Base system
65 DEPENDS:=@!NATIVE_TOOLCHAIN
66 URL:=http://gcc.gnu.org/
67 VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
68 endef
69
70 define Package/libgcc
71 $(call Package/gcc/Default)
72 TITLE:=GCC support library
73 DEPENDS:=@!TARGET_avr32 @!NATIVE_TOOLCHAIN
74 endef
75
76 define Package/libssp
77 $(call Package/gcc/Default)
78 TITLE:=GCC support library
79 endef
80
81 define Package/libstdcpp
82 $(call Package/gcc/Default)
83 NAME:=libstdc++
84 TITLE:=GNU Standard C++ Library v3
85 DEPENDS:=@!NATIVE_TOOLCHAIN&&@INSTALL_LIBSTDCPP
86 endef
87
88 define Package/uclibc/Default
89 SECTION:=libs
90 CATEGORY:=Base system
91 DEPENDS:=@!NATIVE_TOOLCHAIN
92 URL:=http://uclibc.org/
93 VERSION:=$(UCLIBC_VERSION)$(UCLIBC_PATCHVER)-$(PKG_RELEASE)
94 endef
95
96 define Package/libpthread
97 $(call Package/uclibc/Default)
98 TITLE:=POSIX thread library
99 endef
100
101 define Package/uclibc
102 $(call Package/uclibc/Default)
103 TITLE:=C library embedded systems
104 endef
105
106 define Package/ldd
107 $(call Package/uclibc/Default)
108 TITLE:=LDD trace utility
109 endef
110
111 define Package/ldconfig
112 $(call Package/uclibc/Default)
113 TITLE:=Shared library path configuration
114 endef
115
116 define Build/Prepare
117 mkdir -p $(PKG_BUILD_DIR)
118 endef
119
120 define Build/Compile/Default
121 endef
122
123 define Build/Compile
124 $(call Build/Compile/Default)
125 endef
126
127 define Package/base-files$(TARGET)/install
128 $(CP) ./files/* $(1)/
129 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
130 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
131 fi
132 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
133 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
134 fi
135 if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
136 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
137 fi
138 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
139 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
140 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
141 fi; \
142 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
143 $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
144 fi \
145 )
146 $(SED) 's,$$$$R,$(REVISION),g' $(1)/etc/banner
147 $(SED) 's,$$$$S,$(BOARD),g' -e 's,$$$$A,$(ARCH),g' $(1)/etc/ipkg.conf
148 mkdir -p $(1)/dev
149 mkdir -p $(1)/etc/crontabs
150 mkdir -p $(1)/jffs
151 mkdir -p $(1)/lib/firmware
152 mkdir -p $(1)/mnt
153 mkdir -p $(1)/proc
154 mkdir -p $(1)/tmp
155 mkdir -p $(1)/usr/lib
156 mkdir -p $(1)/usr/bin
157 mkdir -p $(1)/sys
158 mkdir -p $(1)/www
159 mkdir -p $(1)/root
160 ln -sf /proc/mounts $(1)/etc/mtab
161 rm -f $(1)/var
162 ln -sf /tmp $(1)/var
163 mkdir -p $(1)/etc
164 ln -sf /tmp/resolv.conf /tmp/fstab $(1)/etc/
165 $(call Package/base-files/install-target,$(1))
166 for conffile in $(1)/etc/config/*; do \
167 if [ -f "$$$$conffile" ]; then \
168 grep "$$$$conffile" $(1)/CONTROL/conffiles || \
169 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
170 fi \
171 done
172 endef
173
174 define Package/libgcc/install
175 $(INSTALL_DIR) $(1)/lib
176 $(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/
177 endef
178
179 ifeq ($(word 1,$(subst ., ,$(LIBGCC_VERSION))),4)
180 define Package/libssp/install
181 $(INSTALL_DIR) $(1)/lib
182 $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
183 endef
184 endif
185
186 define Package/libstdcpp/install
187 $(INSTALL_DIR) $(1)/lib
188 $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/lib/
189 endef
190
191 define Package/libpthread/install
192 $(INSTALL_DIR) $(1)/lib
193 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread.so.* $(1)/lib/
194 $(CP) $(TOOLCHAIN_DIR)/lib/libpthread-$(UCLIBC_VERSION).so $(1)/lib/
195 endef
196
197 define Package/uclibc/install
198 $(INSTALL_DIR) $(1)/lib
199 for file in ld-uClibc libc libcrypt libdl libm libnsl libresolv librt libuClibc libutil; do \
200 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(1)/lib/; \
201 $(CP) $(TOOLCHAIN_DIR)/lib/$$$$file-$(UCLIBC_VERSION).so $(1)/lib/; \
202 done
203 endef
204
205 define Package/ldd/install
206 $(INSTALL_DIR) $(1)/bin/
207 $(CP) $(TOOLCHAIN_DIR)/target-utils/ldd $(1)/bin/
208 endef
209
210 define Package/ldconfig/install
211 $(INSTALL_DIR) $(1)/bin/
212 $(CP) $(TOOLCHAIN_DIR)/target-utils/ldconfig $(1)/bin/
213 endef
214
215 ifneq ($(DUMP),1)
216 -include $(PLATFORM_DIR)/base-files.mk
217 endif
218
219 $(eval $(call BuildPackage,base-files$(TARGET)))
220 $(eval $(call BuildPackage,libgcc))
221 $(eval $(call BuildPackage,libssp))
222 $(eval $(call BuildPackage,libstdcpp))
223 $(eval $(call BuildPackage,libpthread))
224 $(eval $(call BuildPackage,uclibc))
225 $(eval $(call BuildPackage,ldd))
226 $(eval $(call BuildPackage,ldconfig))