-
Notifications
You must be signed in to change notification settings - Fork 9
/
makefile.odx
139 lines (110 loc) · 3.78 KB
/
makefile.odx
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Define compilation type
OSTYPE=msys
#OSTYPE=oda320
#OSTYPE=gcw0
ifeq ($(TARGET),)
TARGET = mame
# TARGET = neomame
endif
# set this the operating system you're building for
# (actually you'll probably need your own main makefile anyways)
# MAMEOS = msdos
MAMEOS = odx
# extension for executables
# EXE = .exe
EXE =
# CPU core include paths
VPATH=src $(wildcard src/cpu/*)
# define regarding OS, which compiler, linker and utilities to use
ifeq "$(OSTYPE)" "msys"
TOOLCHAIN = /c/MinGW32
CC = $(TOOLCHAIN)/bin/gcc
CPP = $(TOOLCHAIN)/bin/gcc
LD = $(TOOLCHAIN)/bin/gcc
else
ifeq "$(OSTYPE)" "gcw0"
TOOLCHAIN = /opt/gcw0-toolchain/usr
else
TOOLCHAIN = /opt/opendingux-toolchain/usr
endif
CC = $(TOOLCHAIN)/bin/mipsel-linux-gcc
CPP = $(TOOLCHAIN)/bin/mipsel-linux-gcc
LD = $(TOOLCHAIN)/bin/mipsel-linux-gcc
endif
MD = @mkdir
RM = @rm -f
CP = @cp
MV = @mv
DEVLIBS =
EMULATOR = $(TARGET)$(EXE)
DEFS = -D__ODX__ -DLSB_FIRST -DALIGN_INTS -DALIGN_SHORTS -DINLINE="static inline" -Dasm="__asm__ __volatile__" -DMAME_UNDERCLOCK -DMAME_FASTSOUND -DENABLE_AUTOFIRE -DBIGCASE
W_OPTS = -Wall -Wno-write-strings -Wno-sign-compare
ifeq "$(OSTYPE)" "msys"
F_OPTS = -fomit-frame-pointer -ffunction-sections -ffast-math -fsingle-precision-constant -fsigned-char -fpermissive
CFLAGS = -O2 -Isrc -Isrc/$(MAMEOS) -Isrc/zlib $(W_OPTS) $(F_OPTS)
CFLAGS += -g
LIB_PATH = $(TOOLCHAIN)/lib
LIBS = -lSDLmain -lSDL -lm -lmingw32 -mwindows
LDFLAGS = $(CFLAGS) -L$(LIB_PATH) $(LIBS)
else
#F_OPTS = -funroll-loops -fomit-frame-pointer -ffast-math -fsingle-precision-constant -fpermissive -fsigned-char -fno-exceptions -fno-rtti
F_OPTS = -fpermissive -falign-functions -falign-loops -falign-labels -falign-jumps \
-ffast-math -fsingle-precision-constant -funsafe-math-optimizations \
-fomit-frame-pointer -fno-builtin -fno-exceptions -fno-common \
-fstrict-aliasing -fexpensive-optimizations -fno-pic \
-finline -finline-functions -fmerge-all-constants \
-ftree-vectorize -fweb -frename-registers
ifeq "$(OSTYPE)" "gcw0"
CFLAGS = -D_GCW0_ -G0 -O3 -march=mips32 -mtune=mips32r2 -Isrc -Isrc/$(MAMEOS) -Isrc/zlib -mhard-float -mbranch-likely -mno-mips16 $(W_OPTS) $(F_OPTS)
else
CFLAGS = -D_GCW0_ -G0 -O3 -march=mips32 -mtune=mips32 -Isrc -Isrc/$(MAMEOS) -Isrc/zlib -msoft-float --mbranch-likely -mno-mips16 $(W_OPTS) $(F_OPTS)
endif
#CFLAGS += -g
LIB_PATH = $(TOOLCHAIN)/lib
#LIBS = -lSDL -lpthread -lm -lgcc -lstdc++
LIBS = -lSDL -lpthread -lm -lgcc
LDFLAGS = $(CFLAGS) -L$(LIB_PATH) $(LIBS) -s
#LDFLAGS = -Wl,--gc-sections -Wl,-s
endif
OBJ = obj_$(TARGET)_$(MAMEOS)
OBJDIRS = $(OBJ) $(OBJ)/cpu $(OBJ)/sound $(OBJ)/$(MAMEOS) \
$(OBJ)/drivers $(OBJ)/machine $(OBJ)/vidhrdw $(OBJ)/sndhrdw \
$(OBJ)/zlib
all: maketree $(EMULATOR)
# include the various .mak files
include src/core.mak
include src/$(TARGET).mak
include src/rules.mak
include src/sound.mak
include src/$(MAMEOS)/$(MAMEOS).mak
# combine the various definitions to one
CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS)
$(EMULATOR): $(COREOBJS) $(OSOBJS) $(DRVOBJS)
$(LD) $(LDFLAGS) $(COREOBJS) $(OSOBJS) $(LIBS) $(DRVOBJS) -o $@
$(MV) $(EMULATOR) distrib/mame4all/$(EMULATOR)
$(EMULATOR).dge: $(FEOBJS)
@echo Linking $@ ...
$(LD) $(LDFLAGS) $(FEOBJS) $(LIBS) -o $@
ifeq "$(OSTYPE)" "msys"
$(MV) $(EMULATOR).dge distrib/mame4all/$(EMULATOR).dge.exe
else
$(MV) $(EMULATOR).dge distrib/mame4all/$(EMULATOR).dge
endif
$(OBJ)/%.o: src/%.c
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: src/%.cpp
@echo Compiling $<...
$(CPP) $(CDEFS) $(CFLAGS) -fno-rtti -c $< -o $@
$(OBJ)/%.o: src/%.s
@echo Compiling $<...
$(CPP) $(CDEFS) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: src/%.S
@echo Compiling $<...
$(CPP) $(CDEFS) $(CFLAGS) -c $< -o $@
$(sort $(OBJDIRS)):
$(MD) $@
maketree: $(sort $(OBJDIRS))
clean:
$(RM) -r $(OBJ)
$(RM) $(EMULATOR)