forked from gak/gravit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.MinGW
168 lines (131 loc) · 4.74 KB
/
Makefile.MinGW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# -*-Makefile-*- for MinGW gcc (32 or 64 bit) on windows
#
FINAL = gravit.exe
ARCH=32
#ARCH=64
DESTDIR=dist/windowsinstaller/$(ARCH)bit
NOARCH=dist/windowsinstaller/files
# -------------------------------
OBJS = src/main.o src/font.o src/frame.o src/frame-pp.o src/frame-pp_sse.o src/frame-ot.o src/gfx.o src/texture.o src/input.o src/console.o src/osd.o src/spawn.o src/tool.o src/command.o src/fps.o src/color.o src/config.o src/timer.o src/lua.o src/png_save.o src/gravitrc.o
# -------------------------------
#generic optimization - OK for any newer proceser with SSE support
# -mstackrealign is needed for Windows XP - otherwise gravit crashes
GenericOpt= -msse -mfpmath=sse \
-fomit-frame-pointer -momit-leaf-frame-pointer \
-floop-optimize -funsafe-loop-optimizations -Wunsafe-loop-optimizations \
-malign-stringops \
-falign-functions=6 \
-falign-loops=6 \
-falign-jumps=6 \
-mpreferred-stack-boundary=6 \
-minline-stringops-dynamically \
-mstackrealign
GenericOpt64= -msse \
-fomit-frame-pointer -momit-leaf-frame-pointer \
-floop-optimize -funsafe-loop-optimizations -Wunsafe-loop-optimizations \
-malign-stringops \
-minline-stringops-dynamically \
-mstackrealign
#optimize for Core2
P4C2opt=-mtune=core2 -march=core2 \
-msse -msse2 -msse3 -mssse3 -mfpmath=sse \
-fomit-frame-pointer -momit-leaf-frame-pointer \
-floop-optimize -funsafe-loop-optimizations -Wunsafe-loop-optimizations \
-malign-stringops \
-falign-functions=6 \
-falign-loops=6 \
-falign-jumps=6 \
-mpreferred-stack-boundary=6 \
-minline-stringops-dynamically \
-mstackrealign
#optimize for Corei3/5/7
X64opt= -mtune=corei7 -march=corei7 \
-msse4 -msahf -mcx16 \
-msse -msse2 -msse3 -mssse3 -mfpmath=sse \
-fomit-frame-pointer -momit-leaf-frame-pointer \
-floop-optimize -funsafe-loop-optimizations -Wunsafe-loop-optimizations
# -mpreferred-stack-boundary=6 \
# -falign-functions=6 \
# -falign-loops=6 \
# -falign-jumps=6 \
# -mstackrealign
# -------------------------------
INCDIRS = -I./MinGW/include$(ARCH) -I./MinGW/include$(ARCH)/SDL -I./MinGW/include -I./MinGW/include/SDL -I/usr/local/include -I/usr/local/include/SDL
LIBDIRS = -L./MinGW/lib$(ARCH) -L./MinGW/lib -L/usr/local/lib
CFLAGS = -DWITH_LUA -DHAVE_LUA -DHAVE_SSE -DHAVE_PNG -DUSE_PTHREAD \
$(INCDIRS) \
-D_GNU_SOURCE=1 -Dmain=SDL_main \
-O4 -ffast-math \
-mwindows -DWIN32
# for extra security on Windows, enable ASLR and DEP via GCC linker flags
LDFLAGS = -Wl,--dynamicbase -Wl,--nxcompat \
$(LIBDIRS)
LDLIBS = -lag_gui -lag_core \
-lSDL_ttf -lSDL_image -lfreetype -llua52 \
-lGLU32 -lopenGL32 \
-lmingw32 -lSDLmain -lSDL -lpng -mwindows -lscrnsave -lwinmm -ldxguid \
-lpthread
INSTALL=cp -av
# mingw gcc 4.4.5 has openMP support.
ifeq ($(ARCH),64)
CC=gcc -fopenmp $(GenericOpt64)
LD=gcc -fopenmp $(GenericOpt64)
else
CC=gcc -fopenmp $(GenericOpt)
LD=gcc -fopenmp $(GenericOpt)
endif
# if you have gcc >= 4.6.0
#CC=gcc -flto=2 -Ofast $(P4C2opt)
#LD=gcc -flto=2 -Ofast $(P4C2opt) $(CFLAGS)
#CC=gcc -fopenmp -Ofast $(X64opt)
#LD=gcc -fopenmp -Ofast $(X64opt)
#for gcc < 4.6.0
#CC=gcc -fopenmp $(P4C2opt)
#LD=gcc -fopenmp $(P4C2opt)
# -------------------------------
all: final
# a little shell magic to find out where gcc.exe lives
# (needed later to find libgomp and (p)thread dll's)
GCCPATH:=$(shell dirname `which gcc.exe`)
# prepare for creating setup program
install: final
@echo ""
@mkdir -p $(DESTDIR)
@mkdir -p $(NOARCH)
@mkdir -p $(NOARCH)/cfg
@rm -rf $(NOARCH)/spawn
@rm -rf $(NOARCH)/data
@echo ""
@$(INSTALL) $(FINAL) $(DESTDIR)
@$(INSTALL) ./COPYING $(NOARCH)/COPYING
@$(INSTALL) ./README $(NOARCH)/README.txt
@$(INSTALL) ./cfg/*.cfg $(NOARCH)/cfg
@-$(INSTALL) ./demo.cfg $(NOARCH)/cfg
@$(INSTALL) ./data/gravit.ico $(NOARCH)/gravit.ico
@$(INSTALL) ./data $(NOARCH)
@$(INSTALL) ./spawn $(NOARCH)
@touch $(NOARCH)/stdout.txt $(NOARCH)/stderr.txt
@echo ""
@-$(INSTALL) $(GCCPATH)/../lib/libgomp*.dll $(DESTDIR)
@-$(INSTALL) $(GCCPATH)/../*/lib/libgomp*.dll $(DESTDIR)
@-$(INSTALL) $(GCCPATH)/libgomp*.dll $(DESTDIR)
@-$(INSTALL) $(GCCPATH)/*thread*.dll $(DESTDIR)
@-$(INSTALL) $(GCCPATH)/libgcc*.dll $(DESTDIR)
@$(INSTALL) ./MinGW/lib$(ARCH)/*.dll $(DESTDIR)
@echo ""
@echo "installation files copied into " $(DESTDIR) "and " $(NOARCH)
@echo "you may now run InnoSetup to create setup-gravit-0.5.1-"$(ARCH)"bit".exe
@echo ""
dep:
@makedepend $(CFLAGS) *.c 2> /dev/null
final: $(OBJS)
@echo building $(FINAL) ' ('$(ARCH)bit')'
$(LD) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(FINAL)
clean:
rm -f src/*.o $(FINAL)
src/gravitrc.o: src/gravit.rc
windres src/gravit.rc src/gravitrc.o
src/%.o: src/%.c src/gravit.h
@echo $<
@$(CC) -c $(CFLAGS) $(subst ,, src/$*.c) -o src/$*.o
# -------------------------------