accfd1479c46a3a389d5b3f25efc9d43a2d88c1f
[mesa.git] / src / mesa / 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.3 for Mesa
24 #
25 # Copyright (C) 2002 - Borca Daniel
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 # X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
44 # default = no
45 #
46 # Targets:
47 # all: build GL
48 # clean: remove object files
49 #
50
51
52
53 .PHONY: all clean
54 .INTERMEDIATE: x86/gen_matypes.exe
55 .SUFFIXES: .rc .res
56
57 TOP = ../..
58 GLIDE ?= $(TOP)/glide3
59 LIBDIR = $(TOP)/lib
60 GL_DLL = opengl32.dll
61 GL_IMP = libopengl32.a
62
63 LDLIBS = -lgdi32
64
65 CC = mingw32-gcc
66 CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_MSC_VER
67 CFLAGS += $(INCLUDE_DIRS)
68 ifeq ($(FX),1)
69 CFLAGS += -I$(GLIDE)/include -DFX
70 LDLIBS += -L$(GLIDE)/lib -lglide3x
71 GL_DEF = drivers/glide/fxopengl.def
72 GL_RES = drivers/glide/fx.rc
73 else
74 GL_DEF = drivers/windows/gdi/mesa.def
75 endif
76
77 AR = ar
78 ARFLAGS = rus
79
80 ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
81 UNLINK = del $(subst /,\,$(1))
82 else
83 UNLINK = $(RM) $(1)
84 endif
85
86 include sources
87
88 ifeq ($(X86),1)
89 CFLAGS += -DUSE_X86_ASM
90 CFLAGS += -DUSE_MMX_ASM
91 CFLAGS += -DUSE_SSE_ASM
92 CFLAGS += -DUSE_3DNOW_ASM
93 X86_SOURCES += $(X86_API)
94 else
95 X86_SOURCES =
96 endif
97
98 ifeq ($(FX),1)
99 DRIVER_SOURCES = \
100 $(GLIDE_DRIVER_SOURCES) \
101 drivers/glide/fxwgl.c
102 else
103 DRIVER_SOURCES = \
104 drivers/windows/gdi/wmesa.c \
105 drivers/windows/gdi/wgl.c
106 endif
107
108 SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
109
110 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
111
112 X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
113
114 RESOURCE = $(GL_RES:.rc=.res)
115
116 .c.o:
117 $(CC) -o $@ $(CFLAGS) -c $<
118 .S.o:
119 $(CC) -o $@ $(CFLAGS) -c $<
120 .s.o:
121 $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
122 .rc.res:
123 windres -o $@ -Irc -Ocoff $<
124
125 all: $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP)
126
127 $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE)
128 dllwrap -o $(LIBDIR)/$(GL_DLL) --output-lib $(LIBDIR)/$(GL_IMP) --target i386-mingw32 --def $(GL_DEF) $^ $(LDLIBS)
129
130 $(X86_OBJECTS): x86/matypes.h
131
132 x86/matypes.h: x86/gen_matypes.exe
133 $(subst /,\,$< > $@)
134
135 x86/gen_matypes.exe: x86/gen_matypes.c
136 $(CC) -o $@ $(CFLAGS) -s $<
137
138 # [dBorca]
139 # glapi_x86.S needs some adjustments
140 # in order to generate correct entrypoints
141 x86/glapi_x86.o: x86/glapi_x86.S
142 $(CC) -o $@ $(CFLAGS) -U__WIN32__ -DSTDCALL_API -c $<
143 #main/dispatch.o: main/dispatch.c
144 # $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
145
146 # [dBorca]
147 # if we want codegen, we have to stdcall
148 tnl/t_vtx_x86_gcc.o: tnl/t_vtx_x86_gcc.S
149 $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
150
151 clean:
152 -$(call UNLINK,array_cache/*.o)
153 -$(call UNLINK,glapi/*.o)
154 -$(call UNLINK,main/*.o)
155 -$(call UNLINK,math/*.o)
156 -$(call UNLINK,shader/*.o)
157 -$(call UNLINK,sparc/*.o)
158 -$(call UNLINK,swrast/*.o)
159 -$(call UNLINK,swrast_setup/*.o)
160 -$(call UNLINK,tnl/*.o)
161 -$(call UNLINK,x86/*.o)
162 -$(call UNLINK,drivers/common/*.o)
163 -$(call UNLINK,drivers/windows/gdi/*.o)
164 -$(call UNLINK,drivers/glide/*.o)
165 -$(call UNLINK,drivers/glide/*.res)