blob: ca1602eb405c3d36620079b5672f419d74be16d0 [file] [log] [blame]
Martin Roth9b1b3352016-02-24 12:27:06 -08001# Makefile for MemTest86+
2#
3# Author: Chris Brady
4# Created: January 1, 1996
5
6
7#
8# Path for the floppy disk device
9#
10FDISK=/dev/fd0
11
Martin Rothca352c92016-04-21 16:58:57 -060012AS?=as
13CC?=gcc
Stefan Tauner620a64e2016-05-02 01:30:42 +020014OBJCOPY?=objcopy
Martin Roth9b1b3352016-02-24 12:27:06 -080015
Martin Rothca352c92016-04-21 16:58:57 -060016AS+= -32
Martin Roth3325fc42016-02-24 13:15:19 -080017CFLAGS= -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin \
Martin Roth5ab39a12016-02-24 13:27:21 -080018 -ffreestanding -fPIC $(SMP_FL) -fno-stack-protector -fgnu89-inline
Martin Roth8cc1aeb2016-02-24 13:03:52 -080019
Martin Rothbfa1e7f2016-02-24 14:30:25 -080020ifneq ($(SERIAL_CONSOLE_DEFAULT),)
21 CFLAGS += -DSERIAL_CONSOLE_DEFAULT=$(SERIAL_CONSOLE_DEFAULT)
22endif
23
24ifneq ($(SERIAL_BAUD_RATE),)
25 CFLAGS += -DSERIAL_BAUD_RATE=$(SERIAL_BAUD_RATE)
26endif
27
28ifneq ($(SERIAL_TTY),)
29 CFLAGS += -DSERIAL_TTY=$(SERIAL_TTY)
30endif
31
Piotr Król686a6732017-05-25 00:54:47 +020032ifneq ($(CB_NOSPD),)
33 CFLAGS += -DCB_NOSPD=$(CB_NOSPD)
34endif
35
Martin Roth8cc1aeb2016-02-24 13:03:52 -080036# This reverts a change introduced with recent binutils (post
37# http://sourceware.org/bugzilla/show_bug.cgi?id=10569). Needed to
38# ensure Multiboot header is within the limit offset.
39LD += -z max-page-size=0x1000
40
Martin Roth34a7e462016-03-07 21:14:40 -070041OBJS= head.pre.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \
Martin Roth61ea5412016-03-07 20:58:18 -070042 config.o cpuid.o coreboot.o pci.o memsize.o spd.o error.o dmi.o controller.o \
Martin Roth8cc1aeb2016-02-24 13:03:52 -080043 smp.o vmem.o random.o multiboot.o
Martin Roth9b1b3352016-02-24 12:27:06 -080044
Martin Roth4dcd13d2016-02-24 13:53:07 -080045all: clean memtest.bin memtest
Martin Roth9b1b3352016-02-24 12:27:06 -080046
47# Link it statically once so I know I don't have undefined
48# symbols and then link it dynamically so I have full
49# relocation information
50memtest_shared: $(OBJS) memtest_shared.lds Makefile
51 $(LD) --warn-constructors --warn-common -static -T memtest_shared.lds \
52 -o $@ $(OBJS) && \
53 $(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS)
54
55memtest_shared.bin: memtest_shared
Stefan Tauner620a64e2016-05-02 01:30:42 +020056 $(OBJCOPY) -O binary $< memtest_shared.bin
Martin Roth9b1b3352016-02-24 12:27:06 -080057
58memtest: memtest_shared.bin memtest.lds
59 $(LD) -s -T memtest.lds -b binary memtest_shared.bin -o $@
60
Martin Roth34a7e462016-03-07 21:14:40 -070061head.pre.s: head.S config.h defs.h test.h
Martin Roth9b1b3352016-02-24 12:27:06 -080062 $(CC) -E -traditional $< -o $@
63
Martin Roth34a7e462016-03-07 21:14:40 -070064bootsect.pre.s: bootsect.S config.h defs.h
Martin Roth9b1b3352016-02-24 12:27:06 -080065 $(CC) -E -traditional $< -o $@
66
Martin Roth34a7e462016-03-07 21:14:40 -070067setup.pre.s: setup.S config.h defs.h
Martin Roth9b1b3352016-02-24 12:27:06 -080068 $(CC) -E -traditional $< -o $@
69
Martin Roth34a7e462016-03-07 21:14:40 -070070memtest.bin: memtest_shared.bin bootsect.pre.o setup.pre.o memtest.bin.lds
71 $(LD) -T memtest.bin.lds bootsect.pre.o setup.pre.o -b binary \
Martin Roth9b1b3352016-02-24 12:27:06 -080072 memtest_shared.bin -o memtest.bin
73
74reloc.o: reloc.c
75 $(CC) -c $(CFLAGS) -fno-strict-aliasing reloc.c
76
77test.o: test.c
78 $(CC) -c -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin -ffreestanding test.c
79
80random.o: random.c
81 $(CC) -c -Wall -march=i486 -m32 -O3 -fomit-frame-pointer -fno-builtin -ffreestanding random.c
Martin Roth4dcd13d2016-02-24 13:53:07 -080082
83# rule for build number generation
Martin Roth9b1b3352016-02-24 12:27:06 -080084build_number:
Martin Roth4dcd13d2016-02-24 13:53:07 -080085 sh make_buildnum.sh
Martin Roth9b1b3352016-02-24 12:27:06 -080086
87clean:
Martin Roth34a7e462016-03-07 21:14:40 -070088 rm -f *.o *.pre.s *.iso memtest.bin memtest memtest_shared \
Martin Roth9b1b3352016-02-24 12:27:06 -080089 memtest_shared.bin memtest.iso
90
91iso:
92 make all
93 ./makeiso.sh
94
95install: all
96 dd <memtest.bin >$(FDISK) bs=8192
97
98install-precomp:
99 dd <precomp.bin >$(FDISK) bs=8192
Martin Roth4dcd13d2016-02-24 13:53:07 -0800100
Martin Roth9b1b3352016-02-24 12:27:06 -0800101dos: all
102 cat mt86+_loader memtest.bin > memtest.exe
Martin Roth18a736c2016-02-28 10:01:26 -0800103
104junit.xml:
105 echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > $@.tmp
106 echo "<testcase classname='memtest86+' name='memtest86+'>" >> $@.tmp
107 $(MAKE) all >> $@.tmp.2 2>&1 && type="system-out" || type="failure"; \
108 cat $@.tmp.2; \
109 if [ "$$type" = "failure" ]; then \
110 echo "<failure type='buildFailed'>" >> $@.tmp; \
111 echo "Building memtest86+ Failed"; \
112 else \
113 echo "<$$type>" >> $@.tmp; \
114 echo "Building memtest86+ Succeeded"; \
115 fi; \
116 echo '<![CDATA[' >> $@.tmp; \
117 cat $@.tmp.2 >> $@.tmp; \
118 echo "]]></$$type>" >>$@.tmp
119 rm -f $@.tmp.2
120 echo "</testcase>" >> $@.tmp
121 echo "</testsuite>" >> $@.tmp
122 mv $@.tmp $@
123 echo