blob: ea9ba0f74ed0492eb6778b3c6735fc8d33b3f5c7 [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
12AS=as -32
13CC=gcc
14
Martin Roth3325fc42016-02-24 13:15:19 -080015CFLAGS= -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin \
Martin Roth9b1b3352016-02-24 12:27:06 -080016 -ffreestanding -fPIC $(SMP_FL) -fno-stack-protector
Martin Roth8cc1aeb2016-02-24 13:03:52 -080017
18# This reverts a change introduced with recent binutils (post
19# http://sourceware.org/bugzilla/show_bug.cgi?id=10569). Needed to
20# ensure Multiboot header is within the limit offset.
21LD += -z max-page-size=0x1000
22
Martin Roth9b1b3352016-02-24 12:27:06 -080023OBJS= head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \
24 config.o cpuid.o linuxbios.o pci.o memsize.o spd.o error.o dmi.o controller.o \
Martin Roth8cc1aeb2016-02-24 13:03:52 -080025 smp.o vmem.o random.o multiboot.o
Martin Roth9b1b3352016-02-24 12:27:06 -080026
27all: clean memtest.bin memtest
Martin Roth9b1b3352016-02-24 12:27:06 -080028
29# Link it statically once so I know I don't have undefined
30# symbols and then link it dynamically so I have full
31# relocation information
32memtest_shared: $(OBJS) memtest_shared.lds Makefile
33 $(LD) --warn-constructors --warn-common -static -T memtest_shared.lds \
34 -o $@ $(OBJS) && \
35 $(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS)
36
37memtest_shared.bin: memtest_shared
38 objcopy -O binary $< memtest_shared.bin
39
40memtest: memtest_shared.bin memtest.lds
41 $(LD) -s -T memtest.lds -b binary memtest_shared.bin -o $@
42
43head.s: head.S config.h defs.h test.h
44 $(CC) -E -traditional $< -o $@
45
46bootsect.s: bootsect.S config.h defs.h
47 $(CC) -E -traditional $< -o $@
48
49setup.s: setup.S config.h defs.h
50 $(CC) -E -traditional $< -o $@
51
52memtest.bin: memtest_shared.bin bootsect.o setup.o memtest.bin.lds
53 $(LD) -T memtest.bin.lds bootsect.o setup.o -b binary \
54 memtest_shared.bin -o memtest.bin
55
56reloc.o: reloc.c
57 $(CC) -c $(CFLAGS) -fno-strict-aliasing reloc.c
58
59test.o: test.c
60 $(CC) -c -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin -ffreestanding test.c
61
62random.o: random.c
63 $(CC) -c -Wall -march=i486 -m32 -O3 -fomit-frame-pointer -fno-builtin -ffreestanding random.c
64
65# rule for build number generation
66build_number:
67 sh make_buildnum.sh
68
69clean:
70 rm -f *.o *.s *.iso memtest.bin memtest memtest_shared \
71 memtest_shared.bin memtest.iso
72
73iso:
74 make all
75 ./makeiso.sh
76
77install: all
78 dd <memtest.bin >$(FDISK) bs=8192
79
80install-precomp:
81 dd <precomp.bin >$(FDISK) bs=8192
82
83dos: all
84 cat mt86+_loader memtest.bin > memtest.exe