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