/[baselayout]/trunk/Makefile
Gentoo

Contents of /trunk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2240 - (show annotations) (download)
Thu Sep 14 10:13:11 2006 UTC (7 years, 10 months ago) by uberlord
File size: 7413 byte(s)
tag 1.12.5
1 # baselayout Makefile
2 # Copyright (c) 2006 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # Contributed by Roy Marples (uberlord@gentoo.org)
5 #
6 # We've moved the installation logic from Gentoo ebuild into a generic
7 # Makefile so that the ebuild is much smaller and more simple.
8 # It also has the added bonus of being easier to install on systems
9 # without an ebuild style package manager.
10
11 NAME = baselayout
12 VERSION = 1.13.0_alpha1
13 PKG = $(NAME)-$(VERSION)
14
15 ARCH = x86
16 OS = Linux
17 DESTDIR =
18 ROOT = /
19 LIB = lib
20
21 DEVDIR = $(DESTDIR)/dev
22 BINDIR = $(DESTDIR)/bin
23 SBINDIR = $(DESTDIR)/sbin
24 LIBDIR = $(DESTDIR)/$(LIB)
25 INITDIR = $(DESTDIR)/etc/init.d
26 MANDIR = $(DESTDIR)/usr/share/man
27 LOGDIR = $(DESTDIR)/var/log
28 RUNDIR = $(DESTDIR)/var/run
29
30 RCDIR = $(LIBDIR)/rcscripts
31 SHDIR = $(RCDIR)/sh
32 NETDIR= $(RCDIR)/net
33 AWKDIR = $(RCDIR)/awk
34 LVLDIR = $(DESTDIR)/etc/runlevels
35
36 # Default init scripts for the boot runlevel
37 BOOT_LEVEL = bootmisc checkroot checkfs clock hostname localmount \
38 urandom
39 # Default init scripts for the default runlevel
40 DEFAULT_LEVEL = local netmount
41
42 # Don't install these files if they already exist in ROOT
43 # Basically, don't hit the users key config files
44 ETC_SKIP = hosts passwd shadow group fstab
45
46 KEEP_DIRS = boot dev proc home \
47 mnt/cdrom mnt/floppy \
48 usr/local/bin usr/local/sbin usr/local/share/doc usr/local/share/man \
49 var/run lib/rcscripts/init.d lib/rcscripts/tmp
50
51 SUBDIRS = src
52
53 SBINTOLIB = rc-daemon.sh rc-help.sh rc-services.sh \
54 init.$(OS).sh init-functions.sh init-common-pre.sh init-common-post.sh
55
56 ifeq ($(OS),Linux)
57 BOOTLEVEL += consolefont keymaps modules rmnologin
58 NET_LO = net.lo
59 DEFAULT_LEVEL += hdparm
60 KEEP_DIRS += sys
61 endif
62 ifeq ($(OS),BSD)
63 NET_LO = net.lo0
64 endif
65 BOOT_LEVEL += $(NET_LO)
66
67 default:
68 for x in $(SUBDIRS) ; do \
69 cd $$x ; \
70 $(MAKE) $(AM_MAKEFLAGS) ; \
71 done
72
73 clean:
74 for x in $(SUBDIRS) ; do \
75 cd $$x ; \
76 $(MAKE) clean ; \
77 done
78
79 basedev-Linux:
80 if ! test -d $(DEVDIR) ; then \
81 install -m 0755 -d $(DEVDIR) ; \
82 fi
83 ( curdir=`pwd` ; cd $(DEVDIR) ; \
84 $$curdir/sbin/MAKEDEV generic-base )
85
86 dev-Linux:
87 install -m 0755 -d $(DEVDIR)
88 ln -snf ../sbin/MAKEDEV $(DEVDIR)/MAKEDEV \
89 ( curdir=`pwd` ; cd $(DEVDIR) ; \
90 suffix= ; \
91 case $(ARCH) in \
92 arm*) suffix=-arm ;; \
93 alpha) suffix=-alpha ;; \
94 amd64) suffix=-i386 ;; \
95 hppa) suffix=-hppa ;; \
96 ia64) suffix=-ia64 ;; \
97 m68k) suffix=-m68k ;; \
98 mips*) suffix=-mips ;; \
99 ppc*) suffix=-powerpc ;; \
100 s390*) suffix=-s390 ;; \
101 sh*) suffix=-sh ;; \
102 sparc*) suffix=-sparc ;; \
103 x86) suffix=-i386 ;; \
104 esac ; \
105 $$curdir/sbin/MAKEDEV generic$$suffix ; \
106 $$curdir/sbin/MAKEDEV sg scd rtc hde hdf hdg hdh ; \
107 $$curdir/sbin/MAKEDEV input audio video ; \
108 )
109
110 basedev: basedev-$(OS)
111
112 dev: dev-$(OS)
113
114 layout:
115 # Create base filesytem layout
116 for x in $(KEEP_DIRS) ; do \
117 install -m 0755 -d $(DESTDIR)/$$x ; \
118 touch $(DESTDIR)/$$x/.keep ; \
119 done
120 # Special dirs
121 install -m 0700 -d $(DESTDIR)/root
122 touch $(DESTDIR)/root/.keep
123 install -m 1777 -d $(DESTDIR)/var/tmp
124 touch $(DESTDIR)/var/tmp/.keep
125 install -m 1777 -d $(DESTDIR)/tmp
126 touch $(DESTDIR)/tmp/.keep
127 # Needed log files
128 install -m 0755 -d $(LOGDIR)
129 touch $(LOGDIR)/lastlog
130 install -m 0644 -g utmp /dev/null $(LOGDIR)/wtmp
131 install -m 0755 -d $(RUNDIR)
132 install -m 0664 -g utmp /dev/null $(RUNDIR)/utmp
133 # FHS compatibility symlinks stuff
134 ln -snf /var/tmp $(DESTDIR)/usr/tmp
135 ln -snf share/man $(DESTDIR)/usr/local/man
136
137 install:
138 # bin
139 install -m 0755 -d $(BINDIR)
140 for x in `ls bin` ; do \
141 install -m 0755 "bin/$$x" $(BINDIR) ; \
142 done
143 # sbin
144 install -m 0755 -d $(SBINDIR)
145 install -m 0644 sbin/functions.sh $(SBINDIR)
146 for x in depscan.sh env-update.sh runscript.sh rc rc-update \
147 modules-update MAKEDEV ; do \
148 install -m 0755 "sbin/$$x" $(SBINDIR) ; \
149 done
150 # lib
151 install -m 0755 -d $(SHDIR)
152 for x in $(SBINTOLIB) ; do \
153 n=`echo $$x | sed -e 's/\.$(OS)//'` ; \
154 if test $$x = "rc-help.sh" ; then \
155 install -m 0755 "sbin/$$x" $(SHDIR)/$$n ; \
156 else \
157 install -m 0644 "sbin/$$x" $(SHDIR)/$$n ; \
158 fi \
159 done
160 # awk
161 install -m 0755 -d $(AWKDIR)
162 for x in `ls src/awk` ; do \
163 install -m 0644 "src/awk/$$x" $(AWKDIR) ; \
164 if test $(LIB) != "lib" ; then \
165 sed -i -e 's:/lib/rcscripts:/'$(LIB)'/rcscripts:' $(AWKDIR)/$$x ; \
166 fi ; \
167 done
168 # init.d
169 install -m 0755 -d $(INITDIR)
170 for x in `ls init.d` ; do \
171 install -m 0755 "init.d/$$x" $(INITDIR) ; \
172 done
173 # Create our symlinks
174 for x in depscan.sh functions.sh runscript.sh ; do \
175 ln -snf ../../sbin/"$$x" $(INITDIR)/"$$x" ; \
176 done
177 # etc
178 # Assume that everything is a flat layout
179 for x in `ls -R etc` ; do \
180 if test `echo "$$x" | sed -e 's/.*\(.\)$$/\1/'` = ":" ; then \
181 d=`echo "$$x" | sed -e 's/\(.*\).$$/\1/'` ; \
182 install -m 0755 -d $(DESTDIR)/"$$d" ; \
183 elif test -f "$$d/$$x" ; then \
184 skip=0 ; \
185 for y in $(ETC_SKIP) ; do \
186 if test "$$d/$$x" = "etc/$$y" ; then \
187 if test -f $(ROOT)/$$d/$$x ; then \
188 skip=1 ; \
189 break ; \
190 fi ; \
191 fi ; \
192 done ; \
193 if test $$skip -eq 0 ; then \
194 m=0644 ; \
195 if test "$$d/$$x" = "etc/shadow" ; then \
196 m=0600 ; \
197 elif test "$$d/$$x" = "/etc/sysctl.conf" ; then \
198 m=0640 ; \
199 fi ; \
200 install -m $$m "$$d/$$x" $(DESTDIR)/"$$d/$$x" ; \
201 fi ; \
202 fi; \
203 done
204 # net scripts
205 install -m 0755 net-scripts/init.d/net.lo $(SH_DIR)/net.lo
206 ln -snf $(SH_DIR)/net.lo $(INITDIR)/$(NET_LO)
207 for x in `ls net-scripts/conf.d` ; do \
208 install -m 0644 net-scripts/conf.d/"$$x" $(DESTDIR)/etc/conf.d ; \
209 done
210 install -m 0755 -d $(NETDIR)
211 for x in `ls net-scripts/net` ; do \
212 install -m 0644 net-scripts/net/"$$x" $(NETDIR) ; \
213 done
214 for x in `ls net-scripts/net.$(OS)` ; do \
215 install -m 0644 net-scripts/net/"$$x" $(NETDIR) ; \
216 done
217 # Wang our man pages in
218 for x in `ls man` ; do \
219 d=`echo "$$x" | sed -e 's/.*\.\([0-9]\+\)$$/\1/'` ; \
220 install -m 0755 -d $(MANDIR)/man"$$d" ; \
221 install -m 0644 man/"$$x" $(MANDIR)/man"$$d" ; \
222 done
223 # Populate our runlevel folders
224 if ! test -d $(ROOT)/etc/runlevels/boot ; then \
225 install -m 0755 -d $(LVLDIR)/boot ; \
226 for x in $(BOOT_LEVEL) ; do \
227 ln -snf ../../init.d/"$$x" $(LVLDIR)/boot/"$$x" ; \
228 done ; \
229 fi
230 if ! test -d $(ROOT)/etc/runlevels/default ; then \
231 install -m 0755 -d $(LVLDIR)/default ; \
232 for x in $(DEFAULT_LEVEL) ; do \
233 ln -snf ../../init.d/"$$x" $(LVLDIR)/default/"$$x" ; \
234 done ; \
235 fi
236 # SPARC fixes
237 # SPAC does not like stty, so we disable RC_INTERACTIVE which requires it
238 # see Gentoo bug #104067.
239 if test $(ARCH) = "sparc" ; then \
240 sed -i -e '/^KEYMAP=/s:us:sunkeymap:' $(DESTDIR)/etc/conf.d/keymaps ; \
241 sed -i -e '/^RC_INTERACTIVE=/s:yes:no:' $(DESTDIR)/etc/conf.d/rc ; \
242 fi
243 # Now install our supporting utilities
244 for x in $(SUBDIRS) ; do \
245 cd $$x ; \
246 $(MAKE) install ; \
247 done
248
249 distcheck:
250 svnfiles=`svn status 2>&1 | egrep -v '^(U|P)'` ; \
251 if test "x$$svnfiles" != "x" ; then \
252 echo "Refusing to package tarball until svn is in sync:" ; \
253 echo "$$svnfiles" ; \
254 echo "make distforce to force packaging" ; \
255 exit 1 ; \
256 fi
257
258 distforce: clean
259 install -d /tmp/$(PKG)
260 cp -axr . /tmp/$(PKG)
261 cd /tmp/$(PKG) ; \
262 rm -rf *.sh rc-lists `find . -iname .svn` sbin/MAKEDEV-gentoo.patch \
263 src/core ; \
264 cd .. ; \
265 tar -cvjpf $(PKG).tar.bz2 $(PKG)
266 rm -rf /tmp/$(PKG)
267 du /tmp/$(PKG).tar.bz2
268
269 dist: distcheck distforce
270
271 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20