Whamcloud - gitweb
* scripts/lmake:
authorjacob <jacob>
Fri, 10 Oct 2003 09:20:12 +0000 (09:20 +0000)
committerjacob <jacob>
Fri, 10 Oct 2003 09:20:12 +0000 (09:20 +0000)
 * scripts/lustre-kernel.spec.in:
   - build like red hat's kernel

 * scripts/linux-merge-config.awk:
 * scripts/linux-merge-modules.awk:
   - include from red hat kernel srpm

 * kernel_patches/targets/rh-2.4.target:
   - update to new .target format

 * kernel_patches/kernel-configs/kernel-2.4.20-rh-2.4-i386.config:
   - generic i386 kernel config for rh-2.4 target

lustre/kernel_patches/kernel_configs/kernel-2.4.20-rh-2.4-i386.config [moved from lustre/kernel_patches/kernel_configs/linux-2.4.20-rh-i686-smp.config with 94% similarity]
lustre/kernel_patches/targets/rh-2.4.target
lustre/scripts/linux-merge-config.awk [new file with mode: 0644]
lustre/scripts/linux-merge-modules.awk [new file with mode: 0644]
lustre/scripts/lmake
lustre/scripts/lustre-kernel-2.4.spec.in

@@ -1,5 +1,5 @@
 #
-# Automatically generated by make menuconfig: don't edit
+# Automatically generated make config: don't edit
 #
 CONFIG_X86=y
 # CONFIG_SBUS is not set
@@ -21,12 +21,12 @@ CONFIG_KMOD=y
 # Processor type and features
 #
 CONFIG_LOLAT=y
-# CONFIG_M386 is not set
+CONFIG_M386=y
 # CONFIG_M486 is not set
 # CONFIG_M586 is not set
 # CONFIG_M586TSC is not set
 # CONFIG_M586MMX is not set
-CONFIG_M686=y
+# CONFIG_M686 is not set
 # CONFIG_MPENTIUMIII is not set
 # CONFIG_MPENTIUM4 is not set
 # CONFIG_MK6 is not set
@@ -37,21 +37,13 @@ CONFIG_M686=y
 # CONFIG_MWINCHIP2 is not set
 # CONFIG_MWINCHIP3D is not set
 # CONFIG_MCYRIXIII is not set
-CONFIG_X86_WP_WORKS_OK=y
-CONFIG_X86_INVLPG=y
-CONFIG_X86_CMPXCHG=y
-CONFIG_X86_XADD=y
-CONFIG_X86_BSWAP=y
-CONFIG_X86_POPAD_OK=y
-# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_X86_L1_CACHE_SHIFT=7
-CONFIG_X86_HAS_TSC=y
-CONFIG_X86_GOOD_APIC=y
-CONFIG_X86_PGE=y
-CONFIG_X86_USE_PPRO_CHECKSUM=y
+# CONFIG_X86_CMPXCHG is not set
+# CONFIG_X86_XADD is not set
+CONFIG_X86_L1_CACHE_SHIFT=4
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_X86_PPRO_FENCE=y
-CONFIG_X86_F00F_WORKS_OK=y
+# CONFIG_X86_F00F_WORKS_OK is not set
 CONFIG_X86_MCE=y
 
 #
@@ -60,31 +52,26 @@ CONFIG_X86_MCE=y
 # CONFIG_CPU_FREQ is not set
 CONFIG_TOSHIBA=m
 CONFIG_I8K=m
-CONFIG_MICROCODE=m
+# CONFIG_MICROCODE is not set
 CONFIG_X86_MSR=m
 CONFIG_X86_CPUID=m
 # CONFIG_E820_PROC is not set
 CONFIG_EDD=m
-# CONFIG_NOHIGHMEM is not set
-CONFIG_HIGHMEM4G=y
+CONFIG_NOHIGHMEM=y
+# CONFIG_HIGHMEM4G is not set
 # CONFIG_HIGHMEM64G is not set
-CONFIG_HIGHMEM=y
-CONFIG_HIGHPTE=y
-CONFIG_HIGHIO=y
-# CONFIG_MATH_EMULATION is not set
+# CONFIG_HIGHMEM is not set
+CONFIG_MATH_EMULATION=y
 CONFIG_MTRR=y
-CONFIG_SMP=y
-# CONFIG_X86_NUMA is not set
+# CONFIG_SMP is not set
+# CONFIG_X86_UP_APIC is not set
+# CONFIG_X86_UP_IOAPIC is not set
 # CONFIG_X86_TSC_DISABLE is not set
-CONFIG_X86_TSC=y
-CONFIG_HAVE_DEC_LOCK=y
 
 #
 # General setup
 #
 CONFIG_NET=y
-CONFIG_X86_IO_APIC=y
-CONFIG_X86_LOCAL_APIC=y
 CONFIG_PCI=y
 # CONFIG_PCI_GOBIOS is not set
 # CONFIG_PCI_GODIRECT is not set
@@ -109,11 +96,11 @@ CONFIG_I82365=y
 #
 # PCI Hotplug Support
 #
-CONFIG_HOTPLUG_PCI=y
+# CONFIG_HOTPLUG_PCI is not set
 # CONFIG_HOTPLUG_PCI_ACPI is not set
-CONFIG_HOTPLUG_PCI_COMPAQ=m
+# CONFIG_HOTPLUG_PCI_COMPAQ is not set
 # CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set
-CONFIG_HOTPLUG_PCI_IBM=m
+# CONFIG_HOTPLUG_PCI_IBM is not set
 # CONFIG_HOTPLUG_PCI_H2999 is not set
 CONFIG_SYSVIPC=y
 CONFIG_BSD_PROCESS_ACCT=y
@@ -170,11 +157,19 @@ CONFIG_BLK_DEV_FD=y
 CONFIG_BLK_DEV_XD=m
 CONFIG_PARIDE=m
 CONFIG_PARIDE_PARPORT=m
+
+#
+# Parallel IDE high-level drivers
+#
 CONFIG_PARIDE_PD=m
 CONFIG_PARIDE_PCD=m
 CONFIG_PARIDE_PF=m
 CONFIG_PARIDE_PT=m
 CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
 CONFIG_PARIDE_ATEN=m
 CONFIG_PARIDE_BPCK=m
 CONFIG_PARIDE_BPCK6=m
@@ -220,6 +215,10 @@ CONFIG_BLK_DEV_LVM=m
 #
 CONFIG_CRYPTO=m
 CONFIG_CIPHERS=m
+
+#
+# 128 bit blocksize
+#
 CONFIG_CIPHER_AES=m
 CONFIG_CIPHER_IDENTITY=m
 CONFIG_CRYPTODEV=m
@@ -347,6 +346,10 @@ CONFIG_ATM_MPOA=m
 CONFIG_ATM_BR2684=m
 CONFIG_ATM_BR2684_IPFILTER=y
 CONFIG_VLAN_8021Q=m
+
+#
+#  
+#
 CONFIG_IPX=m
 # CONFIG_IPX_INTERN is not set
 CONFIG_ATALK=m
@@ -425,6 +428,10 @@ CONFIG_IDE=y
 # IDE, ATA and ATAPI Block devices
 #
 CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
 # CONFIG_BLK_DEV_HD_IDE is not set
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
@@ -436,6 +443,10 @@ CONFIG_BLK_DEV_IDETAPE=m
 CONFIG_BLK_DEV_IDEFLOPPY=y
 CONFIG_BLK_DEV_IDESCSI=m
 # CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
 CONFIG_BLK_DEV_CMD640=y
 # CONFIG_BLK_DEV_CMD640_ENHANCED is not set
 CONFIG_BLK_DEV_ISAPNP=y
@@ -492,6 +503,10 @@ CONFIG_BLK_DEV_ATARAID_SII=m
 # SCSI support
 #
 CONFIG_SCSI=m
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
 CONFIG_BLK_DEV_SD=m
 CONFIG_SD_EXTRA_DEVS=40
 CONFIG_CHR_DEV_ST=m
@@ -500,6 +515,10 @@ CONFIG_BLK_DEV_SR=m
 CONFIG_BLK_DEV_SR_VENDOR=y
 CONFIG_SR_EXTRA_DEVS=4
 CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
 # CONFIG_SCSI_DEBUG_QUEUES is not set
 # CONFIG_SCSI_MULTI_LUN is not set
 CONFIG_SCSI_CONSTANTS=y
@@ -626,8 +645,16 @@ CONFIG_NET_FC=y
 # IEEE 1394 (FireWire) support (EXPERIMENTAL)
 #
 CONFIG_IEEE1394=m
+
+#
+# Device Drivers
+#
 # CONFIG_IEEE1394_PCILYNX is not set
 CONFIG_IEEE1394_OHCI1394=m
+
+#
+# Protocol Drivers
+#
 CONFIG_IEEE1394_VIDEO1394=m
 CONFIG_IEEE1394_SBP2=m
 CONFIG_IEEE1394_SBP2_PHYS_DMA=y
@@ -700,7 +727,7 @@ CONFIG_DEPCA=m
 CONFIG_HP100=m
 CONFIG_NET_ISA=y
 CONFIG_E2100=m
-# CONFIG_EWRK3 is not set
+CONFIG_EWRK3=m
 CONFIG_EEXPRESS=m
 CONFIG_EEXPRESS_PRO=m
 CONFIG_HPLAN_PLUS=m
@@ -802,9 +829,17 @@ CONFIG_AIRO=m
 CONFIG_HERMES=m
 CONFIG_PLX_HERMES=m
 CONFIG_PCI_HERMES=m
+
+#
+# Wireless Pcmcia cards support
+#
 CONFIG_PCMCIA_HERMES=m
 CONFIG_AIRO_CS=m
 CONFIG_NET_WIRELESS=y
