Show distinction between readonly-in-movie and finished in status flags
[lsnes.git] / Makefile
blobf704988e50d5ac133b00119ccefb4325d61a55bd
1 CROSS_PREFIX=
2 EXECUTABLE_SUFFIX = exe
3 OBJECT_SUFFIX = o
4 ARCHIVE_SUFFIX = a
5 FONT_SRC := unifontfull-5.1.20080820.hex
7 #Compilers.
8 CC := g++
9 REALCC = $(CROSS_PREFIX)$(CC)
11 #Flags.
12 HOSTCCFLAGS = -std=gnu++0x
13 CFLAGS = -I$(BSNES_PATH) -Iinclude -Iavi -std=gnu++0x
14 LDFLAGS = -lboost_iostreams -lboost_filesystem -lboost_system -lz
15 PLATFORM_CFLAGS =
16 PLATFORM_LDFLAGS =
18 #Platform defs.
19 GRAPHICS = SDL
20 SOUND = SDL
21 JOYSTICK = SDL
23 #Core objects and what to build.
24 CORE_OBJECTS = $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard src/core/*.cpp)) \
25 $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard avi/*.cpp)) \
26 src/fonts/font.$(OBJECT_SUFFIX)
27 PROGRAMS = lsnes.$(EXECUTABLE_SUFFIX) movieinfo.$(EXECUTABLE_SUFFIX) lsnes-dumpavi.$(EXECUTABLE_SUFFIX) sdmp2sox.$(EXECUTABLE_SUFFIX)
28 all: $(PROGRAMS)
30 #Platform objects.
31 PLATFORM_OBJECTS=
33 #Lua.
34 ifndef LUA
35 CFLAGS += -DNO_LUA
36 else
37 CORE_OBJECTS += $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard src/lua/*.cpp))
38 CFLAGS += $(shell $(CROSS_PREFIX)pkg-config $(LUA) --cflags)
39 LDFLAGS += $(shell $(CROSS_PREFIX)pkg-config $(LUA) --libs)
40 endif
42 #Threads
43 ifdef THREADS
44 ifeq ($(THREADS), YES)
45 CFLAGS += -DUSE_THREADS
46 else
47 ifeq ($(THREADS), NO)
48 CFLAGS += -DNO_THREADS
49 else
50 $(error "Bad value for THREADS (expected YES or NO)")
51 endif
52 endif
53 endif
56 #Some misc defines.
57 ifdef BSNES_IS_COMPAT
58 CFLAGS += -DBSNES_IS_COMPAT
59 endif
61 #Joystick.
62 ifeq ($(JOYSTICK), SDL)
63 ifneq ($(GRAPHICS), SDL)
64 $(error "SDL Joystick requires SDL graphics")
65 endif
66 PLATFORM_OBJECTS += src/plat-sdl/joystick.$(OBJECT_SUFFIX)
67 else
68 ifeq ($(JOYSTICK), DUMMY)
69 CFLAGS += -DSDL_NO_JOYSTICK
70 PLATFORM_OBJECTS += src/plat-dummy/joystick.$(OBJECT_SUFFIX)
71 else
72 ifeq ($(JOYSTICK), EVDEV)
73 CFLAGS += -DSDL_NO_JOYSTICK
74 PLATFORM_OBJECTS += $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard src/plat-evdev/*.cpp))
75 else
76 $(error "Unsupported joystick type")
77 endif
78 endif
79 endif
81 #Sound stuff.
82 ifeq ($(SOUND), SDL)
83 ifneq ($(GRAPHICS), SDL)
84 $(error "SDL Sound requires SDL graphics")
85 endif
86 PLATFORM_OBJECTS += src/plat-sdl/sound.$(OBJECT_SUFFIX)
87 else
88 ifeq ($(SOUND), PORTAUDIO)
89 PLATFORM_OBJECTS += src/plat-portaudio/sound.$(OBJECT_SUFFIX)
90 PLATFORM_CFLAGS += $(shell $(CROSS_PREFIX)pkg-config portaudio-2.0 --cflags)
91 PLATFORM_LDFLAGS += $(shell $(CROSS_PREFIX)pkg-config portaudio-2.0 --libs)
92 else
93 ifeq ($(SOUND), DUMMY)
94 PLATFORM_OBJECTS += src/plat-dummy/sound.$(OBJECT_SUFFIX)
95 else
96 $(error "Unsupported sound type")
97 endif
98 endif
99 endif
101 #Graphics stuff.
102 ifeq ($(GRAPHICS), SDL)
103 PLATFORM_OBJECTS += src/plat-sdl/main.$(OBJECT_SUFFIX) src/plat-sdl/graphics.$(OBJECT_SUFFIX) src/plat-sdl/paint.$(OBJECT_SUFFIX)
104 PLATFORM_CFLAGS += $(shell $(CROSS_PREFIX)sdl-config --cflags)
105 PLATFORM_LDFLAGS += $(shell $(CROSS_PREFIX)sdl-config --libs)
106 else
107 ifeq ($(GRAPHICS), WXWIDGETS)
108 PLATFORM_OBJECTS += $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard src/plat-wxwidgets/*.cpp))
109 PLATFORM_CFLAGS += $(shell $(CROSS_PREFIX)wx-config --cxxflags) $(shell $(CROSS_PREFIX)pkg-config libswscale --cflags)
110 PLATFORM_LDFLAGS += $(shell $(CROSS_PREFIX)wx-config --libs) $(shell $(CROSS_PREFIX)pkg-config libswscale --libs)
111 else
112 $(error "Unsupported graphics type")
113 endif
114 endif
116 CORE_CFLAGS=$(CFLAGS) $(USER_CFLAGS)
117 SUPPORT_CFLAGS=$(CORE_CFLAGS) $(PLATFORM_CFLAGS) $(USER_PLATFORM_CFLAGS)
118 CORE_LDFLAGS=$(BSNES_PATH)/out/libsnes.$(ARCHIVE_SUFFIX) $(LDFLAGS) $(USER_LDFLAGS)
119 SUPPORT_LDFLAGS=$(CORE_LDFLAGS) $(PLATFORM_LDFLAGS) $(USER_PLATFORM_LDFLAGS)
120 PLAT_DUMMY_OBJECTS=$(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard src/plat-dummy/*.cpp))
121 HOST_CFLAGS=$(HOSTCCFLAGS) $(USER_HOSTCCFLAGS)
122 HOST_LDFLAGS=$(HOSTLDFLAGS) $(USER_HOSTLDFLAGS)
124 .PRECIOUS: %
126 #Stuff compiled with core CFLAGS.
127 avi/%.$(OBJECT_SUFFIX): avi/%.cpp
128 $(REALCC) -c -o $@ $< $(CORE_CFLAGS)
129 src/core/%.$(OBJECT_SUFFIX): src/core/%.cpp
130 $(REALCC) -c -o $@ $< $(CORE_CFLAGS)
131 src/lua/%.$(OBJECT_SUFFIX): src/lua/%.cpp
132 $(REALCC) -c -o $@ $< $(CORE_CFLAGS)
133 src/plat-dummy/%.$(OBJECT_SUFFIX): src/plat-dummy/%.cpp
134 $(REALCC) -c -o $@ $< $(CORE_CFLAGS)
135 src/util/%.$(OBJECT_SUFFIX): src/util/%.cpp
136 $(REALCC) -c -o $@ $< $(CORE_CFLAGS)
138 #Platform stuff to be compiled with support CFLAGS.
139 src/plat-evdev/%.$(OBJECT_SUFFIX): src/plat-evdev/%.cpp
140 $(REALCC) -c -o $@ $< $(SUPPORT_CFLAGS)
141 src/plat-portaudio/%.$(OBJECT_SUFFIX): src/plat-portaudio/%.cpp
142 $(REALCC) -c -o $@ $< $(SUPPORT_CFLAGS)
143 src/plat-sdl/%.$(OBJECT_SUFFIX): src/plat-sdl/%.cpp
144 $(REALCC) -c -o $@ $< $(SUPPORT_CFLAGS)
145 src/plat-wxwidgets/%.$(OBJECT_SUFFIX): src/plat-wxwidgets/%.cpp
146 $(REALCC) -c -o $@ $< $(SUPPORT_CFLAGS)
148 #lsnes main executable.
149 lsnes.$(EXECUTABLE_SUFFIX): $(CORE_OBJECTS) $(PLATFORM_OBJECTS)
150 $(REALCC) -o $@ $^ $(SUPPORT_LDFLAGS)
152 #Other executables.
153 %.$(EXECUTABLE_SUFFIX): src/util/%.$(OBJECT_SUFFIX) $(CORE_OBJECTS) $(PLAT_DUMMY_OBJECTS)
154 $(REALCC) -o $@ $^ $(CORE_LDFLAGS)
156 #Fonts.
157 src/fonts/font.$(OBJECT_SUFFIX): src/fonts/$(FONT_SRC)
158 echo "extern const char* font_hex_data = " >src/fonts/font.cpp
159 sed -E -f src/fonts/fonttransform.sed <$^ >>src/fonts/font.cpp
160 echo ";" >>src/fonts/font.cpp
161 $(REALCC) $(CORE_CFLAGS) -c -o $@ src/fonts/font.cpp
163 clean:
164 rm -f $(PROGRAMS) src/*.$(OBJECT_SUFFIX) src/*/*.$(OBJECT_SUFFIX) avi/*.$(OBJECT_SUFFIX) src/fonts/font.o src/fonts/font.cpp