aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: b6ede7c31733d99ee399444ace4224918ddccb10 (plain)
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
TARGET_NAME   := catsfc

INCLUDE     := -Isource -Isource/unzip -Isource/nds
INCLUDE     += -I.

platform = unix

ifeq ($(platform), unix)
   TARGET := $(TARGET_NAME)_libretro.so
   fpic   := -fPIC
   SHARED := -shared -Wl,--version-script=link.T
   CROSS  :=

   CFLAGS := -fno-builtin \
            -fno-exceptions -ffunction-sections \
             -fomit-frame-pointer -fgcse-sm -fgcse-las -fgcse-after-reload \
             -fweb -fpeel-loops \
             -Wall -Wno-unused-function -Wno-unused-variable

   DEFS   :=
else
   TARGET := $(TARGET_NAME)_libretro_psp1.a
   CROSS  := psp-
   CFLAGS := -G0 -march=allegrex -mno-abicalls -fno-pic -fno-builtin \
            -fno-exceptions -ffunction-sections -mno-long-calls \
             -fomit-frame-pointer -fgcse-sm -fgcse-las -fgcse-after-reload \
             -fweb -fpeel-loops \
             -Wall -Wno-unused-function -Wno-unused-variable

#   CFLAGS   += -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi
#   CFLAGS   += -fomit-frame-pointer -fstrict-aliasing
#   CFLAGS   += -falign-functions=32 -falign-loops -falign-labels -falign-jumps
#   CFLAGS   += -Wall -Wundef -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wsign-compare

   DEFS   :=  -DPSP -D_PSP_FW_VERSION=371

   INCLUDE     += -I$(shell psp-config --pspsdk-path)/include
#   INCLUDE     += -I$(shell psp-config --psp-prefix)/include
   STATIC_LINKING := 1
endif

# - - - Tools - - -
CC           = $(CROSS)gcc
AR           = $(CROSS)ar
LD           = $(CROSS)ld
OBJCOPY      = $(CROSS)objcopy
NM           = $(CROSS)nm
OBJDUMP      = $(CROSS)objdump

#C_SOURCES   = libretro.c
CPP_SOURCES = source/apu.cpp source/c4.cpp \
              source/c4emu.cpp source/cheats2.cpp source/cheats.cpp \
              source/clip.cpp source/cpu.cpp source/cpuexec.cpp \
              source/cpuops.cpp source/data.cpp\
              source/dma.cpp source/dsp1.cpp \
              source/fxdbg.cpp source/fxemu.cpp source/fxinst.cpp \
              source/gfx.cpp source/globals.cpp \
              source/memmap.cpp \
              source/obc1.cpp source/ppu.cpp \
              source/sa1.cpp source/sa1cpu.cpp source/screenshot.cpp \
              source/sdd1.cpp source/sdd1emu.cpp \
              source/seta010.cpp source/seta011.cpp source/seta018.cpp \
              source/seta.cpp source/snaporig.cpp source/snapshot.cpp \
              source/soundux.cpp \
              source/spc700.cpp source/spc7110.cpp \
              source/srtc.cpp \
              source/tile.cpp \
              libretro.cpp

SOURCES      = $(C_SOURCES) $(CPP_SOURCES)
C_OBJECTS    = $(C_SOURCES:.c=.o)
CPP_OBJECTS  = $(CPP_SOURCES:.cpp=.o)
OBJECTS      = $(C_OBJECTS) $(CPP_OBJECTS)

# - - - Compilation flags - - -

DEFS   += -DSPC700_C -DEXECUTE_SUPERFX_PER_LINE -DSDD1_DECOMP \
          -DVAR_CYCLES -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
          -DNO_INLINE_SET_GET -DNOASM -DHAVE_MKSTEMP '-DACCEPT_SIZE_T=size_t'

ifeq ($(DEBUG), 1)
OPTIMIZE	      := -O0 -g
OPTIMIZE_SAFE  := -O0 -g
else
OPTIMIZE	      := -O3
OPTIMIZE_SAFE  := -O2
endif


DEFS  += -D__LIBRETRO__

CFLAGS += $(fpic)

all: $(TARGET)

$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
	$(AR) rcs $@ $(OBJECTS)
else
	$(CC) $(fpic) $(SHARED) $(INCLUDES) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBM)
endif

clean:
	rm -f $(OBJECTS)
	rm -f depend
	rm -f $(TARGET)

.c.o:
	$(CC) $(OPTIMIZE) $(CFLAGS) $(INCLUDE) $(DEFS) -o $@ -c $<
.cpp.o:
	$(CC) $(OPTIMIZE) $(CFLAGS) $(INCLUDE) $(DEFS) -fno-rtti -o $@ -c $<

Makefile: depend

depend: $(SOURCES)
	$(CC) -MM $(CFLAGS) $(INCLUDE) $(DEFS) $(SOURCES) > $@
	touch Makefile

.PHONY: clean

-include depend