+
+#
+# Wireless Pcmcia cards support
+#
 CONFIG_PCMCIA_HERMES_OLD=m
 
 #
@@ -916,6 +951,10 @@ CONFIG_ATM_FORE200E=m
 # Amateur Radio support
 #
 CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
 CONFIG_AX25=m
 # CONFIG_AX25_DAMA_SLAVE is not set
 CONFIG_NETROM=m
@@ -924,6 +963,10 @@ CONFIG_ROSE=m
 #
 # AX.25 network device drivers
 #
+
+#
+# AX.25 network device drivers
+#
 # CONFIG_MKISS is not set
 # CONFIG_6PACK is not set
 # CONFIG_BPQETHER is not set
@@ -949,10 +992,18 @@ CONFIG_SOUNDMODEM_FSK9600=y
 # IrDA (infrared) support
 #
 CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
 CONFIG_IRLAN=m
 CONFIG_IRNET=m
 CONFIG_IRCOMM=m
 CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
 CONFIG_IRDA_CACHE_LAST_LSAP=y
 CONFIG_IRDA_FAST_RR=y
 # CONFIG_IRDA_DEBUG is not set
@@ -960,8 +1011,16 @@ CONFIG_IRDA_FAST_RR=y
 #
 # Infrared-port device drivers
 #
+
+#
+# SIR device drivers
+#
 CONFIG_IRTTY_SIR=m
 CONFIG_IRPORT_SIR=m
+
+#
+# Dongle support
+#
 CONFIG_DONGLE=y
 CONFIG_ESI_DONGLE=m
 CONFIG_ACTISYS_DONGLE=m
@@ -972,6 +1031,10 @@ CONFIG_MCP2120_DONGLE=m
 CONFIG_OLD_BELKIN_DONGLE=m
 CONFIG_ACT200L_DONGLE=m
 CONFIG_MA600_DONGLE=m
+
+#
+# FIR device drivers
+#
 CONFIG_USB_IRDA=m
 CONFIG_NSC_FIR=m
 CONFIG_WINBOND_FIR=m
@@ -1000,10 +1063,18 @@ CONFIG_ISDN_DRV_LOOP=m
 # CONFIG_ISDN_DIVERSION is not set
 
 #
+# low-level hardware drivers
+#
+
+#
 # Passive ISDN cards
 #
 CONFIG_ISDN_DRV_HISAX=m
 CONFIG_ISDN_HISAX=y
+
+#
+#   D-channel protocol features
+#
 CONFIG_HISAX_EURO=y
 CONFIG_DE_AOC=y
 # CONFIG_HISAX_NO_SENDCOMPLETE is not set
@@ -1012,6 +1083,10 @@ CONFIG_DE_AOC=y
 CONFIG_HISAX_1TR6=y
 CONFIG_HISAX_NI1=y
 CONFIG_HISAX_MAX_CARDS=8
+
+#
+#   HiSax supported cards
+#
 CONFIG_HISAX_16_0=y
 CONFIG_HISAX_16_3=y
 CONFIG_HISAX_AVM_A1=y
@@ -1130,7 +1205,7 @@ CONFIG_STALDRV=y
 CONFIG_STALLION=m
 CONFIG_ISTALLION=m
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=2048
+CONFIG_UNIX98_PTY_COUNT=512
 CONFIG_PRINTER=m
 CONFIG_LP_CONSOLE=y
 CONFIG_PPDEV=m
@@ -1225,6 +1300,10 @@ CONFIG_INPUT_CS461X=m
 CONFIG_INPUT_EMU10K1=m
 CONFIG_INPUT_SERIO=m
 CONFIG_INPUT_SERPORT=m
+
+#
+# Joysticks
+#
 CONFIG_INPUT_ANALOG=m
 CONFIG_INPUT_A3D=m
 CONFIG_INPUT_ADI=m
@@ -1245,11 +1324,11 @@ CONFIG_INPUT_DB9=m
 CONFIG_INPUT_GAMECON=m
 CONFIG_INPUT_TURBOGRAFX=m
 # CONFIG_QIC02_TAPE is not set
-CONFIG_IPMI_HANDLER=m
+# CONFIG_IPMI_HANDLER is not set
 # CONFIG_IPMI_PANIC_EVENT is not set
-CONFIG_IPMI_DEVICE_INTERFACE=m
-CONFIG_IPMI_KCS=m
-CONFIG_IPMI_WATCHDOG=m
+# CONFIG_IPMI_DEVICE_INTERFACE is not set
+# CONFIG_IPMI_KCS is not set
+# CONFIG_IPMI_WATCHDOG is not set
 
 #
 # Watchdog Cards
@@ -1293,6 +1372,10 @@ CONFIG_SONYPI=m
 CONFIG_FTAPE=m
 CONFIG_ZFTAPE=m
 CONFIG_ZFT_DFLT_BLK_SZ=10240
+
+#
+#   The compressor will be built as a module only!
+#
 CONFIG_ZFT_COMPRESSOR=m
 CONFIG_FT_NR_BUFFERS=3
 # CONFIG_FT_PROC_FS is not set
@@ -1300,6 +1383,10 @@ CONFIG_FT_NORMAL_DEBUG=y
 # CONFIG_FT_FULL_DEBUG is not set
 # CONFIG_FT_NO_TRACE is not set
 # CONFIG_FT_NO_TRACE_AT_ALL is not set
+
+#
+# Hardware configuration
+#
 CONFIG_FT_STD_FDC=y
 # CONFIG_FT_MACH2 is not set
 # CONFIG_FT_PROBE_FC10 is not set
@@ -1316,17 +1403,7 @@ CONFIG_AGP_AMD_8151=y
 CONFIG_AGP_SIS=y
 CONFIG_AGP_ALI=y
 CONFIG_AGP_SWORKS=y
-CONFIG_DRM=y
-# CONFIG_DRM_OLD is not set
-CONFIG_DRM_NEW=y
-CONFIG_DRM_TDFX=m
-CONFIG_DRM_R128=m
-CONFIG_DRM_RADEON=m
-CONFIG_DRM_I810=m
-# CONFIG_DRM_I810_XFREE_41 is not set
-CONFIG_DRM_I830=m
-CONFIG_DRM_MGA=m
-# CONFIG_DRM_SIS is not set
+# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
@@ -1346,6 +1423,10 @@ CONFIG_VIDEO_DEV=m
 #
 CONFIG_VIDEO_PROC_FS=y
 CONFIG_I2C_PARPORT=m
+
+#
+# Video Adapters
+#
 CONFIG_VIDEO_BT848=m
 CONFIG_VIDEO_PMS=m
 CONFIG_VIDEO_BWQCAM=m
@@ -1404,7 +1485,7 @@ CONFIG_REISERFS_FS=m
 # CONFIG_REISERFS_CHECK is not set
 CONFIG_REISERFS_PROC_INFO=y
 # CONFIG_ADFS_FS is not set
-CONFIG_AFS_FS=m
+# CONFIG_AFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 CONFIG_HFS_FS=m
@@ -1448,8 +1529,8 @@ CONFIG_DEVPTS_FS=y
 CONFIG_ROMFS_FS=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_XATTR_SHARING=y
-CONFIG_EXT2_FS_XATTR_USER=y
+# CONFIG_EXT2_FS_XATTR_SHARING is not set
+# CONFIG_EXT2_FS_XATTR_USER is not set
 CONFIG_SYSV_FS=m
 CONFIG_UDF_FS=m
 CONFIG_UDF_RW=y
@@ -1701,14 +1782,30 @@ CONFIG_SOUND_TVMIXER=m
 #
 CONFIG_USB=m
 # CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
 CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_BANDWIDTH is not set
+
+#
+# USB Host Controller Drivers
+#
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_UHCI=m
 CONFIG_USB_UHCI_ALT=m
 CONFIG_USB_OHCI=m
+
+#
+# USB Device Class drivers
+#
 CONFIG_USB_AUDIO=m
 # CONFIG_USB_EMI26 is not set
+
+#
+#   USB Bluetooth can only be used with disabled Bluetooth subsystem
+#
 CONFIG_USB_MIDI=m
 CONFIG_USB_STORAGE=m
 # CONFIG_USB_STORAGE_DEBUG is not set
@@ -1722,6 +1819,10 @@ CONFIG_USB_STORAGE_SDDR55=y
 CONFIG_USB_STORAGE_JUMPSHOT=y
 CONFIG_USB_ACM=m
 CONFIG_USB_PRINTER=m
+
+#
+# USB Human Interface Devices (HID)
+#
 CONFIG_USB_HID=m
 CONFIG_USB_HIDINPUT=y
 CONFIG_USB_HIDDEV=y
@@ -1731,11 +1832,19 @@ CONFIG_USB_AIPTEK=m
 CONFIG_USB_WACOM=m
 CONFIG_USB_KBTAB=m
 CONFIG_USB_POWERMATE=m
+
+#
+# USB Imaging devices
+#
 # CONFIG_USB_DC2XX is not set
 CONFIG_USB_MDC800=m
 CONFIG_USB_SCANNER=m
 CONFIG_USB_MICROTEK=m
 CONFIG_USB_HPUSBSCSI=m
+
+#
+# USB Multimedia devices
+#
 CONFIG_USB_IBMCAM=m
 CONFIG_USB_KONICAWC=m
 CONFIG_USB_OV511=m
@@ -1745,12 +1854,20 @@ CONFIG_USB_STV680=m
 CONFIG_USB_VICAM=m
 CONFIG_USB_DSBR=m
 CONFIG_USB_DABUSB=m
+
+#
+# USB Network adaptors
+#
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_RTL8150=m
 CONFIG_USB_KAWETH=m
 CONFIG_USB_CATC=m
 CONFIG_USB_CDCETHER=m
 CONFIG_USB_USBNET=m
