2 # Build a uClinux/distribution source package from git tree.
4 # (C) Copyright 1999-2013, Greg Ungerer <greg.ungerer@accelecon.com>
6 # Takes a git tree a ssource and builds a uClinux-dist package.
10 SOURCE=${1:-uclinux-dist.working}
15 # KEEP_IXP_MODULES=true
16 # KEEP_OCF_MODULES=true
18 # KEEP_MODULE_CONFIGS=true
21 # If we keep crypto or ixp modules, we need to keep the module configs too.
22 [ "$KEEP_CRYPTO" = "true" -o "$KEEP_IXP_MODULES" = "true" ] && KEEP_MODULE_CONFIGS=true
26 PACKAGE=${NAME}-${DATE}
28 DIRS="README SOURCE COPYING Documentation Makefile config linux-2.4.x linux-3.x freeswan openswan lib glibc uClibc user include tools vendors bin"
30 [ "$KEEP_PROP" = "true" ] && DIRS="$DIRS prop"
31 [ "$KEEP_BOOT" = "true" ] && DIRS="$DIRS boot"
34 SRCDIR=${CURPWD}/${SOURCE}
35 DSTDIR=${CURPWD}/${NAME}
36 SLASHPKGDIR=${CURPWD}/${PKGDIR}/.
40 # Check if target directory exists, bail if it does.
44 echo "ERROR: directory ${DSTDIR} exists, stopping now!"
50 # Remove any old current images hanging around...
52 [ -d ${SLASHPKGDIR} ] || mkdir -p ${SLASHPKGDIR}
53 rm -f ${SLASHPKGDIR}/${PACKAGE}*
57 # Start creating new directory
59 echo "Creating ${DSTDIR} directory..."
62 echo "Copying ${SRCDIR} to ${DSTDIR}..."
63 find ${DIRS} -print | grep -v CVS | cpio -pmd ${DSTDIR}
65 if [ "$KEEP_MODULE_CONFIGS" = "true" ]; then
66 echo "Copying module dir configs..."
67 mkdir -p ${DSTDIR}/modules
68 head -9 ${SRCDIR}/modules/Kconfig > ${DSTDIR}/modules/Kconfig
69 sed -e ':b /\\$/{ ; N ; s/\\\n// ; bb ; }' ${SRCDIR}/modules/Makefile |\
70 sed -e "s/^subdir-m.*$/subdir-m := /" \
71 > ${DSTDIR}/modules/Makefile
74 if [ "$KEEP_OCF_MODULES" = "true" ]; then
75 echo "Copying modules/ocf..."
76 find modules/ocf -print | grep -v CVS | cpio -pd ${DSTDIR}
77 find ${DSTDIR}/modules/ocf -name "*.o" | xargs rm -f
78 echo "source ocf/Kconfig" >> ${DSTDIR}/modules/Kconfig
79 cp ${DSTDIR}/modules/Makefile ${DSTDIR}/modules/Makefile.bak
80 sed -e "s/^subdir-m := /subdir-m := ocf /" \
81 ${DSTDIR}/modules/Makefile.bak \
82 > ${DSTDIR}/modules/Makefile
83 rm ${DSTDIR}/modules/Makefile.bak
84 cp ${SRCDIR}/prop/include/octeon-asm.h ${DSTDIR}/modules/ocf/cryptocteon/
87 find vendors -name "config.linux*" |
90 cp ${FILE} ${FILE}.org
91 sed -e "s/CONFIG_KLIPS_OCF=y/# CONFIG_KLIPS_OCF is not set/g" \
95 sed -e 's/-I$(ROOTDIR)\/modules\/ocf//' \
96 ${SRCDIR}/linux-2.4.x/net/ipsec/Makefile \
97 > ${DSTDIR}/linux-2.4.x/net/ipsec/Makefile
98 sed -e "s/bool ' IPsec: OCF HW Acceleration support' CONFIG_KLIPS_OCF//" \
99 ${SRCDIR}/openswan/linux/net/ipsec/Config.in.os2_4 \
100 > ${DSTDIR}/openswan/linux/net/ipsec/Config.in.os2_4
104 if [ "$KEEP_IXP_MODULES" = "true" ]; then
105 echo "Copying modules/ixp425..."
106 find modules/ixp425 -print | grep -v CVS | cpio -pd ${DSTDIR}
107 find ${DSTDIR}/modules/ixp425 -name "*.o" | grep -v dsr.o | xargs rm -f
108 echo "source ixp425/Kconfig" >> ${DSTDIR}/modules/Kconfig
109 cp ${DSTDIR}/modules/Makefile ${DSTDIR}/modules/Makefile.bak
110 sed -e "s/^subdir-m := /subdir-m := ixp425 /" \
111 ${DSTDIR}/modules/Makefile.bak \
112 > ${DSTDIR}/modules/Makefile
113 rm ${DSTDIR}/modules/Makefile.bak
116 if [ "$KEEP_PROP" != "true" ]; then
117 cp ${DSTDIR}/config/Kconfig /tmp/
118 grep -v prop /tmp/Kconfig > ${DSTDIR}/config/Kconfig
119 cp ${DSTDIR}/config/Makefile /tmp/
120 sed -e "s/\.\.\/prop\/Kconfig\.auto//g" < /tmp/Makefile |
121 sed -e "s/\.\.\/prop\/Makefile\.auto//g" \
122 > ${DSTDIR}/config/Makefile
126 if [ "$KEEP_BOOT" != "true" ]; then
127 cp ${DSTDIR}/config/Kconfig /tmp/
128 grep -v boot /tmp/Kconfig > ${DSTDIR}/config/Kconfig
129 cp ${DSTDIR}/config/Makefile /tmp/
130 sed -e "s/\.\.\/boot\/Kconfig\.auto//g" < /tmp/Makefile |
131 sed -e "s/\.\.\/boot\/Makefile\.auto//g" \
132 > ${DSTDIR}/config/Makefile
136 # Remove all binaries, top level clean...
138 echo "Removing objects from ${DSTDIR}..."
140 make dep 2>&1 | cat > /tmp/dep
141 echo "making clean ..."
142 make distclean 2>&1 | cat > /tmp/clean
143 make -C linux-2.4.x distclean 2> /dev/null > /dev/null
144 make -C linux-3.x distclean 2> /dev/null > /dev/null
145 make -C config/scripts clean 2> /dev/null > /dev/null
146 make -C config/scripts/lxdialog clean 2> /dev/null > /dev/null
147 find linux-3.x -name ".*.cmd" | xargs rm -f
148 rm -f linux-3.x/scripts/kconfig/*.o
149 rm -f linux-3.x/scripts/kconfig/lex.zconf.c
150 rm -f linux-3.x/scripts/kconfig/zconf.hash.c
151 rm -f linux-3.x/scripts/kconfig/zconf.tab.c
152 rm -f linux-3.x/scripts/kconfig/conf
153 rm -f linux-3.x/scripts/basic/fixdep
154 rm -f linux-3.x/scripts/basic/docproc
155 rm -f linux-3.x/scripts/basic/hash
156 rm -rf linux-3.x/include/config
157 rm -f linux-2.4.x/include/asm-armnommu/arch
158 rm -f linux-2.4.x/include/asm-armnommu/proc
159 rm -f uClibc/extra/config/*.o
164 # Remove mention of some vendors from configs...
166 echo "removing vendors..."
167 rm -rf ${DSTDIR}/vendors/ATT
171 # Remove other miscellaneous stuff...
173 echo "Cleaning out miscellaneous other stuff..."
175 find . -name errs -print | xargs rm -f
176 find . -name .depend -print | xargs rm -f
177 find . -name .depend.embed -print | xargs rm -f
178 find . -name .version -print | xargs rm -f
179 find . -name .svn -print | xargs rm -rf
180 find user/iptables -name "*.d" | xargs rm -f
181 rm -f linux-2.?.x/.config*
182 rm -f linux-2.?.x/include/linux/autoconf.h
183 rm -f linux-2.?.x/include/asm
184 rm -f linux-2.?.x/include/asm-arm/arch
185 rm -f linux-2.?.x/include/asm-arm/proc
186 rm -f .config config.arch
187 rm -f config/autoconf.h config/.config config/.config.old
188 rm -rf vendors/.config vendors/.config.old
189 rm -rf vendors/Hitachi/dsp
190 rm -f user/iptables/.makefirst
193 rm -rf tools/c++ tools/gcc-* tools/misc/gcc-include
194 rm -f tools/misc/pivio*
195 rm -f tools/misc/nap5272.gdb
196 rm -f tools/misc/*.hdc
197 rm -rf tools/misc/mips/sg590.majic
199 rm -f uClibc/.config*
200 rm -f uClibc/extra/config/conf uClibc/extra/config/zconf.tab.[ch]
201 rm -f uClibc/extra/config/lex.zconf.c uClibc/extra/config/lkc_defs.h
202 rm -rf uClibc/include/bits
203 rm -f uClibc/include/fpu_control.h uClibc/include/net/bpf.h
205 if [ "$KEEP_MODULE_CONFIGS" != "true" ]; then
206 find vendors -name config.modules | xargs rm -f
209 if [ "$KEEP_IXP_MODULES" != "true" ]; then
211 find vendors -name "config.linux-2.4.x" |
214 cp ${FILE} ${FILE}.org
215 sed -e "s/CONFIG_IXP4XX_CRYPTO=y/# CONFIG_IXP4XX_CRYPTO is not set/g" \
216 ${FILE}.org > ${FILE}
223 # Remove private vendor names from config files.
226 find vendors -name "config.device*" |
229 grep -v "CONFIG_DEFAULTS_ADTRAN_" ${SRCDIR}/${FILE} | \
230 grep -v "CONFIG_DEFAULTS_ATT_" | \
231 grep -v "CONFIG_DEFAULTS_MARCONI_" | \
232 grep -v "CONFIG_DEFAULTS_GILBARCO_" \
238 # Change some permissions, so they look nice.
240 chmod 775 ${DSTDIR}/bin/*
243 # Fix up some autogen files so they don't get rebuilt.
245 touch ${DSTDIR}/user/mawk/array.[ch]
247 echo "Packaging ${DSTDIR}..."
249 tar cf ${PACKAGE}.tar ${NAME}
250 echo "gziping ${PACKAGE}.tar..."
251 bzip2 -9 -k ${PACKAGE}.tar
252 gzip -9 ${PACKAGE}.tar
254 mv ${PACKAGE}.tar.gz ${PACKAGE}.tar.bz2 ${PKGDIR}