Sort out the fucking messages mess
[lsnes.git] / Makefile
blobce85c3e954febd02bb1c1391799bb552378d9547
1 OPTIONS=options.build
2 include $(OPTIONS)
4 ifndef LUA
5 LUA=lua
6 endif
8 #Compilers.
9 REALCC = $(CROSS_PREFIX)$(CC)
10 REALLD = $(CROSS_PREFIX)$(LD)
11 REALRANLIB = $(CROSS_PREFIX)$(RANLIB)
13 ifeq ($(CORE_TYPE), BSNES)
14 CORE_PATH=$(shell pwd)/bsnes
15 CORE_SUBDIR=bsnes
16 CORE_OBJECT=bsnes/out/libsnes.$(ARCHIVE_SUFFIX)
17 CORE_DEFINE=-DCORETYPE_BSNES=1
18 ifdef BSNES_IS_COMPAT
19 CFLAGS += -DBSNES_IS_COMPAT
20 BSNES_PROFILE_STRING=profile=compatibility
21 else
22 BSNES_PROFILE_STRING=profile=accuracy
23 endif
24 ifeq ($(BSNES_VERSION), 084)
25 BSNES_PROFILE_STRING+=options=debugger
26 CFLAGS += -DBSNES_HAS_DEBUGGER
27 else
28 ifeq ($(BSNES_VERSION), 085)
29 BSNES_PROFILE_STRING+=options=debugger
30 CFLAGS += -DBSNES_HAS_DEBUGGER
31 endif
32 endif
34 ifeq ($(BSNES_VERSION), 087)
35 BSNES_TARGET_STRING=target=libsnes
36 else
37 BSNES_TARGET_STRING=ui=ui-libsnes
38 endif
39 CFLAGS += -DBSNES_V${BSNES_VERSION}
40 else
41 ifeq ($(CORE_TYPE), GAMBATTE)
42 CORE_PATH=$(shell pwd)/gambatte
43 CORE_SUBDIR=gambatte
44 CORE_OBJECT=gambatte/libgambatte/libgambatte.$(ARCHIVE_SUFFIX)
45 CORE_DEFINE=-DCORETYPE_GAMBATTE=1
46 BSNES_PROFILE_STRING=
47 BSNES_TARGET_STRING=
48 else
49 $(error "Bad value for CORETYPE (expected BSNES or GAMBATTE)")
50 endif
51 endif
53 #Flags.
54 HOSTCCFLAGS = -std=gnu++0x
55 CFLAGS += -I$(CORE_PATH) $(CORE_DEFINE) -std=gnu++0x $(USER_CFLAGS)
56 ifdef BOOST_NEEDS_MT
57 BOOST_LIB_POSTFIX=-mt
58 else
59 BOOST_LIB_POSTFIX=
60 endif
62 LDFLAGS = -lboost_iostreams$(BOOST_LIB_POSTFIX) -lboost_filesystem$(BOOST_LIB_POSTFIX) -lboost_system$(BOOST_LIB_POSTFIX) -lboost_regex$(BOOST_LIB_POSTFIX) -lz $(USER_LDFLAGS)
64 ifeq ($(THREADS), NATIVE)
65 CFLAGS += -DNATIVE_THREADS
66 else
67 ifeq ($(THREADS), BOOST)
68 CFLAGS += -DBOOST_THREADS
69 LDFLAGS += -lboost_thread$(BOOST_LIB_POSTFIX)
70 else
71 $(error "Bad value for THREADS (expected NATIVE or BOOST)")
72 endif
73 endif
76 export
78 all: src/__all_files__
80 CFLAGS += $(shell $(CROSS_PREFIX)pkg-config $(LUA) --cflags)
81 LDFLAGS += $(shell $(CROSS_PREFIX)pkg-config $(LUA) --libs)
83 compiler=$(subst ++,cc,$(REALCC))
84 gambatte_compiler=$(REALCC)
86 $(CORE_OBJECT): forcelook
87 $(MAKE) -C $(CORE_SUBDIR) $(BSNES_PROFILE_STRING) $(BSNES_TARGET_STRING)
88 $(REALRANLIB) $@
90 src/__all_files__: src/core/version.cpp forcelook $(CORE_OBJECT)
91 $(MAKE) -C src precheck
92 $(MAKE) -C src
93 cp src/lsnes$(DOT_EXECUTABLE_SUFFIX) .
95 buildaux/version.exe: buildaux/version.cpp VERSION
96 $(HOSTCC) $(HOSTCCFLAGS) -o $@ $<
97 src/core/version.cpp: buildaux/version.exe forcelook
98 buildaux/version.exe >$@
101 clean:
102 -$(MAKE) -C bsnes clean
103 -$(MAKE) -C gambatte clean
104 $(MAKE) -C src clean
106 forcelook:
107 @true