]> Shamusworld >> Repos - virtualjaguar/blob - jaguarcore.mak
89faa3bad1e42c1779da55d6a5a3520772aaf89a
[virtualjaguar] / jaguarcore.mak
1 #
2 # Makefile for Virtual Jaguar core library
3 #
4 # by James Hammons
5 #
6 # This software is licensed under the GPL v3 or any later version. See the
7 # file GPLv3 for details. ;-)
8 #
9
10 # Cross compilation with MXE
11 #CROSS = i686-pc-mingw32-
12
13 # Figure out which system we're compiling for, and set the appropriate variables
14
15 ifeq "$(CROSS)" ""
16 OSTYPE := $(shell uname -a)
17
18 # Win32
19 ifeq "$(findstring Msys,$(OSTYPE))" "Msys"
20
21 SYSTYPE    := __GCCWIN32__
22 SDLLIBTYPE := --libs
23
24 # Apple. Should catch both 'darwin' and 'darwin7.0'
25 else ifeq "$(findstring Darwin,$(OSTYPE))" "Darwin"
26
27 SYSTYPE    := __GCCUNIX__ -D__THINK_STUPID__
28 SDLLIBTYPE := --static-libs
29
30 # Linux
31 else ifeq "$(findstring Linux,$(OSTYPE))" "Linux"
32
33 SYSTYPE    := __GCCUNIX__
34 SDLLIBTYPE := --libs
35
36 # ??? Throw error, unknown OS
37 else
38
39 $(error OS TYPE UNDETECTED)
40
41 endif
42 else
43 SYSTYPE    := __GCCWIN32__
44 SDLLIBTYPE := --libs
45 endif
46
47 # Set vars for libcdio
48 ifneq "$(shell pkg-config --silence-errors --libs libcdio)" ""
49 HAVECDIO := -DHAVE_LIB_CDIO
50 CDIOLIB  := -lcdio
51 else
52 HAVECDIO :=
53 CDIOLIB  :=
54 endif
55
56 CC      := $(CROSS)gcc
57 LD      := $(CROSS)gcc
58 AR      := $(CROSS)ar
59 ARFLAGS := -rs
60
61 # Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
62 #CFLAGS  := -MMD -O2 -ffast-math -fomit-frame-pointer `sdl-config --cflags` -D$(SYSTYPE)
63 #CXXFLAGS  := -MMD -O2 -ffast-math -fomit-frame-pointer `sdl-config --cflags` -D$(SYSTYPE)
64 CFLAGS ?= -O2 -ffast-math -fomit-frame-pointer
65 CXXFLAGS ?= -O2 -ffast-math -fomit-frame-pointer
66
67 SDL_CFLAGS = `$(CROSS)sdl-config --cflags`
68 DEFINES = -D$(SYSTYPE)
69 GCC_DEPS = "-MMD"
70
71 INCS := -I./src
72
73 OBJS := \
74         obj/blitter.o      \
75         obj/cdintf.o       \
76         obj/cdrom.o        \
77         obj/crc32.o        \
78         obj/dac.o          \
79         obj/dsp.o          \
80         obj/eeprom.o       \
81         obj/event.o        \
82         obj/file.o         \
83         obj/filedb.o       \
84         obj/gpu.o          \
85         obj/jagbios.o      \
86         obj/jagcdbios.o    \
87         obj/jagdevcdbios.o \
88         obj/jagstub1bios.o \
89         obj/jagstub2bios.o \
90         obj/jagdasm.o      \
91         obj/jaguar.o       \
92         obj/jerry.o        \
93         obj/joystick.o     \
94         obj/log.o          \
95         obj/memory.o       \
96         obj/mmu.o          \
97         obj/op.o           \
98         obj/settings.o     \
99         obj/state.o        \
100         obj/tom.o          \
101         obj/universalhdr.o \
102         obj/unzip.o        \
103         obj/wavetable.o
104
105 # Targets for convenience sake, not "real" targets
106 .PHONY: clean
107
108 all: obj obj/libjaguarcore.a
109         @echo "Done!"
110
111 obj:
112         @mkdir obj
113
114 # Library rules (might not be cross-platform compatible)
115 obj/libjaguarcore.a: $(OBJS) 
116         @$(AR) $(ARFLAGS) obj/libjaguarcore.a $(OBJS)
117
118 # Main source compilation (implicit rules)...
119
120 obj/%.o: src/%.c
121         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
122 #       @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
123         @$(CC) $(GCC_DEPS) $(CFLAGS) $(SDL_CFLAGS) $(DEFINES) $(INCS) -c $< -o $@
124
125 obj/%.o: src/%.cpp
126         @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
127 #       @$(CC) $(CXXFLAGS) $(INCS) -c $< -o $@
128         @$(CC) $(GCC_DEPS) $(CXXFLAGS) $(SDL_CFLAGS) $(DEFINES) $(INCS) -c $< -o $@
129
130 -include obj/*.d