1+ # # ========================================================================================================
2+ # # IMPORTANT NOTE: This Makefile setup is designed to work both standalone and integrated with brickOS-bibo
3+ # # - Makefile: For building stand-alone, effectively providing what would provided by Makefle
4+ # # or Makefile.common from brickOS-bibo
5+ # # - Makefile.sub: Facilitates building as part of brickOS-bibo
6+ # # ========================================================================================================
7+
18# Development Packages:
29# * Required: GNU GCC, h8300 toolchain
310# * Optional: ALSA, SDL
4- # Runtime Packages Required: TK, ALSA or SDL
11+ # Runtime Packages Required: TK,TCL Libs, and ALSA or SDL
512# * openSUSE: tk
13+
14+ # Using $(abspath x) here so that symlinks are NOT replaced
15+ MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST ) ) )
16+ MAKEFILE_DIR := $(abspath $(dir $(MAKEFILE_PATH ) ) )
17+ MAKEFILE_NAME := $(notdir $(MAKEFILE_PATH ) )
18+
619CC =gcc
720CFLAGS=-std =gnu89 -O2 -pg -g -Wall -Wmissing-prototypes
821CROSSTOOLPREFIX =h8300-hitachi-coff-
@@ -13,41 +26,9 @@ PROFILE=
1326# If defined, EMUSUBDIR _MUST_ include the trailing directory slash
1427EMUSUBDIR =
1528
16- ifeq ($(SOUND ) ,mute)
17- $(info SOUND Library Target : Muted (requested via value of SOUND))
18- EMU_SOUND_SOURCE_FILES =sound_none.c
19- else ifneq ($(shell which sdl-config 2>/dev/null),)
20- # SDL depends on ALSA, so if the ALSA check is first, SDL will never be selected
21- $(info SOUND Library Target : SDL (Simple DirectMedia Layer))
22- # use default SDL config arguments
23- CFLAGS += $(shell sdl-config --cflags)
24- LIBS += $(shell sdl-config --libs)
25- # use custom SDL config arguments (e.g. for building in Cygwin)
26- # CFLAGS += -I/usr/local/include/SDL
27- # LIBS += -L/usr/local/lib -lSDL
28- EMU_SOUND_SOURCE_FILES =sound_sdl.c
29- else ifeq ($(shell test -d /usr/include/alsa && echo 1),1)
30- $(info SOUND Library Target : ALSA (Advanced Linux Sound Architecture))
31- LIBS += -L/usr/lib -lasound
32- EMU_SOUND_SOURCE_FILES =sound_alsa.c
33- else
34- $(info SOUND Library Target : None (no compatible libraries found))
35- EMU_SOUND_SOURCE_FILES =sound_none.c
36- endif
37- EMU_SOUND_SOURCE_PATHS=$(EMU_SOUND_SOURCE_FILES:% =$(EMUSUBDIR ) %)
38-
39- EMU_HEADER_FILES =types.h h8300.h peripherals.h memory.h lx.h symbols.h hash.h \
40- frame.h debugger.h socket.h coff.h
41- EMU_HEADER_PATHS=$(EMU_HEADER_FILES:% =$(EMUSUBDIR ) %)
42-
43- EMU_SOURCE_FILES =main.c h8300.c peripherals.c memory.c lcd.c timer16.c timer8.c \
44- buttons.c waitstate.c frame.c serial.c debugger.c adsensors.c \
45- watchdog.c firmware.c coff.c srec.c socket.c motor.c symbols.c \
46- lx.c hash.c savefile.c printf.c brickos.c bibo.c
47- EMU_SOURCE_PATHS=$(EMU_SOURCE_FILES:% =$(EMUSUBDIR ) %)
29+ ROM_SOURCES =rom.s rom-lcd.s rom.ld
4830
4931DIST_ASM_SOURCES =h8300-i586.S h8300-x86-64.S h8300-sparc.S
50- ROM_SOURCES =rom.s rom-lcd.s rom.ld
5132
5233DIST = README Makefile \
5334 $(SOURCES ) $(DIST_ASM_SOURCES ) $(HEADERS ) \
@@ -58,68 +39,21 @@ DIST = README Makefile \
5839 firmdl.diff dll-src.diff Makefile.diff \
5940 brickemu.dxy rom.bin
6041
61- # # NOTE: Assembly sources do not work with current compiler tools,
62- # # so disabling EMU_ASM_SOURCE_FILES for now by commenting out the line below.
63- # MACHINE:=$(shell uname -m)
64- ifeq ($(MACHINE ) ,x86_64)
65- EMU_ASM_SOURCE_FILES =h8300-x86-64.S
66- else
67- ifneq ($(filter i%86,$(MACHINE)),)
68- EMU_ASM_SOURCE_FILES =h8300-i586.S
69- else
70- ifneq ($(filter sun4%,$(MACHINE)),)
71- EMU_ASM_SOURCE_FILES =h8300-sparc.S
72- LIBS += -lsocket
73- endif
74- endif
75- endif
76- ifneq ($(EMU_ASM_SOURCE_FILES ) ,)
77- CFLAGS += -DHAVE_RUN_CPU_ASM
78- endif
79-
80- EMU_ASM_SOURCE_PATHS=$(EMU_ASM_SOURCE_FILES:% =$(EMUSUBDIR ) %)
81-
8242
8343OBJS = $(subst .c,.o,$(EMU_SOURCE_PATHS ) ) $(subst .S,.o,$(EMU_ASM_SOURCE_PATHS ) ) \
8444 $(subst .c,.o,$(EMU_SOUND_SOURCE_PATHS ) )
8545
8646
8747all : emu ir-server rom
8848
89- clean : emu-clean
90-
91- realclean : clean emu-realclean
92- rm -f ir-server
93-
94-
95- emu : CFLAGS += $(PROFILE )
96- emu : $(OBJS )
97- $(CC ) $(CFLAGS ) $^ $(LIBS ) -lz -o $@
98-
99- emu-clean :
100- rm -f * .o * .inc
101- rm -rf html latex
102-
103- emu-realclean : emu-clean
104- rm -f emu
105-
106- emu-install :
10749
108- emu-uninstall :
50+ include $( MAKEFILE_DIR ) /Makefile.sub
10951
110- # Empty target to see how the sound library check evaluates
111- check-sound-lib :
11252
53+ clean : emu-clean
11354
114-
115- h83% .inc : h83% .pl
116- perl $^ > $@
117-
118- h8300.o : h8300.inc h8300.h
119- h8300-i586.o : h8300-i586.inc
120- h8300-x86-64.o : h8300-x86-64.inc
121- h8300-sparc.o : h8300-sparc.inc
122- lcd.o : h8300.h
55+ realclean : clean emu-realclean
56+ rm -f ir-server
12357
12458
12559brickemu.tar.gz : $(DIST )
@@ -148,4 +82,4 @@ rom.bin: rom.coff
14882 $(CROSSTOOLPREFIX ) objcopy$(CROSSTOOLSUFFIX ) -I coff-h8300 -O binary $< $@
14983
15084
151- .PHONY : all clean realclean emu-clean emu-realclean emu-install emu-uninstall rom
85+ .PHONY : all clean realclean emu-clean emu-realclean emu-install emu-uninstall rom
0 commit comments