--- trunk/linux-libc-headers/headers.sh 2006/10/02 10:17:08 393 +++ trunk/linux-libc-headers/headers.sh 2007/03/16 00:06:55 435 @@ -1,6 +1,6 @@ #!/bin/bash # -# Minimal Sanitized Headers - Version 00.91 +# Minimal Sanitized Headers - Version 01.00 # # Submit bugreports via http://headers.cross-lfs.org # @@ -25,19 +25,16 @@ # Theo Schneider # Roberto Nibali # -# -# As of Version 00.26 we no longer link to glibc headers, we link strictly -# use Linux Headers. Glibc, dietlibc, and uclibc use byteswap.h which is -# required for various headers. We have elected to link with the existing -# ones. -# -# # LFS/CLFS Build notes # # You will also need to copy over asm-generic to ensure you have all the -# necessary headers. In LLH they combine these into the asm-architecture +# necessary headers. In LLH they asm-generic these into the asm-{architecture} # so there is no asm-generic. # +# Headers Lists +# As of version 01.00 we have removed the headers lists from the scripts +# and put them into separate text files in lists directory. The file format +# is one header per line. # # Programs Required # @@ -92,13 +89,15 @@ usage() { echo "usage:" - echo " $0 kernel_version {optional}" + echo " $0 version=kernel_version {optional}" echo "example: $0" echo "" echo "Optional:" - echo " dump - dump headers name then create headers package" - echo " dumponly - dump headers name then exit" - echo " file - creates a file list" + echo " check - checks to see if the header exists in unsantized headers" + echo " dump - dump headers name then create headers package" + echo " dumponly - dump headers name then exit" + echo " file - creates a file list" + echo " patchfile={patch} - utilize this patch" exit 255 } @@ -135,6 +134,7 @@ -e 's/\b__user\b//g' \ -e 's/ inline / __inline__ /g' \ -e 's/__kernel_sockaddr_/sockaddr_/g' \ + -e 's/^#define $//' \ $header > $header.new mv $header.new $header fi @@ -213,10 +213,12 @@ -e '/#include /d' \ -e '/#include /d' \ -e '/endif .* __KERNEL__/d' \ + -e 's/|| !defined (__KERNEL__)//g' \ -e 's/|| !defined(__KERNEL__)//g' \ -e 's/!defined(__KERNEL__) ..//g' \ -e 's/|| defined(__KERNEL__)//g' \ -e 's/defined(__KERNEL__) ..//g' \ + -e 's/|| defined (__KERNEL__)//g' \ -e 's/#ifdef linux/#ifdef __linux__/g' \ -e 's/#ifndef linux/#ifndef __linux__/g' \ -e '/#include /d' \ @@ -247,9 +249,32 @@ done } +check_headers() { + for file in $CHECKHEADERS; do + TEST="`find * -name $file`" + if [ "$TEST" != "" ]; then + echo "$file was found" + else + echo "$file was not located." >> $CURRENT_DIR/missing_headers + fi + done +} +check_headers2() { + for file in $CHECKHEADERS; do + TEST="`find * -print0 | grep -FzZ $file`" + if [ "$TEST" != "" ]; then + echo "$file was found" + else + echo "$file was not located." >> $CURRENT_DIR/missing_headers + fi + done +} + clean_header() { header=$1 sed -e '/^$/N;/\n$/D' \ + -e 's@#if defined@#if defined@g' \ + -e 's@#if !defined@#if !defined@g' \ $header > $header.new mv $header.new $header } @@ -422,28 +447,40 @@ # Input Check # if [ "$1" = "" ]; then - usage + usage fi -# Setup Version -# -VERSION=$1 -shift - while [ $# -gt 0 ]; do case $1 in + check) + CHECK=yes + ;; + file) - FILE="yes" + FILE=yes ;; dump) - DUMP="yes" + DUMP=yes + ;; + + patchfile=*) + TEMPPATCH=`echo $1 | awk -F= '{print $2;}'` + if [ "$PATCHES" = "" ]; then + PATCHES="$TEMPPATCH" + else + PATCHES="$PATCHES $TEMPPATCH" + fi ;; dumponly) - DUMP="yes" - DUMPONLY="yes" + DUMP=yes + DUMPONLY=yes + ;; + + version=*) + VERSION=`echo $1 | awk -F= '{print $2;}'` ;; *) @@ -455,55 +492,60 @@ done # Checking for all the tools we need +TEST=`whereis awk | cut -f2 -d:` +if [ "$TEST" = "" ]; then + echo "Missing awk" + exit 254 +fi TEST=`whereis cp | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing cp." - exit 254 + exit 253 fi TEST=`whereis install | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing install." - exit 253 + exit 252 fi TEST=`whereis mv | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing mv." - exit 252 + exit 251 fi TEST=`whereis pwd | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing pwd." - exit 251 + exit 250 fi TEST=`whereis sed | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing sed." - exit 250 + exit 249 fi TEST=`whereis rm | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing rm." - exit 249 + exit 248 fi TEST=`whereis rmdir | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing rmdir." - exit 248 + exit 247 fi TEST=`whereis tar | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing tar." - exit 247 + exit 246 fi TEST=`whereis unifdef | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing unifdef." - exit 246 + exit 245 fi TEST=`whereis wget | cut -f2 -d:` if [ "$TEST" = "" ]; then echo "Missing wget." - exit 245 + exit 244 fi # Set Linux Version @@ -514,80 +556,27 @@ # Our Working Directories CURRENT_DIR=`pwd -P` -ORIGDIR="$CURRENT_DIR/linux-headers-$VERSION.orig/include" -NEWDIR="$CURRENT_DIR/linux-headers-$VERSION/include" +ORIGDIR=$CURRENT_DIR/linux-headers-$VERSION.orig/include +NEWDIR=$CURRENT_DIR/linux-headers-$VERSION/include # Headers to Sanitize -ASM_HEADERS="8253pit.h addrs.h addrspace.h alternative.h anna.h a.out.h apicdef.h apic.h arch.h as85ep1.h asi.h asm-compat.h - asm.h asmmacro-32.h asmmacro-64.h asmmacro.h assembler.h atomic.h auxvec.h barrier.h bitops.h bootparam.h - break.h btfixup.h byteorder.h cachectl.h cacheflush.h cache.h checksum.h clinkage.h clps7111.h compat.h - console.h constants.h const.h contregs.h coprocessor.h core.h cpudata.h cpufeature.h cpu-features.h cpu.h - cputable.h cputime.h cs89712.h current.h ddb5477.h dec21285.h delay.h desc.h div64.h domain.h ec3104.h eeh.h - elf.h entry.h ep7211.h ep7212.h errno-base.h errno.h ev96100.h ev96100int.h fcntl.h fixmap.h fls64.h - fpga85e2c.h fpregdef.h fpu.h gentrap.h gic.h gio_defs.h glue.h gpio.h hal.h hardirq.h hardware.h hd64465.h - head.h hubio.h hw_irq.h hwrpb.h hypervisor.h ia64regs.h imx-regs.h intrinsics.h io_apic.h ioctl.h ioctls.h - io_generic.h iomap.h iomd.h irc-regs.h irq.h irqs.h irq-sh73180.h irq-sh7780.h isadep.h iseries_io.h - it8172.h it8172_int.h it8712.h ixp2000-regs.h jazz.h kbio.h kldir.h kmap_types.h kregs.h lasat.h ldt.h - leds.h linkage.h local.h locks.h lowcore.h m32102.h m32104ut_pld.h m32700ut_lan.h m32700ut_lcd.h - m32700ut_pld.h m32r.h m32r_mp_fpga.h ma1.h machdep.h mach-types.h machvec.h macrology.h ma.h map.h - mappi2_pld.h mappi3_pld.h math_emu.h me2.h mem-layout.h memory.h mips_mt.h mipsmtregs.h mipsregs.h mman.h - mmsegment.h mmu_context.h mmu.h module.h motorola_pgalloc.h motorola_pgtable.h movs.h mpspec_def.h mpspec.h - msr.h mtrr.h nodedata.h node.h numa.h nvram.h openprom.h openpromio.h oplib.h opsput_lan.h opsput_lcd.h - opsput_pld.h pal.h param.h pda.h pdc.h pgalloc.h pgtable-2level.h pgtable-32.h pgtable-64.h pgtable-bits.h - pgtable.h pgtable-hwdef.h pgtsrmmu.h pgtsun4c.h pgtsun4.h pil.h platform.h poll.h posix_types.h prctl.h - processor.h procinfo.h psr.h pstate.h psw.h ptrace.h regdef.h reg.h registers.h reg_map.h reg_rdwr.h - regs267x.h regs306x.h regs-clock.h regs-watchdog.h rs485.h rse.h rte_cb.h rte_ma1_cb.h rte_me2_cb.h - rte_nb85e_cb.h rwlock.h scatterlist.h scratchpad.h segment.h semaphore.h sembuf.h serial.h serial-regs.h - setup.h sgidefs.h shmbuf.h shmparam.h shub_mmr.h sigcontext.h siginfo.h signal.h sigp.h sim85e2c.h - sim85e2.h sim85e2s.h sim.h sizes.h smp.h smtc.h sn_cpuid.h socket.h sockios.h spinlock.h spitfire.h - spr-regs.h starfire.h stat.h string.h sun3-head.h sun3mmu.h sun3_pgalloc.h sun3_pgtable.h sv_addr_ag.h - svinto.h synch.h sysasic.h syscall.h sysen.h sysirq.h system.h teg.h termbits.h termios.h timer-regs.h - timex.h tlbflush.h tlb.h traps.h tsc.h types.h ubc.h unaligned.h unistd.h unwind.h upa.h user.h - ustack.h v850e2_cache.h v850e2.h v850e_cache.h v850e.h v850e_intc.h vac-ops.h vaddrs.h visasm.h - vm86.h vsyscall32.h vsyscall.h war.h wbflush.h" -ASM_ARCH_HEADERS="asm-alpha/pci.h asm-alpha/console.h asm-alpha/hwrpb.h asm-mips/vr41xx/pci.h asm-mips/sysmips.h" -ASM_SYS_HEADERS="io.h" -LINUX_HEADERS="adb.h adfs_fs.h adfs_fs_i.h adfs_fs_sb.h affs_fs.h agpgart.h a.out.h apm_bios.h atalk.h atmapi.h - atmarp.h atmclip.h atmdev.h atm_eni.h atm.h atm_idt77105.h atmioc.h atmlec.h atmmpc.h atm_nicstar.h - atmppp.h atmsap.h atmsvc.h atm_tcp.h atm_zatm.h auto_fs4.h auto_fs.h auxvec.h backing-dev.h bfs_fs.h - binfmts.h bitops.h blkpg.h blockgroup_lock.h cache.h calc64.h capability.h capi.h cdrom.h coda_fs_i.h - coff.h compat.h cpu.h cramfs_fs.h cramfs_fs_sb.h crypto.h dcache.h dccp.h delay.h device.h devpts_fs.h - dirent.h dm-ioctl.h dn.h dnotify.h dqblk_xfs.h efs_dir.h efs_fs.h efs_fs_i.h efs_fs_sb.h elf.h errno.h - errqueue.h ethtool.h ext2_fs.h ext2_fs_sb.h ext3_fs.h ext3_fs_i.h ext3_fs_sb.h fb.h fcntl.h fd.h fdreg.h - filter.h fs.h fs_struct.h fuse.h futex.h gameport.h gen_stats.h gfp.h hayesesp.h hdreg.h hiddev.h - highmem.h hpfs_fs.h hrtimer.h icmp.h icmpv6.h idr.h if_arcnet.h if_arp.h if_bonding.h if_bridge.h - if_cablemodem.h if_ec.h if_eql.h if_ether.h if_fc.h if_fddi.h if_frad.h if.h if_hippi.h if_infiniband.h - if_ltalk.h if_packet.h if_plip.h if_ppp.h if_pppox.h if_shaper.h if_slip.h if_strip.h if_tr.h if_tun.h - if_tunnel.h if_vlan.h if_wanpipe_common.h if_wanpipe.h in6.h inet_diag.h in.h init.h inotify.h input.h - in_route.h interrupt.h ioctl.h ioport.h ip6_tunnel.h ipc.h ip.h ip_mp_alg.h ipsec.h ipv6.h ipv6_route.h - ipx.h irda.h irq_cpustat.h irqflags.h irq.h irqreturn.h isdn.h iso_fs.h jffs2_fs_i.h jffs2_fs_sb.h - jffs2.h jiffies.h joystick.h kdev_t.h kd.h kernelcapi.h kernel.h kernel_stat.h keyboard.h klist.h - kmod.h ktime.h lapb.h limits.h linkage.h list.h llc.h loop.h lp.h major.h mempool.h mii.h minix_fs.h - mm.h mod_devicetable.h module.h moduleparam.h mount.h msdos_fs.h msg.h ncp_fs_i.h ncp_fs_sb.h ncp.h - ncp_mount.h ncp_no.h netdevice.h netfilter_arp.h netfilter_bridge.h netfilter_decnet.h netfilter.h - netfilter_ipv4.h netfilter_ipv6.h net.h netlink.h netrom.h nfs2.h nfs4.h nfsacl.h nfs_fs.h nfs_fs_i.h - nfs_fs_sb.h nfs.h nfs_xdr.h notifier.h numa.h openprom_fs.h page-flags.h param.h parport.h patchkey.h - pcieport_if.h pci.h pci_ids.h pci_regs.h percpu_counter.h personality.h pfkeyv2.h pfn.h phy.h pid.h - pipe_fs_i.h pkt_cls.h pkt_sched.h pm.h pmu.h poll.h posix_acl.h posix_types.h ppdev.h ppp-comp.h - ppp_defs.h prctl.h preempt.h proc_fs.h profile.h ptrace.h qnx4_fs.h qnxtypes.h quota.h random.h raw.h - rbtree.h reboot.h reiserfs_fs.h reiserfs_fs_i.h reiserfs_fs_sb.h romfs_fs.h rose.h route.h rtc.h - rtnetlink.h sched.h sctp.h seccomp.h securebits.h security.h sem.h seqlock.h serial.h serial_reg.h - shmem_fs.h shm.h skbuff.h slab.h smb_fs.h smb_fs_i.h smb_fs_sb.h smb.h smb_mount.h smbno.h smp_lock.h - snmp.h sockios.h sonet.h soundcard.h statfs.h stddef.h stringify.h swap.h syscalls.h sysctl.h sysdev.h - sysv_fs.h tcp.h termios.h threads.h timex.h tiocl.h tty.h udf_fs.h udf_fs_i.h udf_fs_sb.h udp.h ufs_fs.h - ufs_fs_i.h ufs_fs_sb.h ultrasound.h unistd.h usbdevice_fs.h usb.h user.h utsname.h vfs.h videodev2.h - videodev.h vmalloc.h vt.h wireless.h workqueue.h x25.h xdr.h xfrm.h" - -NOSANTIZE_ASM_HEADERS="types.h" -NOSANTIZE_LINUX_HEADERS="nfs3.h types.h byteorder/big_endian.h byteorder/little_endian.h" - -BLANK_HEADERS="asm-sparc64/psr.h linux/autoconf.h linux/agp_backend.h linux/compiler.h linux/config.h linux/list.h - linux/mmzone.h linux/pagemap.h linux/percpu.h linux/syscalls.h linux/uio.h linux/utime.h" -ROOT_HEADERS="linux/elf.h linux/signal.h linux/string.h" -SYS_HEADERS="linux/acct.h linux/resource.h linux/socket.h linux/stat.h linux/un.h linux/wait.h" +ASM_HEADERS=$(cat $CURRENT_DIR/lists/asm-headers) +ASM_ARCH_HEADERS=$(cat $CURRENT_DIR/lists/asm-arch-headers) +ASM_SYS_HEADERS=$(cat $CURRENT_DIR/lists/asm-sys-headers) + +LINUX_HEADERS=$(cat $CURRENT_DIR/lists/linux-headers) + +NOSANTIZE_ASM_HEADERS=$(cat $CURRENT_DIR/lists/no_santize-asm-headers) +NOSANTIZE_LINUX_HEADERS=$(cat $CURRENT_DIR/lists/no_santize-linux-headers) + +BLANK_HEADERS=$(cat $CURRENT_DIR/lists/blank-headers) -REMOVE_HEADERS="asm-generic/page.h asm-mips/fpu.h net/raw.h net/rawv6.h asm-cris/arch-v10/atomic.h - asm-cris/arch-v32/atomic.h" +ROOT_HEADERS=$(cat $CURRENT_DIR/lists/root-headers) +SYS_HEADERS=$(cat $CURRENT_DIR/lists/sys-headers) + +GLIBC_HEADERS=$(cat $CURRENT_DIR/lists/glibc-headers) + +REMOVE_HEADERS=$(cat $CURRENT_DIR/lists/remove-headers) if [ "$FILE" = "yes" ]; then echo "Files List to $CURRENT_DIR/asm-list..." @@ -649,7 +638,48 @@ echo "Decompressing Kernel Headers only..." rm -rf linux-$VERSION linux-headers-$VERSION linux-headers-$VERSION.orig -tar jxf linux-$VERSION.tar.bz2 linux-$VERSION/include/* +tar --wildcards -jxf linux-$VERSION.tar.bz2 linux-$VERSION/include/* +if [ -e $CURRENT_DIR/patches/linux-$VERSION-REQUIRED-1.patch ]; then + if [ "$PATCHES" = "" ]; then + PATCHES="linux-$VERSION-REQUIRED-1.patch" + else + PATCHES="$PATCHES linux-$VERSION-REQUIRED-1.patch" + fi +fi +if [ -e $CURRENT_DIR/patches/linux-$VERSION-mips_headers-1.patch ]; then + if [ "$PATCHES" = "" ]; then + PATCHES="linux-$VERSION-mips_headers-1.patch" + else + PATCHES="$PATCHES linux-$VERSION-mips_headers-1.patch" + fi +fi +for PATCHFILE in $PATCHES; do + if [ -e "$CURRENT_DIR/patches/$PATCHFILE" ]; then + cd linux-$VERSION + echo "Patching Kernel Headers with $PATCHFILE..." + patch -Np1 -f -s -i $CURRENT_DIR/patches/$PATCHFILE + cd .. + fi +done + +if [ "$CHECK" = "yes" ]; then + cd linux-headers-$VERSION + rm -f $CURRENT_DIR/missing_headers + echo "Checking ASM..." + CHECKHEADERS="$ASM_HEADERS $NOSANTIZE_ASM_HEADERS" + check_headers + CHECKHEADERS="$ASM_ARCH_HEADERS $NOSANTIZE_ASM_HEADERS" + check_headers2 + echo "Checking Linux..." + CHECKHEADERS="$LINUX_HEADERS" + check_headers + CHECKHEADERS="$NOSANTIZE_LINUX_HEADERS" + check_headers2 + echo "Report is located at $CURRENT_DIR/missing_headers." + rm -rf linux-headers-$VERSION + cd $CURRENT_DIR + exit 0 +fi echo "Renaming directory to linux-headers-$VERSION..." mv linux-$VERSION linux-headers-$VERSION.orig @@ -663,21 +693,21 @@ install -d $NEWDIR/$dir done -DONT_CHANGE="no" -TYPE="asm" +DONT_CHANGE=no +TYPE=asm HEADERS="$ASM_HEADERS" if [ "$HEADERS" != "" ]; then make_headers fi -TYPE="asm" -HEADERS="$ASM_ARCH_HEADERS" +TYPE=asm +HEADERS=$ASM_ARCH_HEADERS if [ "$HEADERS" != "" ]; then make_headers fi -TYPE="linux" -HEADERS="$LINUX_HEADERS" +TYPE=linux +HEADERS=$LINUX_HEADERS if [ "$HEADERS" != "" ]; then make_headers fi @@ -685,7 +715,7 @@ SETTYPE="byteorder dvb isdn lockd mtd netfilter netfilter_arp netfilter_bridge netfilter_ipv4 netfilter_ipv6 nfsd raid sunrpc tc_act tc_ematch" for type in $SETTYPE; do - TYPE="linux" + TYPE=linux cd $ORIGDIR/linux if [ -e $ORIGDIR/linux/$type ]; then HEADERS=`find $type | grep .h | sed -e '/big_endian.h/d' | sed -e '/little_endian.h/d' | sort -u ` @@ -707,15 +737,15 @@ fi done -DONT_CHANGE="yes" -TYPE="linux" -HEADERS="$NOSANTIZE_LINUX_HEADERS" +DONT_CHANGE=yes +TYPE=linux +HEADERS=$NOSANTIZE_LINUX_HEADERS if [ "$HEADERS" != "" ]; then make_headers fi -TYPE="asm" -HEADERS="$NOSANTIZE_ASM_HEADERS" +TYPE=asm +HEADERS=$NOSANTIZE_ASM_HEADERS if [ "$HEADERS" != "" ]; then make_headers fi @@ -826,7 +856,7 @@ cp $ORIGDIR/asm-ia64/page.h $NEWDIR/asm-ia64/page.h PAGE_H=$NEWDIR/asm-ia64/page.h echo "Processing include/asm-ia64/page.h..." -unifdef -UCONFIG_IA64_PAGE_SIZE_4KB -UCONFIG_IA64_PAGE_SIZE_8KB \ +unifdef -e -UCONFIG_IA64_PAGE_SIZE_4KB -UCONFIG_IA64_PAGE_SIZE_8KB \ -UCONFIG_IA64_PAGE_SIZE_16KB -UCONFIG_IA64_PAGE_SIZE_64KB $PAGE_H > $PAGE_H.new cp $PAGE_H.new $PAGE_H sed -e 's/# error Unsupported page size./#define PAGE_SIZE\tsysconf (_SC_PAGE_SIZE)\nNeXtLiNe/' $PAGE_H > $PAGE_H.new @@ -1238,23 +1268,25 @@ cp $SWAB_H.new $SWAB_H sed -e 's/provide defaults when no architecture-specific optimization is detected/definitions that are not in glibc but required/g' $SWAB_H > $SWAB_H.new mv $SWAB_H.new $SWAB_H -echo "" >> $SWAB_H -echo "#define ___constant_swab16(x) __bswap_constant_16(x)" >> $SWAB_H -echo "#define ___constant_swab32(x) __bswap_constant_32(x)" >> $SWAB_H -echo "#define ___constant_swab64(x) __bswap_constant_64(x)" >> $SWAB_H -echo "" >> $SWAB_H -echo "#define __swab16(x) bswap_16(x)" >> $SWAB_H -echo "#define __swab32(x) bswap_32(x)" >> $SWAB_H -echo "#define __swab64(x) bswap_64(x)" >> $SWAB_H -echo "" >> $SWAB_H -echo "#define __swab16p(x) __swab16(*(x))" >> $SWAB_H -echo "#define __swab32p(x) __swab32(*(x))" >> $SWAB_H -echo "#define __swab64p(x) __swab64(*(x))" >> $SWAB_H -echo "" >> $SWAB_H -echo "#define __swab16s(x) do { *(x) = __swab16p((x)); } while (0)" >> $SWAB_H -echo "#define __swab32s(x) do { *(x) = __swab32p((x)); } while (0)" >> $SWAB_H -echo "#define __swab64s(x) do { *(x) = __swab64p((x)); } while (0)" >> $SWAB_H -echo "" >> $SWAB_H +if [ "$LINUXCODE" -gt "132625" ]; then + echo "" >> $SWAB_H + echo "#define ___constant_swab16(x) __bswap_constant_16(x)" >> $SWAB_H + echo "#define ___constant_swab32(x) __bswap_constant_32(x)" >> $SWAB_H + echo "#define ___constant_swab64(x) __bswap_constant_64(x)" >> $SWAB_H + echo "" >> $SWAB_H + echo "#define __swab16(x) bswap_16(x)" >> $SWAB_H + echo "#define __swab32(x) bswap_32(x)" >> $SWAB_H + echo "#define __swab64(x) bswap_64(x)" >> $SWAB_H + echo "" >> $SWAB_H + echo "#define __swab16p(x) __swab16(*(x))" >> $SWAB_H + echo "#define __swab32p(x) __swab32(*(x))" >> $SWAB_H + echo "#define __swab64p(x) __swab64(*(x))" >> $SWAB_H + echo "" >> $SWAB_H + echo "#define __swab16s(x) do { *(x) = __swab16p((x)); } while (0)" >> $SWAB_H + echo "#define __swab32s(x) do { *(x) = __swab32p((x)); } while (0)" >> $SWAB_H + echo "#define __swab64s(x) do { *(x) = __swab64p((x)); } while (0)" >> $SWAB_H + echo "" >> $SWAB_H +fi echo "#endif /* _LINUX_BYTEORDER_SWAB_H */" >> $SWAB_H clean_header $SWAB_H @@ -1275,12 +1307,10 @@ echo "Fixing include/linux/types.h..." sed -e 's@#include @#include \n#include @' $TYPES_H > $TYPES_H.new cp $TYPES_H.new $TYPES_H -if [ "$LINUXVERSION" = "2.6" ]; then - sed -e 's@typedef __u32 __kernel_dev_t;@typedef __u32 __kernel_dev_t;\n\n#if defined(WANT_KERNEL_TYPES) || !defined(__GLIBC__)@' $TYPES_H > $TYPES_H.new - cp $TYPES_H.new $TYPES_H - sed -e 's@#endif /. __KERNEL_STRICT_NAMES ./@\n#endif\n#endif\n\n@' $TYPES_H > $TYPES_H.new - cp $TYPES_H.new $TYPES_H -fi +sed -e 's@typedef __u32 __kernel_dev_t;@typedef __u32 __kernel_dev_t;\n\n#if defined(WANT_KERNEL_TYPES) || !defined(__GLIBC__)@' $TYPES_H > $TYPES_H.new +cp $TYPES_H.new $TYPES_H +sed -e 's@#endif /. __KERNEL_STRICT_NAMES ./@\n#endif\n#endif\n\n@' $TYPES_H > $TYPES_H.new +cp $TYPES_H.new $TYPES_H clean_header $TYPES_H for file in $REMOVE_HEADERS; do @@ -1288,11 +1318,20 @@ rm -f $NEWDIR/$file done +echo "Removing Headers that are replaced by glibc headers..." +for file in $GLIBC_HEADERS; do + rm $NEWDIR/$file +done + if [ "$LINUXCODE" -gt "132625" ]; then HEADER_FILE="videodev.h" HEADER_NAME="__LINUX_VIDEODEV_H" HEADER_UPDATE="#include " change_header + VIDEODEV_H=$NEWDIR/linux/videodev.h + sed -e '/CONFIG_VIDEO_V4L1_COMPAT/d' $VIDEODEV_H > $VIDEODEV_H.new + cp $VIDEODEV_H.new $VIDEODEV_H + clean_header $VIDEODEV_H fi echo "Removing any Kbuild files..." @@ -1330,6 +1369,9 @@ creation="$CURRENT_DIR/linux-headers-$VERSION/creation" echo "Processed $count headers on `date +%m-%d-%Y` at `date +%r`" > $creation echo "based on $VERSION kernel." >> $creation +if [ -e "$CURRENT_DIR/patches/$PATCHFILE" ]; then + echo "Utilized patch - $PATCHFILE" >> $creation +fi bugreport="$CURRENT_DIR/linux-headers-$VERSION/bug-report" echo "Report bugs at http://headers.cross-lfs.org" > $bugreport @@ -1348,6 +1390,20 @@ install -d $CURRENT_DIR/linux-headers-$VERSION/script cp $0 $CURRENT_DIR/linux-headers-$VERSION/script +install -d $CURRENT_DIR/linux-headers-$VERSION/lists +cp $CURRENT_DIR/lists/* $CURRENT_DIR/linux-headers-$VERSION/lists +install -d $CURRENT_DIR/linux-headers-$VERSION/script/patches +if [ -e $CURRENT_DIR/patches/linux-$VERSION-REQUIRED-1.patch ]; then + cp $CURRENT_DIR/patches/linux-$VERSION-REQUIRED-1.patch $CURRENT_DIR/linux-headers-$VERSION/script/patches/linux-$VERSION-REQUIRED-1.patch +fi +if [ -e $CURRENT_DIR/patches/linux-$VERSION-mips_headers-1.patch ]; then + cp $CURRENT_DIR/patches/linux-$VERSION-mips_headers-1.patch $CURRENT_DIR/linux-headers-$VERSION/script/patches/linux-$VERSION-mips_headers-1.patch +fi +for PATCHFILE in $PATCHES; do + if [ -e "$CURRENT_DIR/patches/$PATCHFILE" ]; then + cp $CURRENT_DIR/patches/$PATCHFILE $CURRENT_DIR/linux-headers-$VERSION/script/patches/$PATCHFILE + fi +done cp license $CURRENT_DIR/linux-headers-$VERSION/license