Merge from vendor branch GCC:
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.41 2005/08/31 02:38:34 corecode Exp $
2 #
3
4 ISODIR ?= /usr/release
5 ISOFILE ?= ${ISODIR}/dfly.iso
6 ISOROOT = ${ISODIR}/root
7 OBJSYS= ${.OBJDIR}/../sys
8 KERNCONF ?= GENERIC
9
10 # Specify which packages are required on the ISO, and let the user
11 # specify additional packages to include.  During the `pkgaddiso'
12 # target, the packages are obtained from PACKAGES_LOC.
13 #
14 REQ_PACKAGES= cdrtools-2.01 cvsup-without-gui-16.1h
15 REL_PACKAGES?= ${REQ_PACKAGES} ${EXTRA_PACKAGES}
16 .if defined(PACKAGES)
17 PACKAGES_LOC?= ${PACKAGES}/All
18 .else
19 PACKAGES_LOC?= /usr/ports/packages/All
20 .endif
21 PACKAGE_SITES?=http://www.bsdinstaller.org/packages/ \
22                http://cvs.bsdinstaller.org/packages/
23
24 # Specify which root skeletons are required, and let the user include
25 # their own.  They are copied into ISODIR during the `pkgcustomizeiso'
26 # target; each overwrites the last.
27 #
28 REQ_ROOTSKELS= ${.CURDIR}/root
29 ROOTSKELS?= ${REQ_ROOTSKELS} ${EXTRA_ROOTSKELS}
30
31 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
32 # the additional '/nrelease' manually, as a safety measure.
33 #
34 NRLOBJDIR?= /usr/obj
35
36 WORLD_CCVER ?= ${CCVER}
37 KERNEL_CCVER ?= ${CCVER}
38
39 #########################################################################
40 #                               BASE ISO TARGETS                        #
41 #########################################################################
42
43 release:        check clean buildworld1 buildkernel1 \
44                 buildiso customizeiso pkgaddiso mklocatedb mkiso
45
46 quickrel:       check clean buildworld2 buildkernel2 \
47                 buildiso customizeiso pkgaddiso mklocatedb mkiso
48
49 realquickrel:   check clean \
50                 buildiso customizeiso pkgaddiso mklocatedb mkiso
51
52 #########################################################################
53 #                       ISO TARGETS WITH INSTALLER                      #
54 #########################################################################
55
56 INSTALLER_PKGS= libaura-3.1 libdfui-4.1 libinstaller-5.1 \
57                 dfuibe_installer-1.1.6 dfuife_curses-1.5 \
58                 thttpd-notimeout-2.24 dfuife_cgi-1.4
59 INSTALLER_SKELS= installer
60
61 INSTALLER_ENV= EXTRA_PACKAGES="${INSTALLER_PKGS} ${EXTRA_PACKAGES}" \
62                 EXTRA_ROOTSKELS="${INSTALLER_SKELS} ${EXTRA_ROOTSKELS}"
63
64 installer_check:
65                 @${INSTALLER_ENV} ${MAKE} check
66
67 installer_fetchpkgs:
68                 @${INSTALLER_ENV} ${MAKE} fetchpkgs
69
70 installer_release:
71                 ${INSTALLER_ENV} ${MAKE} release
72
73 installer_quickrel:
74                 ${INSTALLER_ENV} ${MAKE} quickrel
75
76 installer_realquickrel:
77                 ${INSTALLER_ENV} ${MAKE} realquickrel
78
79 #########################################################################
80 #                               HELPER TARGETS                          #
81 #########################################################################
82
83 check:
84         @if [ ! -f /usr/local/bin/mkisofs ]; then \
85                 echo "You need to install the sysutils/cdrtools port for"; \
86                 echo "this target"; \
87                 exit 1; \
88         fi
89 .for PKG in ${REL_PACKAGES}
90         @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
91                 echo "Unable to find ${PACKAGES_LOC}/${PKG}.tgz."; \
92                 echo "(Perhaps you need to download or build it first?)"; \
93                 echo ""; \
94                 echo "If you are trying to build the installer, the"; \
95                 echo "required packages can be obtained from:"; \
96                 echo ""; \
97                 echo "    http://www.bsdinstaller.org/packages/"; \
98                 echo ""; \
99                 echo "They can be automatically downloaded by issuing"; \
100                 echo "'make installer_fetchpkgs' from this directory."; \
101                 echo ""; \
102                 exit 1; \
103         fi
104 .endfor
105         @echo "check: all preqs found"
106
107 fetchpkgs:
108 .for PKG in ${REL_PACKAGES}
109         @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
110                 cd ${PACKAGES_LOC} && \
111                 echo "fetching ${PKG}..." && \
112                 for SITE in ${PACKAGE_SITES}; do \
113                         if [ ! -f ${PKG}.tgz ]; then \
114                                 fetch $${SITE}${PKG}.tgz || \
115                                     echo "Not available from $${SITE}"; \
116                         fi; \
117                 done; \
118                 if [ ! -f ${PKG}.tgz ]; then \
119                         echo "Couldn't retrieve ${PKG}.tgz!"; \
120                         exit 1; \
121                 fi; \
122         fi
123 .endfor
124
125 buildworld1:
126         ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make buildworld )
127
128 buildworld2:
129         ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make quickworld )
130
131 buildkernel1:
132         ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make buildkernel KERNCONF=${KERNCONF} )
133
134 buildkernel2:
135         ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make quickkernel KERNCONF=${KERNCONF} )
136
137 # note that we do not want to mess with any /usr/obj directories not related
138 # to buildworld, buildkernel, or nrelease, so we must supply the proper
139 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
140 # buildkernel mechanism.
141 #
142 buildiso:
143         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
144         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
145         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
146         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
147                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
148         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
149         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} \
150                 installkernel KERNCONF=${KERNCONF} )
151         ln -s kernel ${ISOROOT}/kernel.BOOTP
152         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
153         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
154         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
155
156 customizeiso:
157 .for ROOTSKEL in ${ROOTSKELS}
158         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
159 .endfor
160         rm -rf `find ${ISOROOT} -type d -name CVS -print`
161         rm -rf ${ISOROOT}/usr/local/share/pristine
162         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
163 .for UPGRADE_ITEM in Makefile                   \
164                      etc.${MACHINE_ARCH}        \
165                      isdn/Makefile              \
166                      rc.d/Makefile              \
167                      periodic/Makefile          \
168                      periodic/daily/Makefile    \
169                      periodic/security/Makefile \
170                      periodic/weekly/Makefile   \
171                      periodic/monthly/Makefile
172         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
173 .endfor
174
175 PKG_VERSTR!=    pkg_info -vP
176 .if !empty(PKG_VERSTR:M*fakeroot*)
177
178 pkgcleaniso:
179 .for PKG in ${REL_PACKAGES}
180         -PKG_FAKEROOT=${ISOROOT:Q} pkg_delete -f ${PKG}
181 .endfor
182
183 pkgaddiso:
184 .for PKG in ${REL_PACKAGES}
185         -PKG_FAKEROOT=${ISOROOT:Q} pkg_add ${PACKAGES_LOC}/${PKG}.tgz
186 .endfor
187
188 .else   # pkgtools don't know fakeroot
189
190 pkgcleaniso:
191         rm -f ${ISOROOT}/tmp/chrootscript
192         echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
193 .for PKG in ${REL_PACKAGES}
194         echo "pkg_delete -f ${PKG}" >> ${ISOROOT}/tmp/chrootscript
195 .endfor
196         chmod a+x ${ISOROOT}/tmp/chrootscript
197         chroot ${ISOROOT}/ /tmp/chrootscript || exit 0
198         rm ${ISOROOT}/tmp/chrootscript
199
200 pkgaddiso:
201         rm -f ${ISOROOT}/tmp/chrootscript
202         echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
203 .for PKG in ${REL_PACKAGES}
204         if [ ! -d ${ISOROOT}/var/db/pkg/${PKG} ]; then \
205                 cp ${PACKAGES_LOC}/${PKG}.tgz ${ISOROOT}/tmp/${PKG}.tgz; \
206                 echo "echo 'Installing package ${PKG}...' && \\" >> \
207                     ${ISOROOT}/tmp/chrootscript; \
208                 echo "pkg_add /tmp/${PKG}.tgz && \\" >> \
209                     ${ISOROOT}/tmp/chrootscript; \
210         fi
211 .endfor
212         echo "echo 'All packages added successfully!'" >> \
213             ${ISOROOT}/tmp/chrootscript
214         chmod a+x ${ISOROOT}/tmp/chrootscript
215         chroot ${ISOROOT}/ /tmp/chrootscript
216         rm ${ISOROOT}/tmp/chrootscript
217 .for PKG in ${REL_PACKAGES}
218         rm -f ${ISOROOT}/tmp/${PKG}.tgz
219 .endfor
220
221 .endif  # pkgtools fakeroot
222
223 mklocatedb:
224         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
225                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
226                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
227                 /usr/libexec/locate.mklocatedb \
228                 -presort >${ISOROOT}/var/db/locate.database )
229
230 mkiso:
231         ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
232                 -R -J -V DragonFly -o ${ISOFILE} . )
233
234 clean:
235         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
236         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
237         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
238
239 realclean:      clean
240         rm -rf ${OBJSYS}/${KERNCONF}
241
242 .include <bsd.prog.mk>