+
+#
+# USB port drivers
+#
 CONFIG_USB_USS720=m
 
 #
@@ -1790,6 +1907,10 @@ CONFIG_USB_SERIAL_PL2303=m
 CONFIG_USB_SERIAL_CYBERJACK=m
 CONFIG_USB_SERIAL_XIRCOM=m
 CONFIG_USB_SERIAL_OMNINET=m
+
+#
+# USB Miscellaneous drivers
+#
 CONFIG_USB_RIO500=m
 CONFIG_USB_AUERSWALD=m
 CONFIG_USB_TIGL=m
@@ -1838,8 +1959,7 @@ CONFIG_BLUEZ_HCIVHCI=m
 #
 # Profiling support
 #
-CONFIG_PROFILING=y
-CONFIG_OPROFILE=m
+# CONFIG_PROFILING is not set
 
 #
 # Kernel hacking
index 6a12e48..47585d9 100644 (file)
@@ -1,5 +1,11 @@
 KERNEL=linux-2.4.20-20.9.tar.gz
 SERIES=rh-2.4.20
-CONFIG=linux-2.4.20-rh-i686-smp.config
 VERSION=2.4.20
 EXTRA_VERSION=20.9
+
+BASE_ARCHS="i386"
+BIGMEM_ARCHS=""
+BOOT_ARCHS=""
+JENSEN_ARCHS=""
+SMP_ARCHS="i686"
+UP_ARCHS=""
diff --git a/lustre/scripts/linux-merge-config.awk b/lustre/scripts/linux-merge-config.awk
new file mode 100644 (file)
index 0000000..9a9338c
--- /dev/null
@@ -0,0 +1,317 @@
+#!/bin/awk -f
+BEGIN {
+       nsects = 0
+}
+{
+       ARCH = $1
+       ARCHES[ARCH] = 1
+       TYPE = $2
+       TYPES[TYPE] = 1
+       NTOTAL++
+       ARCHTYPES[ARCH ":" TYPE] = 1
+       NARCHES[TYPE]++
+       if (NARCHES[TYPE] == 1)
+           NTOTALTYPES++
+       NTYPES[ARCH]++
+       if (NTYPES[ARCH] == 1)
+           NTOTALARCHES++
+       FILE = $3
+       cursects = nsects
+       while ((getline < FILE) > 0) {
+               if ($0 ~ /^\/\*/ || $0 ~ /^ \*\// || $0 ~ /^[   ]*$/)
+                       continue
+               if ($0 ~ /^ * /) {
+                       SECTION = gensub(/^ \* /,"",$0)
+                       if (!(SECTION in sectno)) {
+                               sectno[SECTION] = nsects
+                               counts[SECTION] = 0
+                               nsects++
+                       } else if (cursects && cursects != nsects) {
+                               no = sectno[SECTION]
+                               diff = nsects - cursects
+                               for (s in sectno) {
+                                       if (sectno[s] >= cursects)
+                                               sectno[s] = sectno[s] - cursects + no
+                                       else if (sectno[s] >= no)
+                                               sectno[s] += diff
+                               }
+                       }
+                       cursects = nsect
+                       cursym[SECTION] = counts[SECTION]
+                       continue
+               }
+               if ($1 != "#define" && $1 != "#undef")
+                       exit 1
+               SYMBOL = $2
+               n = index($0,SYMBOL)+length(SYMBOL)
+               if ($1 == "#define") {
+                       n = index($0,SYMBOL)+length(SYMBOL)
+                       VALUE = gensub(/^[      ]*/,"","",substr($0,n))
+                       if (VALUE == "") VALUE = "__novalue__"
+               } else
+                       VALUE = "__undefined__"
+               if (values[SYMBOL]) {
+                       if (present[SYMBOL,ARCH,TYPE]) continue
+                       present[SYMBOL,ARCH,TYPE] = 1
+                       values[SYMBOL] = values[SYMBOL] SUBSEP ARCH ":" TYPE ":" VALUE
+                       if (SECTION == sections[SYMBOL] && cursym[SECTION] && cursym[SECTION] != counts[SECTION]) {
+                               no = pos[SYMBOL]
+                               diff = counts[SECTION]-cursym[SECTION]
+                               for (s in pos)
+                                       if (sections[s] == SECTION) {
+                                               if (pos[s] >= cursym[SECTION])
+                                                       pos[s] = pos[s] - cursym[SECTION] + no
+                                               else if (pos[s] >= no)
+                                                       pos[s] += diff
+                                       }
+                               cursym[SECTION] = counts[SECTION]
+                       }
+               } else {
+                       present[SYMBOL,ARCH,TYPE] = 1
+                       values[SYMBOL] = ARCH ":" TYPE ":" VALUE
+                       sections[SYMBOL] = SECTION
+                       pos[SYMBOL] = counts[SECTION]
+                       counts[SECTION]++
+               }
+       }
+       close(FILE)
+}
+END {
+       for (SECTION in sectno)
+               x[sectno[SECTION]] = SECTION
+       for (i = 0; i < nsects; i++) {
+               SECTION = x[i]
+               if (i > 0)
+                       printf "\n"
+               printf "/*\n * %s\n */\n", SECTION
+               split("",lines)
+               lastelse = ""
+               for (SYMBOL in sections)
+                       if (sections[SYMBOL] == SECTION)
+                               y[pos[SYMBOL]] = SYMBOL
+               for (j = 0; j < counts[SECTION]; j++) {
+                       SYMBOL = y[j]
+                       split("",ntype)
+                       split("",total)
+                       split(values[SYMBOL],z,SUBSEP)
+                       split("",val)
+                       totalsum = 0
+                       for (k in z) {
+                               split(z[k],l,":")
+                               ARCH = l[1]
+                               TYPE = l[2]
+                               VALUE = substr(z[k],length(ARCH)+length(TYPE)+3)
+                               if (val[VALUE])
+                                       val[VALUE] = val[VALUE] " "
+                               val[VALUE] = val[VALUE] ARCH ":" TYPE
+                               ntype[VALUE,TYPE] += 1
+                               total[VALUE] += 1
+                               totalsum += 1
+                       }
+                       split("",curlines)
+                       append = 1
+                       for (VALUE in val) {
+                           if (total[VALUE] == NTOTAL) {
+                               if (VALUE == "__undefined__")
+                                   curlines["1"] = "#undef  " SYMBOL "\n"
+                               else if (VALUE == "__novalue__")
+                                   curlines["1"] = "#define " SYMBOL "\n"
+                               else
+                                   curlines["1"] = "#define " SYMBOL " " VALUE "\n"
+                               if (!lines["1"])
+                                   append = 0
+                               break
+                           }
+                           shorteststr = ""
+                           curcount = 0
+                           for (m = 0; m < 4; m++) {
+                               str = ""
+                               split(val[VALUE],yy)
+                               if (total[VALUE] > 1 && total[VALUE] == NTOTAL - 1) {
+                                   found = 0
+                                   for (arch in ARCHES) {
+                                       for (type in TYPES) {
+                                           archtype = arch ":" type
+                                           if (ARCHTYPES [archtype] == 1) {
+                                               for (n in yy)
+                                                   if (yy[n] == archtype)
+                                                       break
+                                               if (yy[n] != archtype) {
+                                                   found = 1
+                                                   break
+                                               }
+                                           }
+                                       }
+                                       if (found)
+                                           break
+                                   }
+                                   if (NARCHES[type] > 1 && NTYPES[arch] > 1) {
+                                       str = "!defined(__module__" arch "_" type ")"
+                                       shorteststr = str
+                                       break
+                                   }
+                               }
+                               if (m == 0 || m == 2) {
+                                   nfull = 0
+                                   split("",yysave)
+                                   for (type in TYPES)
+                                       if (ntype[VALUE,type] == NARCHES[type]) {
+                                           if (str) str = str " || "
+                                           str = str "defined(__module__" type ")"
+                                           for (k in yy) {
+                                               split(yy[k], z, ":")
+                                               if (z[2] == type) {
+                                                   yysave[k] = yy[k]
+                                                   delete yy[k]
+                                               }
+                                           }
+                                           nfull++
+                                       } else
+                                           NOTYPE = type
+                                   if (m < 2 && nfull > 1 && nfull == NTOTALTYPES - 1) {
+                                       str = "!defined(__module__" NOTYPE ")"
+                                       for (k in yysave)
+                                           yy[k] = yysave[k]
+                                       for (k in yy) {
+                                           split(yy[k], z, ":")
+                                           if (z[2] != NOTYPE)
+                                               delete yy[k]
+                                       }
+                                   }
+                               }
+                               savestr = str
+                               nfull = 0
+                               split("",yysave)
+                               for (arch in ARCHES) {
+                                   narch = 0
+                                   for (k in yy) {
+                                       split(yy[k], z, ":")
+                                       if (z[1] == arch)
+                                           narch++
+                                   }
+                                   if (narch == NTYPES[arch]) {
+                                       if (str) str = str " || "
+                                       str = str "defined(__module__" arch ")"
+                                       for (k in yy) {
+                                           split(yy[k], z, ":")
+                                           if (z[1] == arch) {
+                                               yysave[k] = yy[k]
+                                               delete yy[k]
+                                           }
+                                       }
+                                       nfull++
+                                   } else
+                                       NOARCH = arch
+                               }
+                               if (m < 2 && nfull > 1 && nfull == NTOTALARCHES - 1) {
+                                   str = savestr
+                                   for (k in yysave)
+                                       yy[k] = yysave[k]
+                                   if (str) str = str " || "
+                                   str = str "!defined(__module__" NOARCH ")"
+                                   for (k in yy) {
+                                       split(yy[k], z, ":")
+                                       if (z[1] != NOARCH)
+                                           delete yy[k]
+                                   }
+                               }
+                               if (m == 1 || m == 3) {
+                                   savestr = str
+                                   nfull = 0
+                                   split("",yysave)
+                                   for (type in TYPES) {
+                                       ntypex = 0
+                                       for (k in yy) {
+                                           split(yy[k], z, ":")
+                                           if (z[2] == type)
+                                               ntypex++
+                                       }
+                                       if (ntypex == NARCHES[type]) {
+                                           if (str) str = str " || "
+                                           str = str "defined(__module__" type ")"
+                                           for (k in yy) {
+                                               split(yy[k], z, ":")
+                                               if (z[2] == type) {
+                                                   yysave[k] = yy[k]
+                                                   delete yy[k]
+                                               }
+                                           }
+                                           nfull++
+                                       } else
+                                           NOTYPE = type
+                                   }
+                                   if (m < 2 && nfull > 1 && nfull == NTOTALTYPES - 1) {
+                                       str = savestr
+                                       for (k in yysave)
+                                           yy[k] = yysave[k]
+                                       if (str) str = str " || "
+                                       str = "!defined(__module__" NOTYPE ")"
+                                       for (k in yy) {
+                                           split(yy[k], z, ":")
+                                           if (z[2] != NOTYPE)
+                                               delete yy[k]
+                                       }
+                                   }
+                               }
+                               for (k in yy) {
+                                   split(yy[k], z, ":")
+                                   if (str) str = str " || "
+                                   str = str "defined(__module__" z[1] "_" z[2] ")"
+                               }
+                               if (m == 0 || length(str) < length(shorteststr))
+                                   shorteststr = str
+                           }
+                           str = shorteststr
+                           if (VALUE == "__undefined__")
+                               curlines[str] = "#undef  " SYMBOL "\n"
+                           else if (VALUE == "__novalue__")
+                               curlines[str] = "#define " SYMBOL "\n"
+                           else
+                               curlines[str] = "#define " SYMBOL " " VALUE "\n"
+                           if (!lines[str])
+                               append = 0
+                       }
+                       if (append) {
+                           for (str in curlines)
+                               if (curlines[str])
+                                   lines[str] = lines[str] curlines[str]
+                       } else {
+                           if (lines["1"])
+                               printf "%s", lines["1"]
+                           else if (j > 0) {
+                               ifstr = "#if "
+                               for (str in lines)
+                                   if (lines[str] && str != lastelse) {
+                                       printf "%s %s\n%s", ifstr, str, lines[str]
+                                       ifstr = "#elif "
+                                   }
+                               if (lastelse != "")
+                                   printf "#else\n%s", lines[lastelse]
+                               printf "#endif\n"
+                           }
+                           split("",lines)
+                           lastelse = ""
+                           for (str in curlines)
+                               if (curlines[str]) {
+                                   lines[str] = curlines[str]
+                                   if (totalsum == NTOTAL && length(str) > length(lastelse)) {
+                                       lastelse = str
+                                   }
+                               }
+                       }
+               }
+               if (lines["1"])
+                   printf "%s", lines["1"]
+               else if (j > 0) {
+                   ifstr = "#if "
+                   for (str in lines)
+                       if (lines[str] && str != lastelse) {
+                           printf "%s %s\n%s", ifstr, str, lines[str]
+                           ifstr = "#elif "
+                       }
+                   if (lastelse != "")
+                       printf "#else\n%s", lines[lastelse]
+                   printf "#endif\n"
+               }
+       }
+}
diff --git a/lustre/scripts/linux-merge-modules.awk b/lustre/scripts/linux-merge-modules.awk
new file mode 100644 (file)
index 0000000..babc815
--- /dev/null
@@ -0,0 +1,125 @@
+#!/bin/awk -f
+{
+       # lines in input look like ARCH TYPE path/to/TYPE/ARCH/modules/foo.ver
+       ARCH=$1
+       ARCHES[ARCH]=1
+       TYPE=$2
+       TYPES[TYPE]=1
+       NTOTAL++
+       NARCHES[TYPE]++
+       NTYPES[ARCH]++
+       FILE=$3
+
+       # read files that look like pairs of repeating
+       # #define __ver_foo hexstring
+       # #define foo _set_ver(foo)
+       while ((getline < FILE) > 0) {
+               if ($0 ~ /^[    ]*$/)
+                       continue
+               if ($1 != "#define" || $2 !~ /^__ver_/)
+                       exit 1
+
+               # this is a "#define __ver_foo somehex" line
+               SYMBOL=gensub(/^__ver_/,"","",$2)
+               VALUE=gensub(/^(smp_|2gig_|smp2gig_)/,"","",$3)
+               VALUE=gensub(/^(smp|2gig|smp2gig)/,"","",VALUE)
+               values[SYMBOL,ARCH,TYPE]=VALUE
+
+               # skip the "#define foo _set_ver(foo)" line
+               if ((getline < FILE) <= 0)
+                       exit 2
+               if ($1 != "#define" || $2 != SYMBOL || $3 != "_set_ver(" SYMBOL ")")
+                       exit 3
+       }
+       close(FILE)
+}
+END {
+       count=0
+       for (key in values)
+               if (values[key]) {
+                       count++
+                       split(key,x,SUBSEP)
+                       SYMBOL=x[1]
+                       ARCH=x[2]
+                       TYPE=x[3]
+
+                       # (re)initialize a few arrays to have no elements
+                       split("",x)
+                       split("",ntype)
+                       split("",total)
+
+                       totalsum=0
+                       for (arch in ARCHES)
+                           for (type in TYPES)
+                               if (values[SYMBOL,arch,type]) {
+                                   VALUE = values[SYMBOL,arch,type]
+                                   values[SYMBOL,arch,type] = ""
+                                   ntype[VALUE,type] += 1
+                                   total[VALUE] += 1
+                                   if (x[VALUE])
+                                       x[VALUE] = x[VALUE] " "
+                                   x[VALUE] = x[VALUE] arch ":" type
+                               }
+                       ifstr="#if "
+                       for (VALUE in x) {
+                           if (total[VALUE] == NTOTAL) {
+                               # there is only one checksum for this symbol
+                               printf "#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE
+                               printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL
+                               break
+                           }
+
+                           totalsum += total[VALUE]
+                           if (totalsum == NTOTAL && ifstr == "#elif") {
+                               # this is the last unique checksum for this symbol
+                               printf "#else\n#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE
+                               printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL
+                               break
+                           }
+
+                           # there must be more than one checksum still to
+                           # print for this symbol
+                           str=""
+                           split(x[VALUE],y)
+                           for (type in TYPES)
+                               if (ntype[VALUE,type] == NARCHES[type]) {
+                                   if (str) str = str " || "
+                                   str = str "defined(__module__" type ")"
+                                   for (k in y) {
+                                       split(y[k], z, ":")
+                                       if (z[2] == type)
+                                           delete y[k]
+                                   }
+                               }
+                           for (arch in ARCHES) {
+                               narch=0
+                               for (k in y) {
+                                   split(y[k], z, ":")
+                                   if (z[1] == arch)
+                                       narch++
+                               }
+                               if (narch == NTYPES[arch]) {
+                                   if (str) str = str " || "
+                                   str = str "defined(__module__" arch ")"
+                                   for (k in y) {
+                                       split(y[k], z, ":")
+                                       if (z[1] == arch)
+                                           delete y[k]
+                                   }
+                               }
+                           }
+                           for (k in y) {
+                               split(y[k], z, ":")
+                               if (str) str = str " || "
+                               str = str "defined(__module__" z[1] "_" z[2] ")"
+                           }
+                           printf "%s %s\n#define __ver_%s\t_ver_str(%s)\n", ifstr, str, SYMBOL, VALUE
+                           printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL
+                           ifstr="#elif "
+                       }
+                       if (ifstr == "#elif ")
+                           printf "#endif\n"
+               }
+       if (!count)
+               printf "\n"
+}
index 46fc85c..addbe4f 100755 (executable)
@@ -3,18 +3,37 @@
 # option variables
 DESTDIR=
 KERNELDIR=
-PHASE=
 TARGET=
+# Not sure what to put here
+# TARGET_ARCH=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+TARGET_ARCH="i386"
+TARGET_CONFIG=
 JOBS=1
 CONFIGURE_FLAGS=
 
-# provide by target file
+# commands to run
+BUILD_LUSTRE=0
+BUILD_KERNEL=0
+DEPEND_KERNEL=0
+INSTALL_LUSTRE=0
+INSTALL_KERNEL=0
+SAVE_HEADERS=0
+UNPACK_KERNEL=0
+
+# provided by target file
 KERNEL=
 SERIES=
 CONFIG=
 VERSION=
 EXTRA_VERSION=
 
+BASE_ARCH=
+BIGMEM_ARCHS=
+BOOT_ARCHS=
+JENSEN_ARCHS=
+SMP_ARCHS=
+UP_ARCHS=
+
 # flat-out globals
 TOPDIR=
 TARGET_FILE=
@@ -60,38 +79,69 @@ usage()
     cat <<EOF
 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
 
-${0##*/} has two phases.  The build phase, and the install phase.  The
-phase is specified with the --phase option:
+Options:
+
+  --build
+    same as --build-kernel --build-lustre --unpack-kernel
+
+  --build-lustre
+    configure and compile lustre.  Requires that --build-kernel was
+    already run.
 
-  --phase=build/install
+  --build-kernel
+    configure and compile a kernel.  Implies --depend-kernel.
+    Requires that --unpack-kernel was already run.
+
+  --depend-kernel)
+    Prepares a kernel tree for building (similar to make mrproper
+    oldconfig dep).  Requires that --unpack-kernel was already run.
+
+  --destdir=DESTDIR
+    Root directory to install into (like DESTDIR with auto*).
 
-Options not requiring a phase:
+  --extraversion=EXTRAVERSION
+    Overrides the target kernel\'s EXTRAVERSION text.
 
   -h, --help
     Display this message.
 
-Options appropriate with both phases include:
+  --install
+    same as --install-kernel --install-lustre
+
+  --install-lustre
+    run make install in the Lustre tree.
+
+  --install-kernel
+    install the kernel image and modules.
 
   -j jobs
     This works just like the -j option to make, and is passed to make
     when building.
 
+  --kerneldir=KERNELDIR
+    Directory containing linux source tarballs.
+
   --target=TARGET
     Name of the configuration to use.  The available targets are
     listed below.
 
-Options appropriate with the build phase are:
+  --target-arch=ARCH
+    Specifies an architecture to use when choosing a kernel config
+    file.  Default is i386.
 
-  --kerneldir=KERNELDIR
-    Directory containing linux source tarballs.
+  --target-config=CONFIG
+    Specifies a special option (such as smp, bigmem, or BOOT) to use
+    when choosing a kernel config file.  This also modifies the kernel
+    version and modules directory.
 
-  --extraversion=EXTRAVERSION
-    Overrides the target kernel\'s EXTRAVERSION text.
+  --unpack-kernel
+    Untars and patches the kernel source.
 
-Options appropriate with the install phase are:
+  The order that commands (--build-lustre, --unpack-kernel) are
+  specified on the command line is ignored; ${0##*/} will always
+  execute them in the correct order (unpack, then build, then install
+  etc.).
 
-  --destdir=DESTDIR
-       Root directory to install into (like DESTDIR with auto*).
 EOF
     list_targets
 
@@ -100,26 +150,27 @@ EOF
 
 check_options()
 {
-    [ "$PHASE" ] || usage 1 "A phase must be specified with --phase"
-    case "$PHASE" in
-       build)
-           [ "$KERNELDIR" ] || \
-               usage 1 "A kernel directory must be specified with --kerneldir."
-           [ -d "$KERNELDIR" ] || \
-               usage 1 "$KERNELDIR is not a directory."
-           ;;
-       install)
-           [ -z "$DESTDIR" -o -d "$DESTDIR" ] || \
-               usage 1 "$DESTDIR is not a directory."
-           ;;
-       *)
-           usage 1 "Phase must be build or install."
-           ;;
-    esac
+    (( $BUILD_LUSTRE || $BUILD_KERNEL || $DEPEND_KERNEL || \
+           $INSTALL_LUSTRE || $INSTALL_KERNEL || $SAVE_HEADERS || \
+           $UNPACK_KERNEL )) || \
+               fatal 1 "No commands specified."
+
+    if (( $UNPACK_KERNEL )) ; then
+       [ "$KERNELDIR" ] || \
+           fatal 1 "A kernel directory must be specified with --kerneldir."
+       [ -d "$KERNELDIR" ] || \
+           fatal 1 "$KERNELDIR is not a directory."
+    fi
+
+    if (( $INSTALL_LUSTRE || $INSTALL_KERNEL || $SAVE_HEADERS )) ; then
+       [ -z "$DESTDIR" -o -d "$DESTDIR" ] || \
+           fatal 1 "$DESTDIR is not a directory."
+    fi
+
     [ "$TARGET" ] || usage 1 "A target must be specified with --target."
     TARGET_FILE="$TOPDIR/kernel_patches/targets/$TARGET.target"
     [ -r "$TARGET_FILE" ] || \
