Merge branch 'i915tex_privbuffers' into softpipe_0_1_branch
[mesa.git] / src / mesa / Makefile.mgw
1 # Mesa 3-D graphics library
2 # Version: 7.0
3 #
4 # Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 # and/or sell copies of the Software, and to permit persons to whom the
11 # Software is furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 # MinGW core makefile v1.4 for Mesa
24 #
25 # Copyright (C) 2002 - Daniel Borca
26 # Email : dborca@users.sourceforge.net
27 # Web : http://www.geocities.com/dborca
28
29 # MinGW core-gl makefile updated for Mesa 7.0
30 #
31 # updated : by Heromyth, on 2007-7-21
32 # Email : zxpmyth@yahoo.com.cn
33 # Bugs : 1) All the default settings work fine. But the setting X86=1 can't work.
34 # The others havn't been tested yet.
35 # 2) The generated DLLs are *not* compatible with the ones built
36 # with the other compilers like VC8, especially for GLUT.
37 # 3) Although more tests are needed, it can be used individually!
38
39
40 #
41 # Available options:
42 #
43 # Environment variables:
44 # CFLAGS
45 #
46 # GLIDE path to Glide3 SDK; used with FX.
47 # default = $(TOP)/glide3
48 # FX=1 build for 3dfx Glide3. Note that this disables
49 # compilation of most WMesa code and requires fxMesa.
50 # As a consequence, you'll need the Win32 Glide3
51 # library to build any application.
52 # default = no
53 # ICD=1 build the installable client driver interface
54 # (windows opengl driver interface)
55 # default = no
56 # X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
57 # default = no
58 #
59 # Targets:
60 # all: build GL
61 # clean: remove object files
62 #
63
64
65 .PHONY: all clean
66 .INTERMEDIATE: x86/gen_matypes.exe
67 .SUFFIXES: .rc .res
68
69 # Set this to the prefix of your build tools, i.e. mingw32-
70 TOOLS_PREFIX = mingw32-
71
72
73
74 TOP = ../..
75 GLIDE ?= $(TOP)/glide3
76 LIBDIR = $(TOP)/lib
77 ifeq ($(ICD),1)
78 GL_DLL = mesa32.dll
79 GL_IMP = libmesa32.a
80 else
81 GL_DLL = opengl32.dll
82 GL_IMP = libopengl32.a
83 endif
84
85 GL_DEF = gl.def
86
87 include $(TOP)/configs/config.mgw
88 GL_USING_STDCALL ?= 1
89
90 MESA_LIB = libmesa.a
91
92 LDLIBS = -lgdi32 -luser32 -liberty
93 LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GL_IMP) -Wl,--output-def=$(LIBDIR)/gl.def
94
95 CC = $(TOOLS_PREFIX)gcc
96 CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_DLL -DMESA_MINWARN -DNDEBUG -D_USRDLL -DGDI_EXPORTS
97
98 ifeq ($(GL_USING_STDCALL),1)
99 LDFLAGS += -Wl,--add-stdcall-alias
100 else
101 CFLAGS += -DGL_NO_STDCALL
102 endif
103
104 CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1
105 ifeq ($(FX),1)
106 CFLAGS += -I$(GLIDE)/include -DFX
107 LDLIBS += -L$(GLIDE)/lib -lglide3x
108 GL_DEF = drivers/windows/fx/fxopengl.def
109 GL_RES = drivers/windows/fx/fx.rc
110 else
111 ifeq ($(ICD),1)
112 CFLAGS += -DUSE_MGL_NAMESPACE
113 GL_DEF = drivers/windows/icd/mesa.def
114 else
115 GL_DEF = drivers/windows/gdi/mesa.def
116 endif
117 endif
118
119 AR = ar
120 ARFLAGS = crus
121
122 UNLINK = del $(subst /,\,$(1))
123 ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
124 UNLINK = $(RM) $(1)
125 endif
126 ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),)
127 UNLINK = $(RM) $(1)
128 endif
129
130 include sources
131
132 CFLAGS += $(INCLUDE_DIRS)
133
134 ifeq ($(X86),1)
135 CFLAGS += -DUSE_X86_ASM
136 CFLAGS += -DUSE_MMX_ASM
137 CFLAGS += -DUSE_SSE_ASM
138 CFLAGS += -DUSE_3DNOW_ASM
139 X86_SOURCES += $(X86_API)
140 else
141 X86_SOURCES =
142 endif
143
144 ifeq ($(FX),1)
145 DRIVER_SOURCES = \
146 $(GLIDE_DRIVER_SOURCES) \
147 drivers/windows/fx/fxwgl.c
148 else
149 ifeq ($(ICD),1)
150 DRIVER_SOURCES = \
151 drivers/windows/gdi/wmesa.c \
152 drivers/windows/icd/icd.c
153 else
154 DRIVER_SOURCES = \
155 drivers/windows/gdi/wmesa.c \
156 drivers/windows/gdi/wgl.c
157 endif
158 endif
159
160 SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
161
162 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
163
164 X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
165
166 RESOURCE = $(GL_RES:.rc=.res)
167
168 .c.o:
169 $(CC) -o $@ $(CFLAGS) -c $<
170 .s.o:
171 $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
172
173 .rc.res:
174 windres -o $@ -Irc -Ocoff $<
175
176 all: $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP)
177
178 $(LIBDIR):
179 mkdir -p $(LIBDIR)
180
181 $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE)
182 $(CC) -shared -fPIC -o $(LIBDIR)/$(GL_DLL) $(LDFLAGS) \
183 $^ $(LDLIBS)
184
185 $(X86_OBJECTS): x86/matypes.h
186
187 x86/matypes.h: x86/gen_matypes.exe
188 $(subst /,\,$< > $@)
189
190 x86/gen_matypes.exe: x86/gen_matypes.c
191 $(CC) -o $@ $(CFLAGS) -s $<
192
193 # [dBorca]
194 # glapi_x86.S needs some adjustments
195 # in order to generate correct entrypoints
196 # Trick: change the following condition to
197 # be always false if you need C entrypoints
198 # with USE_X86_ASM (useful for trace/debug)
199 ifeq (1,1)
200 x86/glapi_x86.o: x86/glapi_x86.S
201 $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
202 else
203 main/dispatch.o: main/dispatch.c
204 $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
205 glapi/glapi.o: glapi/glapi.c
206 $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
207 endif
208
209 # [dBorca]
210 # if we want codegen, we have to stdcall
211 tnl/t_vtx_x86_gcc.o: tnl/t_vtx_x86_gcc.S
212 $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
213
214 clean:
215 -$(call UNLINK,glapi/*.o)
216 -$(call UNLINK,main/*.o)
217 -$(call UNLINK,math/*.o)
218 -$(call UNLINK,vbo/*.o)
219 -$(call UNLINK,shader/*.o)
220 -$(call UNLINK,shader/slang/*.o)
221 -$(call UNLINK,shader/grammar/*.o)
222 -$(call UNLINK,sparc/*.o)
223 -$(call UNLINK,ppc/*.o)
224 -$(call UNLINK,swrast/*.o)
225 -$(call UNLINK,swrast_setup/*.o)
226 -$(call UNLINK,tnl/*.o)
227 -$(call UNLINK,x86/*.o)
228 -$(call UNLINK,x86/rtasm/*.o)
229 -$(call UNLINK,x86-64/*.o)
230 -$(call UNLINK,drivers/common/*.o)
231 -$(call UNLINK,drivers/glide/*.o)
232 -$(call UNLINK,drivers/windows/fx/*.o)
233 -$(call UNLINK,drivers/windows/fx/*.res)
234 -$(call UNLINK,drivers/windows/gdi/*.o)
235 -$(call UNLINK,drivers/windows/icd/*.o)