Home | History | Annotate | Download | only in hdt
      1 ## -----------------------------------------------------------------------
      2 ##
      3 ##   Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
      4 ##   Copyright 2009 Intel Corporation; author: H. Peter Anvin
      5 ##
      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.
     11 ##
     12 ## -----------------------------------------------------------------------
     13 
     14 ##
     15 ## Hardware Detection Tool
     16 ##
     17 
     18 VPATH = $(SRC)
     19 include $(MAKEDIR)/elf.mk
     20 
     21 LIBS      = $(objdir)/com32/libupload/libcom32upload.a
     22 C_LIBS    += $(objdir)/com32/cmenu/libmenu/libmenu.c32
     23 CFLAGS    += -I$(com32)/cmenu/libmenu -I$(com32)
     24 
     25 MODULES	  = hdt.c32
     26 TESTFILES =
     27 
     28 OBJS	  = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
     29 VERSION   = $(shell $(SED) -n 's/\#define VERSION \"\(.*\)\"/\1/p' hdt.h)
     30 CODENAME  = $(shell $(SED) -n 's/\#define CODENAME \"\(.*\)\"/\1/p' hdt.h)
     31 NODASH_VERSION = $(shell echo $(VERSION) | $(SED) -e 's/-/_/g' | $(SED) -e 's/\./_/g')
     32 SUM_FILE  = hdt-$(VERSION).checksums
     33 
     34 MEMTEST_URL = http://memtest.org/download/4.20/memtest86+-4.20.bin
     35 MEMTEST     = memtest.bin
     36 
     37 KERNEL_VERSION          ?= $(shell uname -r)
     38 MODULES_ALIAS_FILE      ?= /lib/modules/$(KERNEL_VERSION)/modules.alias
     39 GZ_MODULES_ALIAS_FILE   ?= modules.alias.gz
     40 MODULES_PCIMAP_FILE     ?= /lib/modules/$(KERNEL_VERSION)/modules.pcimap
     41 GZ_MODULES_PCIMAP_FILE  ?= modules.pcimap.gz
     42 ISO_DIR                 ?= iso
     43 ISOLINUX_DIR            ?= isolinux
     44 FLOPPY_DIR		?= floppy
     45 PCI_IDS_FILE            ?= $(PWD)/$(FLOPPY_DIR)/pci.ids
     46 GZ_PCI_IDS_FILE         ?= $(PCI_IDS_FILE).gz
     47 MENU_COM32              ?= $(com32)/menu/menu.c32
     48 CHAIN_COM32             ?= $(com32)/chain/chain.c32
     49 ART_DIR                 ?= art/
     50 QEMU			?= qemu-kvm
     51 
     52 all: $(MODULES) $(TESTFILES)
     53 
     54 hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)
     55 	$(LD) $(LDFLAGS) -o $@ $^
     56 
     57 memtest:
     58 	-[ ! -f $(FLOPPY_DIR)/$(MEMTEST) ] && $(WGET) $(MEMTEST_URL) -O $(FLOPPY_DIR)/$(MEMTEST)
     59 
     60 hdt.img: hdt.c32 $(FLOPPY_DIR)/hdt.cfg $(FLOPPY_DIR)/mtools.conf $(topdir)/mtools/syslinux $(MENU_COM32) memtest $(CHAIN_COM32)
     61 	rm -f hdt*.img
     62 	$(SED) -e 's/%VERSION%/$(VERSION)/g' $(FLOPPY_DIR)/hdt.cfg |\
     63 	$(SED) -e 's/%CODENAME%/$(CODENAME)/g' > $(FLOPPY_DIR)/syslinux.cfg
     64 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MFORMAT) -v HDT_$(NODASH_VERSION) -f 1440 -C a:
     65 	$(topdir)/mtools/syslinux hdt.img
     66 	-[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
     67 	-[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
     68 	-[ -f $(MODULES_ALIAS_FILE) ] &&  cat $(MODULES_ALIAS_FILE) | $(GZIPPROG) - -f | MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) - a:modules.alias
     69 	-[ -f $(MODULES_PCIMAP_FILE) ] && cat $(MODULES_PCIMAP_FILE) | $(GZIPPROG) - -f | MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) - a:modules.pcimap
     70 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) hdt.c32 a:
     71 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(MENU_COM32) a:
     72 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(CHAIN_COM32) a:
     73 	@ [ -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"
     74 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(FLOPPY_DIR)/syslinux.cfg a:
     75 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(FLOPPY_DIR)/$(MEMTEST) a:
     76 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(ART_DIR)/backgnd.png a:
     77 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(ART_DIR)/display.png a:
     78 	MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(ART_DIR)/red.png a:
     79 	mv hdt.img hdt-$(VERSION).img
     80 	ln -sf hdt-$(VERSION).img hdt.img
     81 
     82 hdt.img.gz: hdt.img
     83 	rm -rf hdt*.img.gz
     84 	$(GZIPPROG) -c hdt-$(VERSION).img >hdt-$(VERSION).img.gz
     85 	ln -sf hdt-$(VERSION).img.gz hdt.img.gz
     86 
     87 hdt.iso: hdt.c32 $(topdir)/core/isolinux.bin $(FLOPPY_DIR)/hdt.cfg memtest
     88 	rm -rf $(ISO_DIR)
     89 	rm -f hdt.iso
     90 	mkdir -p $(ISO_DIR)/$(ISOLINUX_DIR)
     91 	cp $(topdir)/core/isolinux.bin $(ISO_DIR)/$(ISOLINUX_DIR)
     92 	$(SED) -e 's/%VERSION%/$(VERSION)/g' $(FLOPPY_DIR)/hdt.cfg |\
     93 		$(SED) -e 's/%CODENAME%/$(CODENAME)/g' > $(ISO_DIR)/$(ISOLINUX_DIR)/isolinux.cfg
     94 	cp hdt.c32 $(ISO_DIR)/$(ISOLINUX_DIR)
     95 	cp $(FLOPPY_DIR)/$(MEMTEST) $(ISO_DIR)/$(ISOLINUX_DIR)
     96 	cp $(MENU_COM32) $(ISO_DIR)/$(ISOLINUX_DIR)
     97 	cp $(CHAIN_COM32) $(ISO_DIR)/$(ISOLINUX_DIR)
     98 	cp -av $(ART_DIR)/backgnd.png $(ISO_DIR)/$(ISOLINUX_DIR)
     99 	cp -av $(ART_DIR)/display.png $(ISO_DIR)/$(ISOLINUX_DIR)
    100 	cp -av $(ART_DIR)/red.png $(ISO_DIR)/$(ISOLINUX_DIR)
    101 	-[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
    102 	-[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
    103 	-[ -f $(MODULES_ALIAS_FILE) ] && cp $(MODULES_ALIAS_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)\
    104 	       	&& $(GZIPPROG) $(ISO_DIR)/$(ISOLINUX_DIR)/modules.alias\
    105 		&& mv $(ISO_DIR)/$(ISOLINUX_DIR)/modules.alias.gz $(ISO_DIR)/$(ISOLINUX_DIR)/modules.alias
    106 	-[ -f $(MODULES_PCIMAP_FILE) ] && cp $(MODULES_PCIMAP_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)\
    107 		&& $(GZIPPROG) $(ISO_DIR)/$(ISOLINUX_DIR)/modules.pcimap\
    108 		&& mv $(ISO_DIR)/$(ISOLINUX_DIR)/modules.pcimap.gz $(ISO_DIR)/$(ISOLINUX_DIR)/modules.pcimap
    109 	-[ ! -f $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids.gz ] && cp $(GZ_PCI_IDS_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids
    110 	-[ ! -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"
    111 	$(MKISOFS) -o hdt.iso -b $(ISOLINUX_DIR)/isolinux.bin -c $(ISOLINUX_DIR)/boot.cat \
    112 		-no-emul-boot -boot-load-size 4 -boot-info-table \
    113 		$(ISO_DIR)
    114 	mv hdt.iso hdt-$(VERSION).iso
    115 	ln -sf hdt-$(VERSION).iso hdt.iso
    116 
    117 hdt-hybrid.iso: hdt.iso ../../utils/isohybrid
    118 	cp hdt-$(VERSION).iso hdt-hybrid-$(VERSION).iso
    119 	../../utils/isohybrid --partok hdt-hybrid-$(VERSION).iso
    120 	ln -sf hdt-hybrid-$(VERSION).iso hdt-hybrid.iso
    121 
    122 release: spotless hdt.c32 hdt.img hdt.img.gz hdt.iso hdt-hybrid.iso
    123 	mv hdt.c32 hdt_$(NODASH_VERSION).c32
    124 	md5sum hdt_$(NODASH_VERSION).c32 >$(SUM_FILE)
    125 	md5sum hdt-$(VERSION).iso >>$(SUM_FILE)
    126 	md5sum hdt-hybrid-$(VERSION).iso >>$(SUM_FILE)
    127 	md5sum hdt-$(VERSION).img >>$(SUM_FILE)
    128 	md5sum hdt-$(VERSION).img.gz >>$(SUM_FILE)
    129 
    130 test: hdt.img
    131 	$(QEMU) -fda hdt.img
    132 
    133 tidy dist:
    134 	rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
    135 
    136 clean: tidy
    137 	rm -f *.lnx
    138 
    139 spotless: clean
    140 	rm -f *.lss *.c32 *.com hdt*.img hdt*.iso hdt*.img.gz
    141 	rm -rf $(ISO_DIR)
    142 	rm -rf $(FLOPPY_DIR)/$(MEMTEST)
    143 	rm -rf $(FLOPPY_DIR)/pci.ids*
    144 	rm -rf hdt-*checksums
    145 	rm -f *~ \#*
    146 
    147 install:
    148 
    149 -include .*.d
    150