-       usage 1 "Target '$TARGET' was not found.  Try --list-targets."
+       fatal 1 "Target '$TARGET' was not found.  Try --list-targets."
 
     if [ -z "$JOBS" -o "$JOBS" -lt "1" ] ; then
        JOBS=1
@@ -128,14 +179,12 @@ check_options()
 
 get_lustre_version()
 {
-    for patch in $(<"$SERIES_FILE") ; do
-       if [ "${patch#lustre_version}" = "${patch}" ] ; then
-           continue
-       fi
-       awk '/^#define LUSTRE_VERSION_VERSION /{ print $3 }' \
-           < "$TOPDIR/kernel_patches/patches/$patch" 2>/dev/null
-       break
-    done
+    lustre_patch=$(grep lustre_version "$SERIES_FILE" 2>/dev/null)
+    [ "$lustre_patch" ] || \
+       fatal 1 "Could not determine Lustre version from $SERIES series."
+
+    awk '/^\+#define LUSTRE_KERNEL_VERSION /{ print $3 }' \
+       "$TOPDIR/kernel_patches/patches/$lustre_patch" 2>/dev/null
 }
 
 load_target()
@@ -146,7 +195,7 @@ load_target()
 
     [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
     [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
-    [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
+#    [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify the kernel version."
     
     if [ "$KERNELDIR" ] ; then
@@ -159,16 +208,17 @@ load_target()
     [ -r "$SERIES_FILE" ] || \
        fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/kernel_patches/series."
 
-    CONFIG_FILE="$TOPDIR/kernel_patches/kernel_configs/$CONFIG"
+    CONFIG_TARGET="$TARGET${TARGET_ARCH:+-$TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
+    CONFIG_FILE="$TOPDIR/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
     [ -r "$CONFIG_FILE" ] || \
        fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/kernel_patches/configs."
 
     if [ "$EXTRA_VERSION_save" ] ; then
        EXTRA_VERSION="$EXTRA_VERSION_save"
     else
-       EXTRA_VERSION="${EXTRA_VERSION}_$(get_lustre_version)"
+       EXTRA_VERSION="${EXTRA_VERSION}_lustre.$(get_lustre_version)"
     fi
-    EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e s/-/_/g)
+    EXTRA_VERSION=${EXTRA_VERSION//-/_}
 }
 
 tarflags()
@@ -198,7 +248,12 @@ untar()
 
 extract_kernel()
 {
+    (( $UNPACK_KERNEL )) || return 0
     pushd "$TOPDIR" >/dev/null
+    if [ -d linux ] ; then
+       [ -L linux ] && rm -rf $(readlink linux)
+       rm -rf linux
+    fi
     untar "$KERNEL_FILE"
     [ -d linux ] || ln -sf linux* linux
     popd >/dev/null
@@ -206,42 +261,62 @@ extract_kernel()
 
 patch_kernel()
 {
+    (( $UNPACK_KERNEL )) || return 0
     pushd "$TOPDIR/linux" >/dev/null
-    echo "Overriding EXTRAVERSION in kernel..."
-    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${EXTRA_VERSION}/" Makefile
     echo -n "Applying patch"
     for patch in $(<"$SERIES_FILE") ; do
        PATCH_FILE="$TOPDIR/kernel_patches/patches/$patch"
        [ -r "$PATCH_FILE" ] || \
            fatal 1 "Patch file not found: $patch"
        echo -n " $patch"
-       patch -s -p1 < "$PATCH_FILE"
+       patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
     done
     echo
     popd >/dev/null
 }
 
-build_kernel()
+depend_kernel()
 {
+    (( $DEPEND_KERNEL )) || return 0
     # we need to override $CC at make time, since there is no
     # configure
     MAKE="make -s CC=$CC"
     pushd "$TOPDIR/linux" >/dev/null
+    echo "Overriding EXTRAVERSION in kernel..."
+    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${EXTRA_VERSION}${TARGET_CONFIG}/" Makefile
     echo "Making depend in $PWD..."
-    make -s mrproper || fatal 1 "Error running make mrproper"
+    $MAKE mrproper || fatal 1 "Error running make mrproper"
     cp "$CONFIG_FILE" .config
-    $MAKE -s oldconfig_nonint || fatal 1 "Error running make oldconfig"
-    $MAKE -j $JOBS -s dep || fatal 1 "Error running make dep"
-    $MAKE -s include/linux/version.h || fatal 1 "Error making include/linux/version.h"
+    $MAKE oldconfig_nonint || fatal 1 "Error running make oldconfig"
+    $MAKE -j $JOBS dep || fatal 1 "Error running make dep"
+    $MAKE include/linux/version.h || fatal 1 "Error making include/linux/version.h"
+}
+
+build_kernel()
+{
+    (( $BUILD_KERNEL )) || return 0
+    # we need to override $CC at make time, since there is no
+    # configure
+    MAKE="make -s CC=$CC"
     echo "Building kernel in $PWD..."
-    $MAKE -j $JOBS -s bzImage || fatal 1 "Error making bzImage."
+    case "$TARGET_ARCH" in
+       i386 | i586 | i686 | athlon | x86_64)
+           $MAKE -j $JOBS -s bzImage || fatal 1 "Error making bzImage."
+           ;;
+       *)
+           $MAKE -j $JOBS -s boot || fatal 1 "Error making boot."
+           ;;
+    esac
     $MAKE -j $JOBS -s modules || fatal 1 "Error building modules."
+
     popd >/dev/null
 }
 
 configure_lustre()
 {
+    (( $BUILD_LUSTRE )) || return 0
     pushd "$TOPDIR" >/dev/null
+    [ -f Makefile ] && make -s clean
     [ -f configure ] || sh ./autogen.sh
     ./configure --with-linux=$PWD/linux $CONFIGURE_FLAGS || \
        fatal 1 "Error configuring Lustre."
@@ -250,6 +325,7 @@ configure_lustre()
 
 build_lustre()
 {
+    (( $BUILD_LUSTRE )) || return 0
     pushd "$TOPDIR" >/dev/null
     make -j $JOBS -s
     popd >/dev/null
@@ -257,25 +333,104 @@ build_lustre()
 
 install_kernel()
 {
-    FULL_VERSION="${VERSION}-${EXTRA_VERSION}"
+    (( $INSTALL_KERNEL )) || return 0
+    FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}"
     pushd "$TOPDIR/linux" >/dev/null
-    mkdir -p "$DESTDIR/boot" "$DESTDIR/lib/modules"
-    INSTALL_MOD_PATH="$DESTDIR" make CC=$CC -s modules_install || \
+    mkdir -p "$DESTDIR/boot"
+
+    install -m 644 System.map "$DESTDIR/boot/System.map-${FULL_VERSION}"
+    # install -m 644 module-info ...
+    install -m 644 "$CONFIG_FILE" "$DESTDIR/boot/config-${FULL_VERSION}"
+
+    mkdir -p "$DESTDIR/dev/shm"
+
+    case "$TARGET_ARCH" in
+       i386 | i586 | i686 | athlon)
+           cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+           cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+           ;;
+       x86_64)
+           cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+           cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+           ;;
+       ia64)
+           gzip -cfv vmlinux > vmlinuz
+           mkdir -p "$DESTDIR/boot/efi/redhat"
+           install -m 755 vmlinux "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
+           install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
+           ln -sf "efi/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+           ln -sf "efi/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+           ;;
+       *)
+           cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+           cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+           ;;
+    esac
+
+    mkdir -p "$DESTDIR/lib/modules/${FULL_VERSION}"
+    make CC="$CC" INSTALL_MOD_PATH="$DESTDIR" KERNELRELEASE="$FULL_VERSION" \
+       -s modules_install || \
        fatal 1 "Error installing modules."
