Skip to content

Commit 7d5d1c8

Browse files
committed
Preliminary refactor of Makefiles for cross-compatibility with brickOS-bibo
1 parent dc949e3 commit 7d5d1c8

File tree

2 files changed

+139
-86
lines changed

2 files changed

+139
-86
lines changed

Makefile

Lines changed: 20 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
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+
619
CC=gcc
720
CFLAGS=-std=gnu89 -O2 -pg -g -Wall -Wmissing-prototypes
821
CROSSTOOLPREFIX=h8300-hitachi-coff-
@@ -13,41 +26,9 @@ PROFILE=
1326
# If defined, EMUSUBDIR _MUST_ include the trailing directory slash
1427
EMUSUBDIR=
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

4931
DIST_ASM_SOURCES=h8300-i586.S h8300-x86-64.S h8300-sparc.S
50-
ROM_SOURCES=rom.s rom-lcd.s rom.ld
5132

5233
DIST = 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

8343
OBJS = $(subst .c,.o,$(EMU_SOURCE_PATHS)) $(subst .S,.o,$(EMU_ASM_SOURCE_PATHS)) \
8444
$(subst .c,.o,$(EMU_SOUND_SOURCE_PATHS))
8545

8646

8747
all: 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

12559
brickemu.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

Makefile.sub

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
8+
# Development Packages:
9+
# * Required: GNU GCC, h8300 toolchain
10+
# * Optional: ALSA, SDL
11+
# Runtime Packages Required: TK, TCL Libs, and ALSA or SDL
12+
# * openSUSE: tk
13+
14+
# If defined, EMUSUBDIR _MUST_ include the trailing directory slash
15+
EMUSUBDIR?=
16+
17+
ifeq ($(SOUND),mute)
18+
$(info SOUND Library Target: Muted (requested via value of SOUND))
19+
EMU_SOUND_SOURCE_FILES=sound_none.c
20+
else ifneq ($(shell which sdl-config 2>/dev/null),)
21+
# SDL depends on ALSA, so if the ALSA check is first, SDL will never be selected
22+
$(info SOUND Library Target: SDL (Simple DirectMedia Layer))
23+
# use default SDL config arguments
24+
CFLAGS += $(shell sdl-config --cflags)
25+
LIBS += $(shell sdl-config --libs)
26+
# use custom SDL config arguments (e.g. for building in Cygwin)
27+
#CFLAGS += -I/usr/local/include/SDL
28+
#LIBS += -L/usr/local/lib -lSDL
29+
EMU_SOUND_SOURCE_FILES=sound_sdl.c
30+
else ifeq ($(shell test -d /usr/include/alsa && echo 1),1)
31+
$(info SOUND Library Target: ALSA (Advanced Linux Sound Architecture))
32+
LIBS += -L/usr/lib -lasound
33+
EMU_SOUND_SOURCE_FILES=sound_alsa.c
34+
else
35+
$(info SOUND Library Target: None (no compatible libraries found))
36+
EMU_SOUND_SOURCE_FILES=sound_none.c
37+
endif
38+
EMU_SOUND_SOURCE_PATHS=$(EMU_SOUND_SOURCE_FILES:%=$(EMUSUBDIR)%)
39+
40+
## NOTE: Assembly sources do not work with current compiler tools,
41+
## so disabling EMU_ASM_SOURCE_FILES for now by commenting out the line below.
42+
#MACHINE:=$(shell uname -m)
43+
ifeq ($(MACHINE),x86_64)
44+
EMU_ASM_SOURCE_FILES=h8300-x86-64.S
45+
else
46+
ifneq ($(filter i%86,$(MACHINE)),)
47+
EMU_ASM_SOURCE_FILES=h8300-i586.S
48+
else
49+
ifneq ($(filter sun4%,$(MACHINE)),)
50+
EMU_ASM_SOURCE_FILES=h8300-sparc.S
51+
LIBS += -lsocket
52+
endif
53+
endif
54+
endif
55+
ifneq ($(EMU_ASM_SOURCE_FILES),)
56+
CFLAGS += -DHAVE_RUN_CPU_ASM
57+
endif
58+
EMU_ASM_SOURCE_PATHS=$(EMU_ASM_SOURCE_FILES:%=$(EMUSUBDIR)%)
59+
60+
EMU_SOURCE_FILES=main.c h8300.c peripherals.c memory.c lcd.c timer16.c timer8.c \
61+
buttons.c waitstate.c frame.c serial.c debugger.c adsensors.c \
62+
watchdog.c firmware.c coff.c srec.c socket.c motor.c symbols.c \
63+
lx.c hash.c savefile.c printf.c brickos.c bibo.c
64+
EMU_SOURCE_PATHS=$(EMU_SOURCE_FILES:%=$(EMUSUBDIR)%)
65+
66+
EMU_HEADER_FILES=types.h h8300.h peripherals.h memory.h lx.h symbols.h hash.h \
67+
frame.h debugger.h socket.h coff.h
68+
EMU_HEADER_PATHS=$(EMU_HEADER_FILES:%=$(EMUSUBDIR)%)
69+
70+
EMU_OBJS = $(subst .c,.o,$(EMU_SOURCE_PATHS)) $(subst .S,.o,$(EMU_ASM_SOURCE_PATHS)) \
71+
$(subst .c,.o,$(EMU_SOUND_SOURCE_PATHS))
72+
73+
74+
DIST_ASM_SOURCES=h8300-i586.S h8300-x86-64.S h8300-sparc.S
75+
76+
DIST = README Makefile \
77+
$(SOURCES) $(DIST_ASM_SOURCES) $(HEADERS) \
78+
sound_alsa.c sound_sdl.c sound_none.c \
79+
$(ROM_SOURCES) \
80+
h8300.pl h8300-i586.pl h8300-x86-64.pl h8300-sparc.pl \
81+
ir-server.c GUI.tcl remote \
82+
firmdl.diff dll-src.diff Makefile.diff \
83+
brickemu.dxy
84+
85+
86+
87+
88+
emu: CFLAGS += $(PROFILE)
89+
emu: $(EMU_OBJS)
90+
$(CC) $(CFLAGS) $^ $(LIBS) -lz -o $@
91+
92+
emu-clean:
93+
rm -f *.o *.inc
94+
rm -f -r html latex
95+
96+
emu-realclean: emu-clean
97+
rm -f emu
98+
99+
emu-install:
100+
101+
102+
emu-uninstall:
103+
104+
105+
# Empty target to see how the sound library check evaluates
106+
check-sound-lib:
107+
108+
109+
h83%.inc: h83%.pl
110+
perl $^ > $@
111+
112+
h8300.o: h8300.inc h8300.h
113+
h8300-i586.o: h8300-i586.inc
114+
h8300-x86-64.o: h8300-x86-64.inc
115+
h8300-sparc.o: h8300-sparc.inc
116+
lcd.o: h8300.h
117+
118+
119+
.PHONY: all clean realclean emu-clean emu-realclean emu-install emu-uninstall

0 commit comments

Comments
 (0)