comparison Makefile @ 761:ffb8cc5845fa

Add support for making a "portable" build on OSX to Makefile
author Michael Pavone <pavone@retrodev.com>
date Sun, 28 Jun 2015 17:16:24 -0700
parents 7306b3967c51
children 206c449eaa81
comparison
equal deleted inserted replaced
760:656b1fded67f 761:ffb8cc5845fa
1 ifndef OS 1 ifndef OS
2 OS:=$(shell uname -s) 2 OS:=$(shell uname -s)
3 endif 3 endif
4 4
5 ifeq ($(OS),Windows) 5 ifeq ($(OS),Windows)
6 CC:=wine gcc.exe
7 6
8 MEM:=mem_win.o 7 MEM:=mem_win.o
9 BLASTEM:=blastem.exe 8 BLASTEM:=blastem.exe
10
11 CC:=wine gcc.exe 9 CC:=wine gcc.exe
12 CFLAGS:=-O2 -std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"C:/MinGW/usr/include/SDL2" -DGLEW_STATIC 10 CFLAGS:=-O2 -std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"C:/MinGW/usr/include/SDL2" -DGLEW_STATIC
13 LDFLAGS:= -L"C:/MinGW/usr/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lglu32 -mwindows 11 LDFLAGS:= -L"C:/MinGW/usr/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lglu32 -mwindows
14 CPU:=i686 12 CPU:=i686
15 13
22 LIBS=sdl2 glew 20 LIBS=sdl2 glew
23 else 21 else
24 LIBS=sdl2 glew gl 22 LIBS=sdl2 glew gl
25 endif #Darwin 23 endif #Darwin
26 24
25 CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -Wno-logical-op-parentheses
26 FIXUP:=
27 ifdef PORTABLE
28 CFLAGS+= -DGLEW_STATIC -Iglew/include
29 LDFLAGS:=-lm glew/lib/libGLEW.a
30
31 ifeq ($(OS),Darwin)
32 CFLAGS+= -IFrameworks/SDL2.framework/Headers
33 LDFLAGS+= -FFrameworks -framework SDL2 -framework OpenGL
34 FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2 ./blastem
35 endif #Darwin
36
37 else
38 CFLAGS:=$(shell pkg-config --cflags-only-I $(LIBS)) $(CFLAGS)
39 LDFLAGS:=-lm $(shell pkg-config --libs $(LIBS))
40
41 ifeq ($(OS),Darwin)
42 LDFLAGS+= -framework OpenGL
43 endif
44
45 endif #PORTABLE
46
27 ifdef DEBUG 47 ifdef DEBUG
28 CFLAGS:=-ggdb -std=gnu99 $(shell pkg-config --cflags-only-I $(LIBS)) -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -Wno-logical-op-parentheses 48 CFLAGS:=-ggdb $(CFLAGS)
29 LDFLAGS:=-ggdb -lm $(shell pkg-config --libs $(LIBS)) 49 LDFLAGS:=-ggdb $(LDFLAGS)
30 else 50 else
31 CFLAGS:=-O2 -flto -std=gnu99 $(shell pkg-config --cflags-only-I $(LIBS)) -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -Wno-logical-op-parentheses 51 CFLAGS:=-O2 -flto $(CFLAGS)
32 LDFLAGS:=-O2 -flto -lm $(shell pkg-config --libs $(LIBS)) 52 LDFLAGS:=-O2 -flto $(LDFLAGS)
33 endif #DEBUG 53 endif #DEBUG
34 endif #Windows 54 endif #Windows
35 55
36 ifdef Z80_LOG_ADDRESS 56 ifdef Z80_LOG_ADDRESS
37 CFLAGS+= -DZ80_LOG_ADDRESS 57 CFLAGS+= -DZ80_LOG_ADDRESS
55 CFLAGS+= -DM68010 75 CFLAGS+= -DM68010
56 endif 76 endif
57 77
58 ifndef CPU 78 ifndef CPU
59 CPU:=$(shell uname -m) 79 CPU:=$(shell uname -m)
60 endif
61
62 ifeq ($(OS),Darwin)
63 LDFLAGS+= -framework OpenGL
64 endif 80 endif
65 81
66 TRANSOBJS=gen.o backend.o $(MEM) 82 TRANSOBJS=gen.o backend.o $(MEM)
67 M68KOBJS=68kinst.o m68k_core.o 83 M68KOBJS=68kinst.o m68k_core.o
68 ifeq ($(CPU),x86_64) 84 ifeq ($(CPU),x86_64)
103 119
104 all : dis zdis stateview vgmplay blastem 120 all : dis zdis stateview vgmplay blastem
105 121
106 $(BLASTEM) : $(MAINOBJS) 122 $(BLASTEM) : $(MAINOBJS)
107 $(CC) -o $(BLASTEM) $(MAINOBJS) $(LDFLAGS) 123 $(CC) -o $(BLASTEM) $(MAINOBJS) $(LDFLAGS)
124 $(FIXUP)
108 125
109 dis : dis.o 68kinst.o tern.o vos_program_module.o 126 dis : dis.o 68kinst.o tern.o vos_program_module.o
110 $(CC) -o dis dis.o 68kinst.o tern.o vos_program_module.o 127 $(CC) -o dis dis.o 68kinst.o tern.o vos_program_module.o
111 128
112 zdis : zdis.o z80inst.o 129 zdis : zdis.o z80inst.o