-    cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-    cp System.map "$DESTDIR/boot/System.map-${FULL_VERSION}"
-    cp .config "$DESTDIR/boot/config-${FULL_VERSION}"
+
     popd >/dev/null
 }
 
 install_lustre()
 {
+    (( $INSTALL_LUSTRE )) || return 0
+    FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}"
     pushd "$TOPDIR" >/dev/null
-    make -s install "DESTDIR=$DESTDIR" || fatal 1 "Error installing Lustre."
+    make -s install "DESTDIR=$DESTDIR" KERNELRELEASE="$FULL_VERSION" || fatal 1 "Error installing Lustre."
     popd >/dev/null
 }
 
-options=$(getopt -o hj: -l destdir:,extraversion:,help,kerneldir:,phase:,target: -- "$@")
+save_headers()
+{
+    echo "Saving headers for $1 $2..."
+    pushd linux >/dev/null
+
+    KVERREL="${VERSION}-${EXTRA_VERSION}"
+    # deal with the kernel headers that are version specific
+    
+    saveddir="$RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/$2/$1"
+    mkdir -p "$saveddir"
+    install -m 644 include/linux/autoconf.h "$saveddir/autoconf.h"
+    install -m 644 include/linux/version.h  "$saveddir/version.h"
+    mv include/linux/modules "$saveddir/"
+    echo $2 $1 ../../savedheaders/$2/$1/ >>  $RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/list
+    popd >/dev/null
+}
+
+save_all_headers()
+{
+    (( $SAVE_HEADERS )) || return 0
+
+    for arch in $BIGMEM_ARCHS ; do
+       save_headers bigmem $arch
+    done
+
+    for arch in $BOOT_ARCHS ; do
+       save_headers BOOT $arch
+    done
+
+    for arch in $JENSEN_ARCHS ; do
+       save_headers jensen $arch
+    done
+
+    for arch in $SMP_ARCHS ; do
+       save_headers smp $arch
+    done
+
+    for arch in $UP_ARCHS ; do
+       save_headers up $arch
+    done
+}
+
+longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
+longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
+longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel"
+
+options=$(getopt -o hj: -l "$longopts" -- "$@")
 
 eval set -- "$options"
     
