1 # Mesa 3-D graphics library
4 # Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
23 # MinGW core makefile v1.4 for Mesa
25 # Copyright (C) 2002 - Daniel Borca
26 # Email : dborca@users.sourceforge.net
27 # Web : http://www.geocities.com/dborca
29 # MinGW core-gl makefile updated for Mesa 7.0
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!
43 # Environment variables:
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.
53 # ICD=1 build the installable client driver interface
54 # (windows opengl driver interface)
56 # X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
61 # clean: remove object files
66 .INTERMEDIATE: x86/gen_matypes.exe
69 # Set this to the prefix of your build tools, i.e. mingw32-
70 TOOLS_PREFIX = mingw32-
75 GLIDE ?= $(TOP)/glide3
82 GL_IMP = libopengl32.a
87 include $(TOP)/configs/config.mgw
92 LDLIBS = -lgdi32 -luser32 -liberty
93 LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GL_IMP) -Wl,--output-def=$(LIBDIR)/gl.def
95 CC = $(TOOLS_PREFIX)gcc
96 CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_DLL -DMESA_MINWARN -DNDEBUG -D_USRDLL -DGDI_EXPORTS
98 ifeq ($(GL_USING_STDCALL),1)
99 LDFLAGS += -Wl,--add-stdcall-alias
101 CFLAGS += -DGL_NO_STDCALL
104 CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=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
112 CFLAGS += -DUSE_MGL_NAMESPACE
113 GL_DEF = drivers/windows/icd/mesa.def
115 GL_DEF = drivers/windows/gdi/mesa.def
122 UNLINK = del $(subst /,\,$(1))
123 ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
126 ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),)
132 CFLAGS += $(INCLUDE_DIRS)
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)
146 $(GLIDE_DRIVER_SOURCES) \
147 drivers/windows/fx/fxwgl.c
151 drivers/windows/gdi/wmesa.c \
152 drivers/windows/icd/icd.c
155 drivers/windows/gdi/wmesa.c \
156 drivers/windows/gdi/wgl.c
160 SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
162 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
164 X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
166 RESOURCE = $(GL_RES:.rc=.res)
169 $(CC) -o $@ $(CFLAGS) -c $<
171 $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
174 windres -o $@ -Irc -Ocoff $<
176 all: $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP)
181 $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE)
182 $(CC) -shared -fPIC -o $(LIBDIR)/$(GL_DLL) $(LDFLAGS) \
185 $(X86_OBJECTS): x86/matypes.h
187 x86/matypes.h: x86/gen_matypes.exe
190 x86/gen_matypes.exe: x86/gen_matypes.c
191 $(CC) -o $@ $(CFLAGS) -s $<
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)
200 x86/glapi_x86.o: x86/glapi_x86.S
201 $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
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 $<
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 $<
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)