1 ## -----------------------------------------------------------------------
3 ## Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009 Intel Corporation; author: H. Peter Anvin
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
9 ## Boston MA 02110-1301, USA; either version 2 of the License, or
10 ## (at your option) any later version; incorporated herein by reference.
12 ## -----------------------------------------------------------------------
15 ## Hardware Detection Tool
19 MAKEDIR
= $(topdir
)/mk
20 include $(MAKEDIR
)/elf.mk
22 LIBS
= ..
/libupload
/libcom32upload.a
23 C_LIBS
+= $(com32
)/cmenu
/libmenu
/libmenu.c32
24 CFLAGS
+= -I
$(com32
)/cmenu
/libmenu
-I
$(com32
)
29 OBJS
= $(patsubst %.c
,%.o
,$(wildcard *.c
))
30 VERSION
= $(shell $(SED
) -n
's/\#define VERSION \"\(.*\)\"/\1/p' hdt.h
)
31 CODENAME
= $(shell $(SED
) -n
's/\#define CODENAME \"\(.*\)\"/\1/p' hdt.h
)
32 NODASH_VERSION
= $(shell echo
$(VERSION
) |
$(SED
) -e
's/-/_/g' |
$(SED
) -e
's/\./_/g')
33 SUM_FILE
= hdt-
$(VERSION
).checksums
35 MEMTEST_URL
= http
://memtest.org
/download
/4.20/memtest86
+-4.20.bin
38 KERNEL_VERSION ?
= $(shell uname
-r
)
39 MODULES_ALIAS_FILE ?
= /lib
/modules
/$(KERNEL_VERSION
)/modules.alias
40 GZ_MODULES_ALIAS_FILE ?
= modules.alias.gz
41 MODULES_PCIMAP_FILE ?
= /lib
/modules
/$(KERNEL_VERSION
)/modules.pcimap
42 GZ_MODULES_PCIMAP_FILE ?
= modules.pcimap.gz
44 ISOLINUX_DIR ?
= isolinux
46 PCI_IDS_FILE ?
= $(PWD
)/$(FLOPPY_DIR
)/pci.ids
47 GZ_PCI_IDS_FILE ?
= $(PCI_IDS_FILE
).gz
48 MENU_COM32 ?
= $(com32
)/menu
/menu.c32
49 CHAIN_COM32 ?
= $(com32
)/chain
/chain.c32
53 all: $(MODULES
) $(TESTFILES
)
55 hdt.elf
: $(OBJS
) $(LIBS
) $(C_LIBS
)
56 $(LD
) $(LDFLAGS
) -o
$@
$^
59 -[ ! -f
$(FLOPPY_DIR
)/$(MEMTEST
) ] && $(WGET
) $(MEMTEST_URL
) -O
$(FLOPPY_DIR
)/$(MEMTEST
)
61 hdt.img
: hdt.c32
$(FLOPPY_DIR
)/hdt.cfg
$(FLOPPY_DIR
)/mtools.conf
$(topdir
)/mtools
/syslinux
$(MENU_COM32
) memtest
$(CHAIN_COM32
)
63 $(SED
) -e
's/%VERSION%/$(VERSION)/g' $(FLOPPY_DIR
)/hdt.cfg |\
64 $(SED
) -e
's/%CODENAME%/$(CODENAME)/g' > $(FLOPPY_DIR
)/syslinux.cfg
65 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MFORMAT
) -v HDT_
$(NODASH_VERSION
) -f
1440 -C a
:
66 $(topdir
)/mtools
/syslinux hdt.img
67 -[ ! -f
$(GZ_PCI_IDS_FILE
) ] && cp
/usr
/share
/hwdata
/pci.ids
$(PCI_IDS_FILE
) && $(GZIPPROG
) $(PCI_IDS_FILE
)
68 -[ ! -f
$(GZ_PCI_IDS_FILE
) ] && cp
/usr
/share
/pci.ids
$(PCI_IDS_FILE
) && $(GZIPPROG
) $(PCI_IDS_FILE
)
69 -[ -f
$(MODULES_ALIAS_FILE
) ] && cat
$(MODULES_ALIAS_FILE
) |
$(GZIPPROG
) - -f | MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) - a
:modules.alias
70 -[ -f
$(MODULES_PCIMAP_FILE
) ] && cat
$(MODULES_PCIMAP_FILE
) |
$(GZIPPROG
) - -f | MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) - a
:modules.pcimap
71 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) hdt.c32 a
:
72 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(MENU_COM32
) a
:
73 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(CHAIN_COM32
) a
:
74 @
[ -f
$(GZ_PCI_IDS_FILE
) ] && MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(GZ_PCI_IDS_FILE
) a
:pci.ids || printf
"\nThe $(GZ_PCI_IDS_FILE) file is missing and can be downloaded from http://pciids.sourceforge.net and gzipped in\nthe ./com32/hdt/$(FLOPPY_DIR) directory of the extracted Syslinux source.\n\n"
75 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(FLOPPY_DIR
)/syslinux.cfg a
:
76 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(FLOPPY_DIR
)/$(MEMTEST
) a
:
77 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(ART_DIR
)/backgnd.png a
:
78 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(ART_DIR
)/display.png a
:
79 MTOOLSRC
=$(PWD
)/$(FLOPPY_DIR
)/mtools.conf
$(MCOPY
) $(ART_DIR
)/red.png a
:
80 mv hdt.img hdt-
$(VERSION
).img
81 ln
-sf hdt-
$(VERSION
).img hdt.img
85 $(GZIPPROG
) -c hdt-
$(VERSION
).img
>hdt-
$(VERSION
).img.gz
86 ln
-sf hdt-
$(VERSION
).img.gz hdt.img.gz
88 hdt.iso
: hdt.c32
$(topdir
)/core
/isolinux.bin
$(FLOPPY_DIR
)/hdt.cfg memtest
91 mkdir
-p
$(ISO_DIR
)/$(ISOLINUX_DIR
)
92 cp
$(topdir
)/core
/isolinux.bin
$(ISO_DIR
)/$(ISOLINUX_DIR
)
93 $(SED
) -e
's/%VERSION%/$(VERSION)/g' $(FLOPPY_DIR
)/hdt.cfg |\
94 $(SED
) -e
's/%CODENAME%/$(CODENAME)/g' > $(ISO_DIR
)/$(ISOLINUX_DIR
)/isolinux.cfg
95 cp hdt.c32
$(ISO_DIR
)/$(ISOLINUX_DIR
)
96 cp
$(FLOPPY_DIR
)/$(MEMTEST
) $(ISO_DIR
)/$(ISOLINUX_DIR
)
97 cp
$(MENU_COM32
) $(ISO_DIR
)/$(ISOLINUX_DIR
)
98 cp
$(CHAIN_COM32
) $(ISO_DIR
)/$(ISOLINUX_DIR
)
99 cp
-av
$(ART_DIR
)/backgnd.png
$(ISO_DIR
)/$(ISOLINUX_DIR
)
100 cp
-av
$(ART_DIR
)/display.png
$(ISO_DIR
)/$(ISOLINUX_DIR
)
101 cp
-av
$(ART_DIR
)/red.png
$(ISO_DIR
)/$(ISOLINUX_DIR
)
102 -[ ! -f
$(GZ_PCI_IDS_FILE
) ] && cp
/usr
/share
/hwdata
/pci.ids
$(PCI_IDS_FILE
) && $(GZIPPROG
) $(PCI_IDS_FILE
)
103 -[ ! -f
$(GZ_PCI_IDS_FILE
) ] && cp
/usr
/share
/pci.ids
$(PCI_IDS_FILE
) && $(GZIPPROG
) $(PCI_IDS_FILE
)
104 -[ -f
$(MODULES_ALIAS_FILE
) ] && cp
$(MODULES_ALIAS_FILE
) $(ISO_DIR
)/$(ISOLINUX_DIR
)\
105 && $(GZIPPROG
) $(ISO_DIR
)/$(ISOLINUX_DIR
)/modules.alias\
106 && mv
$(ISO_DIR
)/$(ISOLINUX_DIR
)/modules.alias.gz
$(ISO_DIR
)/$(ISOLINUX_DIR
)/modules.alias
107 -[ -f
$(MODULES_PCIMAP_FILE
) ] && cp
$(MODULES_PCIMAP_FILE
) $(ISO_DIR
)/$(ISOLINUX_DIR
)\
108 && $(GZIPPROG
) $(ISO_DIR
)/$(ISOLINUX_DIR
)/modules.pcimap\
109 && mv
$(ISO_DIR
)/$(ISOLINUX_DIR
)/modules.pcimap.gz
$(ISO_DIR
)/$(ISOLINUX_DIR
)/modules.pcimap
110 -[ ! -f
$(ISO_DIR
)/$(ISOLINUX_DIR
)/pci.ids.gz
] && cp
$(GZ_PCI_IDS_FILE
) $(ISO_DIR
)/$(ISOLINUX_DIR
)/pci.ids
111 -[ ! -f
$(ISO_DIR
)/$(ISOLINUX_DIR
)/pci.ids
] && printf
"\nThe $(FLOPPY_DIR)/pci.ids file is missing and can be downloaded from http://pciids.sourceforge.net and put in\nthe ./com32/hdt/$(FLOPPY_DIR) directory of the extracted Syslinux source.\n\n"
112 $(MKISOFS
) -o hdt.iso
-b
$(ISOLINUX_DIR
)/isolinux.bin
-c
$(ISOLINUX_DIR
)/boot.cat \
113 -no-emul-boot
-boot-load-size
4 -boot-info-table \
115 mv hdt.iso hdt-
$(VERSION
).iso
116 ln
-sf hdt-
$(VERSION
).iso hdt.iso
118 hdt-hybrid.iso
: hdt.iso ..
/..
/utils
/isohybrid
119 cp hdt-
$(VERSION
).iso hdt-hybrid-
$(VERSION
).iso
120 ..
/..
/utils
/isohybrid
--partok hdt-hybrid-
$(VERSION
).iso
121 ln
-sf hdt-hybrid-
$(VERSION
).iso hdt-hybrid.iso
123 release
: spotless hdt.c32 hdt.img hdt.img.gz hdt.iso hdt-hybrid.iso
124 mv hdt.c32 hdt_
$(NODASH_VERSION
).c32
125 md5sum hdt_
$(NODASH_VERSION
).c32
>$(SUM_FILE
)
126 md5sum hdt-
$(VERSION
).iso
>>$(SUM_FILE
)
127 md5sum hdt-hybrid-
$(VERSION
).iso
>>$(SUM_FILE
)
128 md5sum hdt-
$(VERSION
).img
>>$(SUM_FILE
)
129 md5sum hdt-
$(VERSION
).img.gz
>>$(SUM_FILE
)
135 rm -f
*.o
*.lo
*.a
*.lst
*.elf .
*.d
*.tmp
141 rm -f
*.lss
*.c32
*.com hdt
*.img hdt
*.iso hdt
*.img.gz
143 rm -rf
$(FLOPPY_DIR
)/$(MEMTEST
)
144 rm -rf
$(FLOPPY_DIR
)/pci.ids
*
145 rm -rf hdt-
*checksums