@@ -284,6 +439,26 @@ while [ "$1" ] ; do
        '')
            usage 1
            ;;
+       --build)
+           BUILD_LUSTRE=1
+           BUILD_KERNEL=1
+           DEPEND_KERNEL=1
+           UNPACK_KERNEL=1
+           shift
+           ;;
+       --build-lustre)
+           BUILD_LUSTRE=1
+           shift
+           ;;
+       --build-kernel)
+           BUILD_KERNEL=1
+           DEPEND_KERNEL=1
+           shift
+           ;;
+       --depend-kernel)
+           DEPEND_KERNEL=1
+           shift
+           ;;
        --destdir)
            DESTDIR=$2
            shift 2
@@ -295,6 +470,19 @@ while [ "$1" ] ; do
        --help | -h)
            usage 0
            ;;
+       --install)
+           INSTALL_LUSTRE=1
+           INSTALL_KERNEL=1
+           shift
+           ;;
+       --install-lustre)
+           INSTALL_LUSTRE=1
+           shift
+           ;;
+       --install-kernel)
+           INSTALL_KERNEL=1
+           shift
+           ;;
        -j)
            JOBS=$2
            shift 2
@@ -303,14 +491,26 @@ while [ "$1" ] ; do
            KERNELDIR=$2
            shift 2
            ;;
-       --phase)
-           PHASE=$2
-           shift 2
+       --save-headers)
+           SAVE_HEADERS=1
+           shift
            ;;
        --target)
            TARGET=$2
            shift 2
            ;;
+       --target-arch)
+           TARGET_ARCH=$2
+           shift 2
+           ;;
+       --target-config)
+           TARGET_CONFIG=$2
+           shift 2
+           ;;
+       --unpack-kernel)
+           UNPACK_KERNEL=1
+           shift
+           ;;
        --)
            shift
            CONFIGURE_FLAGS=$@
@@ -325,16 +525,18 @@ done
 check_options
 load_target
 
-case "$PHASE" in
-    build)
-       extract_kernel
-       patch_kernel
-       build_kernel
-       configure_lustre
-       build_lustre
-       ;;
-    install)
-       install_kernel
-       install_lustre
-       ;;
-esac
+extract_kernel
+patch_kernel
+
+depend_kernel
+build_kernel
+
+configure_lustre
+build_lustre
+
+install_kernel
+install_lustre
+
+save_all_headers
+
+exit 0
index 6eca2c9..78585d4 100644 (file)
@@ -1,9 +1,147 @@
+Summary: The Linux kernel (the core of the Linux operating system)
+
+# Versions of various parts
+
+#
+# Polite request for people who spin their own kernel rpms:
+# please modify the "release" field in a way that identifies
+# that the kernel isn't the stock RHL kernel, for example by
+# adding some text to the end of the version number.
+#
+%define kversion @KERNEL_VERSION@
+%define release @KERNEL_RELEASE@
+# /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
+%define kslnk linux-2.4
+
+# groups of related archs
+%define all_x86 i386 i686 i586 athlon
+#define all_x86 i686 i386 i586 athlon
+
+%define nptlarchs %{all_x86}
+#define nptlarchs noarch
+
+# disable build root strip policy
+%define __spec_install_post /usr/lib/rpm/brp-compress || :
+#
+# RPM foo magic
+%define _missing_doc_files_terminate_build    0
+%define _unpackaged_files_terminate_build 0
+%define debug_package %{nil}
+
+# Enable this to build a board-specific kernel configuration 
+# some architectures have LOTS of different setups and this 
+# is a way to deal with that cleanly.
+#
+#define targetboard assabet
+%define dashtargetboard %{?targetboard:-%{targetboard}}
+%define withtargetboard 0
+%{?targetboard: %{expand: %%define withtargetboard 1}}
+       
+# Override generic defaults with per-arch defaults (which can
+# themselves be overridden with --with/--without).  These must
+# ONLY be "0", never "1"
+
+%define buildbase 0
+%define buildbigmem 0
+%define buildBOOT 0
+%define buildjensen 0
+%define buildsmp 0
+%define buildup 0
+
+%ifarch @BASE_ARCHS@
+%define buildbase 1
+%endif
+
+%ifarch @BIGMEM_ARCHS@
+%define buildbigmem 1
+%endif
+
+%ifarch @BOOT_ARCHS@
+%define buildBOOT 1
+%endif
+
+%ifarch @JENSEN_ARCHS@
+%define buildjensen 1
+%endif
+
+%ifarch @SMP_ARCHS@
+%define buildsmp 1
+%endif
+
+%ifarch @UP_ARCHS@
+%define buildup 1
+%endif
+
+# For board-specific kernels, build only the normal kernel (which may actually be smp, not up).
+%if %{withtargetboard}
+%define buildsmp 0
+%define buildBOOT 0
+%define buildbigmem 0
+%define buildjensen 0
+%endif
+
+%if 0
+Second, per-architecture exclusions (ifarch)
+%ifarch i386
+%define buildsmp 0
+%endif
+%ifarch ia64
+%define buildBOOT 0
+%endif
+%endif
+
+# we can't test values inline, only whether a macro exists
+%{expand: %%define buildup_%{buildup} yadda}
+%{expand: %%define buildsmp_%{buildsmp} yadda}
+%{expand: %%define buildBOOT_%{buildBOOT} yadda}
+%{expand: %%define buildbigmem_%{buildbigmem} yadda}
+%{expand: %%define buildjensen_%{buildjensen} yadda}
+%{expand: %%define ikd_%{ikd} yadda}
+%{expand: %%define ibcs_%{ibcs} yadda}
+%{expand: %%define debuglevel_%{debugging} yadda}
+
+%{expand: %%define kernel_conflicts  ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 0.3.1, cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, e2fsprogs < 1.22, initscripts < 5.84, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0, oprofile < 0.4}
+
+%define BOOT_kernel_prereq fileutils, modutils >=  2.4.18
+%define kernel_prereq %{BOOT_kernel_prereq}, initscripts >= 5.83, mkinitrd >= 3.2.6
+%ifarch ia64
+%define initrd_dir /boot/efi/redhat
+%else
+%define initrd_dir /boot
+%endif
+
+%ifarch %{all_x86} x86_64
+%define kernel_glob vmlinu?-%{KVERREL}
+%endif
+%ifarch ia64
+# <sigh>, no GLOB_BRACE for filelists, efi needs to be done separately
+%define kernel_glob vmlinuz-%{KVERREL}
+%endif
+%ifarch alpha
+%define kernel_glob vmlinu?-%{KVERREL}
+%endif
+
 Name: kernel
