move mesa32 over to new dir
[reactos.git] / reactos / lib / mesa32 / src / Makefile.mgw
1 # Mesa 3-D graphics library
2 # Version: 5.1
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
30 #
31 # Available options:
32 #
33 # Environment variables:
34 # CFLAGS
35 #
36 # GLIDE path to Glide3 SDK; used with FX.
37 # default = $(TOP)/glide3
38 # FX=1 build for 3dfx Glide3. Note that this disables
39 # compilation of most WMesa code and requires fxMesa.
40 # As a consequence, you'll need the Win32 Glide3
41 # library to build any application.
42 # default = no
43 # ICD=1 build the installable client driver interface
44 # (windows opengl driver interface)
45 # default = no
46 # X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
47 # default = no
48 #
49 # Targets:
50 # all: build GL
51 # clean: remove object files
52 #
53
54
55
56 .PHONY: all clean
57 .INTERMEDIATE: x86/gen_matypes.exe
58 .SUFFIXES: .rc .res
59
60 # Set this to the prefix of your build tools, i.e. mingw32-
61 TOOLS_PREFIX = mingw32-
62
63 TOP = ../..
64 GLIDE ?= $(TOP)/glide3
65 LIBDIR = $(TOP)/lib
66 ifeq ($(ICD),1)
67 GL_DLL = mesa32.dll
68 GL_IMP = libmesa32.a
69 else
70 GL_DLL = opengl32.dll
71 GL_IMP = libopengl32.a
72 endif
73
74 LDLIBS = -lgdi32
75
76 CC = $(TOOLS_PREFIX)gcc
77 CFLAGS += -DBUILD_GL32 -D_OPENGL32_
78 CFLAGS += $(INCLUDE_DIRS)
79 CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1
80 ifeq ($(FX),1)
81 CFLAGS += -I$(GLIDE)/include -DFX
82 LDLIBS += -L$(GLIDE)/lib -lglide3x
83 GL_DEF = drivers/windows/fx/fxopengl.def
84 GL_RES = drivers/windows/fx/fx.rc
85 else
86 ifeq ($(ICD),1)
87 CFLAGS += -DUSE_MGL_NAMESPACE
88 GL_DEF = drivers/windows/icd/mesa.def
89 else
90 GL_DEF = drivers/windows/gdi/mesa.def
91 endif
92 endif
93
94 AR = ar
95 ARFLAGS = crus
96
97 UNLINK = del $(subst /,\,$(1))
98 ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
99 UNLINK = $(RM) $(1)
100 endif
101 ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),)
102 UNLINK = $(RM) $(1)
103 endif
104
105 include sources
106
107 ifeq ($(X86),1)
108 CFLAGS += -DUSE_X86_ASM
109 CFLAGS += -DUSE_MMX_ASM
110 CFLAGS += -DUSE_SSE_ASM
111 CFLAGS += -DUSE_3DNOW_ASM
112 X86_SOURCES += $(X86_API)
113 else
114 X86_SOURCES =
115 endif
116
117 ifeq ($(FX),1)
118 DRIVER_SOURCES = \
119 $(GLIDE_DRIVER_SOURCES) \
120 drivers/windows/fx/fxwgl.c
121 else
122 ifeq ($(ICD),1)
123 DRIVER_SOURCES = \
124 drivers/windows/gdi/wmesa.c \
125 drivers/windows/icd/icd.c
126 else
127 DRIVER_SOURCES = \
128 drivers/windows/gdi/wmesa.c \
129 drivers/windows/gdi/wgl.c
130 endif
131 endif
132
133 SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
134
135 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
136
137 X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
138
139 RESOURCE = $(GL_RES:.rc=.res)
140
141 .c.o:
142 $(CC) -o $@ $(CFLAGS) -c $<
143 .S.o:
144 $(CC) -o $@ $(CFLAGS) -c $<
145 .s.o:
146 $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
147 .rc.res:
148 windres -o $@ -Irc -Ocoff $<
149
150 all: $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP)
151
152 $(LIBDIR):
153 mkdir -p $(LIBDIR)
154
155 $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE)
156 $(TOOLS_PREFIX)dllwrap -o $(LIBDIR)/$(GL_DLL) --output-lib $(LIBDIR)/$(GL_IMP) \
157 --target i386-mingw32 --def $(GL_DEF) -Wl,-enable-stdcall-fixup \
158 $^ $(LDLIBS)
159
160 $(X86_OBJECTS): x86/matypes.h
161
162 x86/matypes.h: x86/gen_matypes.exe
163 $(subst /,\,$< > $@)
164
165 x86/gen_matypes.exe: x86/gen_matypes.c
166 $(CC) -o $@ $(CFLAGS) -s $<
167
168 # [dBorca]
169 # glapi_x86.S needs some adjustments
170 # in order to generate correct entrypoints
171 # Trick: change the following condition to
172 # be always false if you need C entrypoints
173 # with USE_X86_ASM (useful for trace/debug)
174 ifeq (1,1)
175 x86/glapi_x86.o: x86/glapi_x86.S
176 $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
177 else
178 main/dispatch.o: main/dispatch.c
179 $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
180 glapi/glapi.o: glapi/glapi.c
181 $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
182 endif
183
184 # [dBorca]
185 # if we want codegen, we have to stdcall
186 tnl/t_vtx_x86_gcc.o: tnl/t_vtx_x86_gcc.S
187 $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
188
189 clean:
190 -$(call UNLINK,array_cache/*.o)
191 -$(call UNLINK,glapi/*.o)
192 -$(call UNLINK,main/*.o)
193 -$(call UNLINK,math/*.o)
194 -$(call UNLINK,shader/*.o)
195 -$(call UNLINK,sparc/*.o)
196 -$(call UNLINK,ppc/*.o)
197 -$(call UNLINK,swrast/*.o)
198 -$(call UNLINK,swrast_setup/*.o)
199 -$(call UNLINK,tnl/*.o)
200 -$(call UNLINK,x86/*.o)
201 -$(call UNLINK,drivers/common/*.o)
202 -$(call UNLINK,drivers/glide/*.o)
203 -$(call UNLINK,drivers/windows/fx/*.o)
204 -$(call UNLINK,drivers/windows/fx/*.res)
205 -$(call UNLINK,drivers/windows/gdi/*.o)
206 -$(call UNLINK,drivers/windows/icd/*.o)