forked from BrickBot/brickEmu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (90 loc) · 2.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
CC=gcc
CFLAGS=-O2 -pg -g -Wall -Wmissing-prototypes
TOOLPREFIX=/usr/bin/h8300-hms-
LIBS=
PROFILE=
ifeq ($(SOUND),mute)
SOUND_SOURCES=sound_none.c
else
ifeq ($(shell test -d /usr/include/alsa && echo 1),1)
LIBS += -L/usr/lib -lasound
SOUND_SOURCES=sound_alsa.c
else
ifneq ($(shell which sdl-config 2>/dev/null),)
# use default SDL config arguments
CFLAGS += $(shell sdl-config --cflags)
LIBS += $(shell sdl-config --libs)
# use custom SDL config arguments (e.g. for building in Cygwin)
#CFLAGS += -I/usr/local/include/SDL
#LIBS += -L/usr/local/lib -lSDL
SOUND_SOURCES=sound_sdl.c
else
SOUND_SOURCES=sound_none.c
endif
endif
endif
SOURCES=main.c h8300.c peripherals.c memory.c lcd.c timer16.c timer8.c \
buttons.c waitstate.c frame.c serial.c debugger.c adsensors.c \
watchdog.c firmware.c coff.c srec.c socket.c motor.c symbols.c \
lx.c hash.c savefile.c printf.c brickos.c bibo.c
HEADERS=types.h h8300.h peripherals.h memory.h lx.h symbols.h hash.h \
frame.h debugger.h socket.h coff.h
DIST_ASM_SOURCES=h8300-i586.S h8300-x86-64.S h8300-sparc.S
ROM_SOURCES=rom.S rom-lcd.S rom.ld
DIST =README Makefile \
$(SOURCES) $(DIST_ASM_SOURCES) $(HEADERS) \
sound_alsa.c sound_sdl.c sound_none.c \
$(ROM_SOURCES) \
h8300.pl h8300-i586.pl h8300-x86-64.pl h8300-sparc.pl \
ir-server.c GUI.tcl remote \
firmdl.diff dll-src.diff Makefile.diff \
brickemu.dxy rom.bin
OBJS = $(subst .c,.o,$(SOURCES)) $(subst .S,.o,$(ASM_SOURCES)) \
$(subst .c,.o,$(SOUND_SOURCES))
## NOTE: Assembly sources do not work with current compiler tools,
## so disabling ASM_SOURCES for now by commenting out the line below.
#MACHINE:=$(shell uname -m)
ifeq ($(MACHINE),x86_64)
ASM_SOURCES=h8300-x86-64.S
else
ifneq ($(filter i%86,$(MACHINE)),)
ASM_SOURCES=h8300-i586.S
else
ifneq ($(filter sun4%,$(MACHINE)),)
ASM_SOURCES=h8300-sparc.S
LIBS += -lsocket
endif
endif
endif
ifneq ($(ASM_SOURCES),)
CFLAGS += -DHAVE_RUN_CPU_ASM
endif
all: emu ir-server rom.bin
clean:
rm -f *.o *.inc emu ir-server
rm -rf html latex
h83%.inc: h83%.pl
perl $^ > $@
h8300.o: h8300.inc h8300.h
h8300-i586.o: h8300-i586.inc
h8300-x86-64.o: h8300-x86-64.inc
h8300-sparc.o: h8300-sparc.inc
lcd.o: h8300.h
prototype.h: $(SOURCES)
perl mkproto.pl $(SOURCES) > prototype.h
ir-server: ir-server.o
$(CC) $(CFLAGS) $^ $(LIBS) -o $@
emu: CFLAGS += $(PROFILE)
emu: $(OBJS)
$(CC) $(CFLAGS) $^ $(LIBS) -lz -o $@
brickemu.tar.gz: $(DIST)
mkdir brickemu
cp $^ brickemu
tar -cvzf brickemu.tar.gz brickemu
rm -rf brickemu
rom.o: rom.S rom-lcd.S
$(TOOLPREFIX)gcc -c -o $@ $<
rom.coff: rom.o rom.ld
$(TOOLPREFIX)ld -T rom.ld -relax rom.o -nostdlib -o $@
rom.bin: rom.coff
$(TOOLPREFIX)objcopy -O binary $< $@