-Summary: The Linux Kernel
-Version: @KERNEL_VERSION@
-Release: @KERNEL_RELEASE@
+Version: %{kversion}
+Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
+%define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE}
 License: GPL
 Group: System Environment/Kernel
+ExclusiveArch: %{all_x86} x86_64
+ExclusiveOS: Linux
+Obsoletes: kernel-modules, kernel-sparc
+Provides: kernel = %{version}
+BuildConflicts: rhbuildsys(DiscFree) < 500Mb
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+Autoreqprov: no
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+
+BuildPreReq: patch >= 2.5.4, bash >= 2.03, sh-utils, gnupg, tar
+BuildPreReq: bzip2, findutils, dev, gzip, m4
+
 Vendor: Cluster File Systems, Inc.
 URL: http://www.kernel.org/
 Buildroot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root
@@ -11,18 +149,123 @@ Buildroot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root
 Source0: @LUSTRE_SOURCE@
 Source1: @KERNEL_SOURCE@
 
-%define __spec_install_post /usr/lib/rpm/brp-compress || :
-%define debug_package %{nil}
+Source16: linux-merge-config.awk
+Source17: linux-merge-modules.awk
+
+%package source
+Summary: The source code for the Linux kernel.
+Group: Development/System
+Prereq: fileutils
+Requires: gawk
+Requires: gcc >= 2.96-98
+
+%package doc
+Summary: Various documentation bits found in the kernel source.
+Group: Documentation
 
 %description
-The Linux Kernel, the operating system core itself.
+The kernel package contains the Linux kernel (vmlinuz), the core of a
+Linux operating system.  The kernel handles the basic functions of the
+operating system: memory allocation, process allocation, device input
+and output, etc.
+
+%description source
+The kernel-source package contains the source code files for the Linux
+kernel. These source files are needed to build custom/third party device
+drivers. The source files can also be used to build a custom kernel that is
+better tuned to your particular hardware, if you are so inclined (and you
+know what you're doing).
+
+%description doc
+This package contains documentation files form the kernel
+source. Various bits of information about the Linux kernel and the
+device drivers shipped with it are documented in these files. 
+
+You'll want to install this package if you need a reference to the
+options that can be passed to Linux kernel modules at load time.
+
+%package smp
+Summary: The Linux kernel compiled for SMP machines.
+Group: System Environment/Kernel
+Provides: module-info, kernel = %{version}
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+
+%description smp
+This package includes a SMP version of the Linux kernel. It is
+required only on machines with two or more CPUs, although it should
+work fine on single-CPU boxes.
+
+Install the kernel-smp package if your machine uses two or more CPUs.
+
+%package bigmem
+Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
+Group: System Environment/Kernel
+Provides: module-info, kernel = %{version}
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+Obsoletes: kernel-enterprise <= 2.4.10
+
+%description bigmem
+This package includes a kernel that has appropriate configuration options
+enabled for Pentium III machines with 4 Gigabyte of memory or more.
+
+%package BOOT
+Summary: The version of the Linux kernel used on installation boot disks.
+Group: System Environment/Kernel
+Provides: kernel = %{version}
+Prereq: %{BOOT_kernel_prereq}
+Conflicts: %{kernel_conflicts}
+
+%description BOOT
+This package includes a trimmed down version of the Linux kernel.
+This kernel is used on the installation boot disks only and should not
+be used for an installed system, as many features in this kernel are
+turned off because of the size constraints.
+
+%package BOOTsmp
+Summary: The Linux kernel used on installation boot disks for SMP machines.
+Group: System Environment/Kernel
+Provides: kernel = %{version}
+Prereq: %{BOOT_kernel_prereq}
+Conflicts: %{kernel_conflicts}
+
+%description BOOTsmp
+This package includes a trimmed down version of the Linux kernel. This
+kernel is used on the installation boot disks only and should not be used
+for an installed system, as many features in this kernel are turned off
+because of the size constraints. This kernel is used when booting SMP
+machines that have trouble coming up to life with the uniprocessor kernel.
+
+%package jensen
+Summary: The Linux Kernel compiled for the Alpha Jensen platform.
+Group: System Environment/Kernel
+Provides: kernel = %{version}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+
+%description jensen
+This package includes a kernel that has appropriate configuration
+options enabled for use on the Alpha Jensen platform.  The Jensen
+platform is not supported in the normal generic alpha kernel support.
 
 %package -n lustre-lite-utils
 Summary: Lustre utils for Linux
 Group: Applications/System
 
 %description -n lustre-lite-utils
-The Lustre Lite file system utilities.
+The Lustre Lite file system utilities.  This includes the tools needed
+to configure, mount, and administer a Lustre filesystem.  This package
+is necessary if you want to access a Lustre filesystem.
+
+# the lustre-doc files are just included as %doc wiht
+# lustre-lite-utils
 
 #%package -n lustre-doc
 #Summary: Sample Lustre configurations and documentation
@@ -37,11 +280,20 @@ Summary: LDAP schema files for Lustre
 Group: System Environment/Daemons
 
 %description -n lustre-ldap
-LDAP schema files for Lustre.
+LDAP schema files for Lustre.  These are needed if you plan to store
+your Lustre configuration in LDAP, rather than on disk.
 
 %prep
 %setup -n lustre-kernel-%{version} -q -c
-[ -d lustre ] || ln -sf lustre* lustre
+if [ ! -d lustre ] ; then
+    ln -sf lustre* lustre
+fi
+pushd lustre >/dev/null
+sh -x ./scripts/lmake \
+       --unpack-kernel \
+       --target @LUSTRE_TARGET@ \
+       --kerneldir $RPM_SOURCE_DIR
+popd >/dev/null
 
 %build
 # if RPM_BUILD_NCPUS unset, set it
@@ -55,37 +307,448 @@ if [ -z "$RPM_BUILD_NCPUS" ] ; then
     fi
 fi
 
-pushd lustre >/dev/null
-./scripts/lmake \
-       --phase build \
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT
+
+DependKernel()
+{
+  target_config=${1:+--target-config $1}
+  sh -x ./scripts/lmake \
+       --depend-kernel \
        --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       ${target_config} \
+       --extraversion %{release} \
+       -j $RPM_BUILD_NCPUS
+}
+
+BuildKernel()
+{
+  target_config=${1:+--target-config $1}
+  sh -x ./scripts/lmake \
+       --build-kernel --build-lustre \
+       --install \
+       --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       ${target_config} \
        --extraversion %{release} \
        --kerneldir $RPM_SOURCE_DIR \
        -j $RPM_BUILD_NCPUS \
+       --destdir $RPM_BUILD_ROOT \
        -- @CONFIGURE_FLAGS@
-popd >/dev/null
+}
 
-%install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT
-pushd lustre >/dev/null
-./scripts/lmake \
-       --phase install \
+SaveHeaders()
+{
+  sh -x ./scripts/lmake \
+       --save-headers \
        --target @LUSTRE_TARGET@ \
        --extraversion %{release} \
        --destdir $RPM_BUILD_ROOT
+}
+
+pushd lustre >/dev/null
+
+%if %{buildbigmem}
+BuildKernel bigmem
+%endif
+
+%if %{buildBOOT}
+BuildKernel BOOT
+%endif
+
+%if %{buildjensen}
+BuildKernel jensen
+%endif
+
+%if %{buildsmp}
+BuildKernel smp
+%endif
+
+# we want this one last, so that it is the one populating /usr/bin
+%if %{buildup} || %{buildbase}
+BuildKernel
+%endif
+
+%if %{buildbase}
+SaveHeaders
+%endif
+
+popd >/dev/null
+
+%install
+pushd lustre >/dev/null
+# it's already installed, so just clean up some things that are rpm
+# specific
+for i in $RPM_BUILD_ROOT/lib/modules/* ; do
+  rm -f $i/modules.*
+  rm -f $i/build
+  ln -sf ../../../usr/src/linux-%{KVERREL} $i/build
+%ifarch %{ntplarchs}
+  # remove legacy pcmcia symlink that's no longer useful
+  rm -rf $i/pcmcia
+%endif
+done
+
+# mark the vmlinux* non-executable to fool strip-to-file
+chmod a-x $RPM_BUILD_ROOT/boot/vmlinux*
+
+##
+## do -source package cleanup/install
+##
+%if %{buildbase}
+pushd linux >/dev/null
+mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
+tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
+ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
+# install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+
+#clean up the destination
+make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+cp ../kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
+cp ../kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
+make -s oldconfig_nonint -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+make -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+make -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+
+#this generates modversions info which we want to include and we may as
+#well include the depends stuff as well, after we fix the paths
+make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \
+while read file ; do
+    mv $file $file.old
+    sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file
+    rm -f $file.old
+done
+
+# Try to put some smarter autoconf.h and version.h files in place
+pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; {
+rm -rf modules modversions.h autoconf.h version.h
+cat > modversions.h <<EOF
+#ifndef _LINUX_MODVERSIONS_H
+#define _LINUX_MODVERSIONS_H
+#include <linux/rhconfig.h>
+#include <linux/modsetver.h>
+EOF
+echo '#include <linux/rhconfig.h>' > autoconf.h
+list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort`
+mkdir modules
+for l in $list; do
+    sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l
+    touch -r modules/$l modules/`basename $l .ver`.stamp
+    echo '#include <linux/modules/'$l'>' >> modversions.h
+done
+echo '#endif' >> modversions.h
+sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
+# install -m 644 %{SOURCE15} rhconfig.h
+echo "#include <linux/rhconfig.h>" >> version.h
+keyword=if
+for i in smp BOOT BOOTsmp bigmem  up ; do
+# When we build in an i386, we don't have an bigmem header directory
+# in savedheaders/i386/bigmem.  We also don't have a BOOT directory
+# anywhere except in savedheaders/i386.  So, we need to use this method
+# of determining if a kernel version string needs to be included in the
+# version.h file
+    verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
+    if [ -n "$verh" -a -f "$verh" ]; then
+       if [ "$i" = up ]; then
+           if [ "$keyword" = if ]; then
+               echo "#if 0" >> version.h
+           fi
+           echo "#else" >> version.h
+       else
+           echo "#$keyword defined(__module__$i)" >> version.h
+           keyword=elif
+       fi
+       grep UTS_RELEASE $verh >> version.h
+    fi
+done
+echo "#endif" >> version.h
+if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then
+    # keep to a standard normally
+    HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h
+else
+    # test build not including uniprocessor, must get info from somewhere
+    HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -1)
+fi
+grep -v UTS_RELEASE $HEADER_FILE >> version.h
+rm -rf ../../savedheaders
+} ; popd
+touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion}
+
+rm -f $RPM_BUILD_ROOT/usr/include/linux
+
+rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders
+
+# fix up the tmp_include_depends file wrt the buildroot
+perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends
+popd >/dev/null
+%endif
+
 popd >/dev/null
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+###
+### scripts
+###
+
+# do this for upgrades...in case the old modules get removed we have
+# loopback in the kernel so that mkinitrd will work.
+%pre 
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+exit 0
+
+%pre smp
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+exit 0
+
+%pre bigmem
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+exit 0
+
+%post 
+cd /boot
+%ifnarch ia64 
+ln -sf vmlinuz-%{KVERREL} vmlinuz
+%endif
+ln -sf System.map-%{KVERREL} System.map
+ln -sf module-info-%{KVERREL} module-info
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
+[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
+if [ -x /sbin/new-kernel-pkg ] ; then
+        /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}
+fi
+
+
+%post smp
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
+[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
+if [ -x /sbin/new-kernel-pkg ] ; then
+        /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}smp
+fi
+
+%post bigmem
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
+[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
+if [ -x /sbin/new-kernel-pkg ] ; then
+        /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}bigmem
+fi
+
+%post jensen
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
+[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
+if [ -x /sbin/new-kernel-pkg ] ; then
+        /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}jensen
+fi
+
+%ifnarch ia64
+%post BOOT
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
+[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
+if [ -x /sbin/new-kernel-pkg ] ; then
+        /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}BOOT
+fi
+
+%endif
+
+# Allow clean removal of modules directory
+%preun 
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+#rm -f /lib/modules/%{KVERREL}/modules.*
+if [ -x /sbin/new-kernel-pkg ] ; then
+ /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}
+fi
+
+
+%preun smp
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+rm -f /lib/modules/%{KVERREL}smp/modules.*
+if [ -x /sbin/new-kernel-pkg ] ; then
+ /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}smp
+fi
+
+
+%preun bigmem
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+rm -f /lib/modules/%{KVERREL}bigmem/modules.*
+if [ -x /sbin/new-kernel-pkg ] ; then
+ /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}bigmem
+fi
+
+
+%preun BOOT
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+#rm -f /lib/modules/%{KVERREL}BOOT/modules.*
+if [ -x /sbin/new-kernel-pkg ] ; then
+ /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}BOOT
+fi
+
+
+%preun jensen
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+#rm -f /lib/modules/%{KVERREL}jensen/modules.*
+
+
+# We need this here because we don't prereq kudzu; it could be
+# installed after the kernel
+%triggerin -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin smp -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin bigmem -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin BOOT -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin jensen -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+
+# Old kernel-headers packages owned include symlinks; new
+# ones just make them so that we can have multiple kernel-headers
+# packages installed.
+
+%triggerpostun source -- kernel-headers < 2.2.16
+cd /usr/src
+rm -f %{kslnk}
+ln -snf linux-%{KVERREL} %{kslnk}
+exit 0
+
+%post source
+cd /usr/src
+rm -f %{kslnk}
+ln -snf linux-%{KVERREL} %{kslnk}
+
+%postun source
+if [ -L /usr/src/%{kslnk} ]; then 
+    if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then
+       [ $1 = 0 ] && rm -f /usr/src/%{kslnk}
+    fi
+fi
+exit 0
+
+###
+### file lists
+###
+
+%if %{buildup}
 %files
-%doc lustre/linux/COPYING lustre/linux/CREDITS lustre/linux/README
-%doc lustre/linux/REPORTING-BUGS
 %defattr(-, root, root)
+/boot/%{kernel_glob}
+%ifarch ia64
+/boot/efi/redhat/%{kernel_glob}
+%endif
+/boot/System.map-%{KVERREL}
+/boot/config-%{KVERREL}
+%dir /lib/modules
+%dir /dev/shm
+/lib/modules/%{KVERREL}
+%endif
+
+%if %{buildsmp}
+%files smp
+%defattr(-, root, root)
+/boot/%{kernel_glob}smp
+%ifarch ia64
+/boot/efi/redhat/%{kernel_glob}smp
+%endif
+/boot/System.map-%{KVERREL}smp
+/boot/config-%{KVERREL}smp
+%dir /lib/modules
+%dir /dev/shm
+/lib/modules/%{KVERREL}smp
+%endif
+
+%if %{buildbigmem}
+%files bigmem
+%defattr(-, root, root)
+/boot/%{kernel_glob}bigmem
+%ifarch ia64
+/boot/efi/redhat/%{kernel_glob}bigmem
+%endif
+/boot/System.map-%{KVERREL}bigmem
+/boot/config-%{KVERREL}bigmem
+%dir /lib/modules
+%dir /dev/shm
+/lib/modules/%{KVERREL}bigmem
+%endif
+
+%if %{buildBOOT}
+%files BOOT
+%defattr(-, root, root)
+/boot/%{kernel_glob}BOOT
+%ifarch ia64
+/boot/efi/redhat/%{kernel_glob}BOOT
+%endif
+/boot/System.map-%{KVERREL}BOOT
+/boot/config-%{KVERREL}BOOT
 %dir /lib/modules
-/lib/modules/*
-/boot/*
+%dir /dev/shm
+/lib/modules/%{KVERREL}BOOT
+%endif
+
+%if %{buildbase}
+
+%if 1
+%files source
+%defattr(-,root,root)
+%dir /usr/src/linux-%{KVERREL}
+/usr/src/linux-%{KVERREL}/COPYING*
+/usr/src/linux-%{KVERREL}/CREDITS
+/usr/src/linux-%{KVERREL}/Documentation
+/usr/src/linux-%{KVERREL}/MAINTAINERS
+/usr/src/linux-%{KVERREL}/Makefile
+/usr/src/linux-%{KVERREL}/README
+/usr/src/linux-%{KVERREL}/REPORTING-BUGS
+/usr/src/linux-%{KVERREL}/Rules.make
+/usr/src/linux-%{KVERREL}/arch
+%ifarch sparc
+/usr/src/linux-%{KVERREL}/arch/sparc64
+%endif
+/usr/src/linux-%{KVERREL}/drivers
+/usr/src/linux-%{KVERREL}/crypto
+/usr/src/linux-%{KVERREL}/fs
+/usr/src/linux-%{KVERREL}/init
+/usr/src/linux-%{KVERREL}/ipc
+/usr/src/linux-%{KVERREL}/kernel
+/usr/src/linux-%{KVERREL}/lib
+/usr/src/linux-%{KVERREL}/mm
+/usr/src/linux-%{KVERREL}/net
+/usr/src/linux-%{KVERREL}/scripts
+%ifarch %{all_x86}
+%{?ibcs_1:/usr/src/linux-%{KVERREL}/abi}
+%endif
+/usr/src/linux-%{KVERREL}/configs
+/usr/src/linux-%{KVERREL}/include
+/usr/src/linux-%{KVERREL}/include/asm
+%ifarch %{all_x86}
+%{?ibcs_1:/usr/src/linux-%{KVERREL}/include/abi}
+%endif
+/usr/src/linux-%{KVERREL}/include/linux
+/usr/src/linux-%{KVERREL}/include/rxrpc
+/usr/src/linux-%{KVERREL}/include/net
+/usr/src/linux-%{KVERREL}/include/pcmcia
+/usr/src/linux-%{KVERREL}/include/scsi
+/usr/src/linux-%{KVERREL}/include/video
+/usr/src/linux-%{KVERREL}/tmp_include_depends
+%dir /usr/src/linux-%{KVERREL}/include
+%dir /usr/src/linux-%{KVERREL}/arch
+%ifarch alpha sparc
+/usr/src/linux-%{KVERREL}/include/math-emu
+%endif
+%endif
+
+%files doc
+%defattr(-,root,root)
+%doc lustre/linux/Documentation/*
 
 %files -n lustre-lite-utils
 %doc lustre/COPYING lustre/BUGS lustre/ChangeLog lustre/README lustre/doc/lustre.pdf
@@ -111,3 +774,5 @@ rm -rf $RPM_BUILD_ROOT
 /etc/openldap/schema/lustre.schema
 /usr/lib/lustre/lustre2ldif.xsl
 /usr/lib/lustre/top.ldif
+
+%endif # %{buildbase}