updated makefiles
[mesa.git] / src / mesa / Makefile.DJ
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 # DOS/DJGPP core makefile v1.5 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 DMesa code and requires fxMesa.
40 # As a consequence, you'll need the DJGPP Glide3
41 # library to build any application.
42 # default = no
43 # HAVE_X86=1 optimize for i386.
44 # default = no
45 # HAVE_MMX=1 allow MMX specializations, provided your assembler
46 # supports MMX instruction set. However, the true CPU
47 # capabilities are checked at run-time to avoid crashes.
48 # default = no
49 # HAVE_SSE=1 (see HAVE_MMX)
50 # default = no
51 # HAVE_3DNOW=1 (see HAVE_MMX)
52 # default = no
53 #
54 # Targets:
55 # all: build GL
56 # clean: remove object files
57 #
58
59
60
61 .PHONY: all clean
62 .INTERMEDIATE: x86/gen_matypes.exe
63
64 TOP = ../..
65 GLIDE ?= $(TOP)/glide3
66 LIBDIR = $(TOP)/lib
67 GL_LIB = libgl.a
68 GL_DXE = gl.dxe
69 GL_IMP = libigl.a
70
71 export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR);$(GLIDE)/lib
72
73 CC = gcc
74 CFLAGS += -I$(TOP)/include -I. -Imain -Iglapi
75 ifeq ($(FX),1)
76 CFLAGS += -D__DOS__ -DH3
77 CFLAGS += -I$(GLIDE)/include -DFX
78 LIBNAME = "Mesa/FX DJGPP"
79 else
80 LIBNAME = "Mesa DJGPP"
81 endif
82
83 AR = ar
84 ARFLAGS = rus
85
86 HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
87
88 ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
89 UNLINK = del $(subst /,\,$(1))
90 else
91 UNLINK = $(RM) $(1)
92 endif
93
94 include sources
95
96 X86_SOURCES = \
97 x86/x86.c \
98 x86/glapi_x86.S \
99 x86/common_x86.c \
100 x86/common_x86_asm.S \
101 x86/x86_xform2.S \
102 x86/x86_xform3.S \
103 x86/x86_xform4.S \
104 x86/x86_cliptest.S
105
106 MMX_SOURCES = \
107 x86/mmx_blend.S
108
109 SSE_SOURCES = \
110 x86/sse.c \
111 x86/sse_xform2.S \
112 x86/sse_xform3.S \
113 x86/sse_xform4.S \
114 x86/sse_normal.S
115
116 K3D_SOURCES = \
117 x86/3dnow.c \
118 x86/3dnow_xform2.S \
119 x86/3dnow_xform3.S \
120 x86/3dnow_xform4.S \
121 x86/3dnow_normal.S
122
123 CORE_SOURCES = \
124 $(MAIN_SOURCES) \
125 $(GLAPI_SOURCES) \
126 $(MATH_SOURCES) \
127 $(ARRAY_CACHE_SOURCES) \
128 $(TNL_SOURCES) \
129 $(SWRAST_SOURCES) \
130 $(SWRAST_SETUP_SOURCES)
131
132 ifeq ($(HAVE_MMX),1)
133 X86_SOURCES += $(MMX_SOURCES)
134 CFLAGS += -DUSE_MMX_ASM
135 HAVE_X86 = 1
136 endif
137 ifeq ($(HAVE_SSE),1)
138 X86_SOURCES += $(SSE_SOURCES)
139 CFLAGS += -DUSE_SSE_ASM
140 HAVE_X86 = 1
141 endif
142 ifeq ($(HAVE_3DNOW),1)
143 X86_SOURCES += $(K3D_SOURCES)
144 CFLAGS += -DUSE_3DNOW_ASM
145 HAVE_X86 = 1
146 endif
147 ifeq ($(HAVE_X86),1)
148 CFLAGS += -DUSE_X86_ASM
149 else
150 X86_SOURCES =
151 endif
152
153 DRIVER_SOURCES = \
154 drivers/dos/dmesa.c
155 ifeq ($(FX),1)
156 DRIVER_SOURCES += \
157 drivers/glide/fxapi.c \
158 drivers/glide/fxdd.c \
159 drivers/glide/fxddspan.c \
160 drivers/glide/fxddtex.c \
161 drivers/glide/fxsetup.c \
162 drivers/glide/fxtexman.c \
163 drivers/glide/fxtris.c \
164 drivers/glide/fxvb.c \
165 drivers/glide/fxglidew.c \
166 drivers/glide/fxg.c
167 else
168 DRIVER_SOURCES += \
169 drivers/dos/video.c \
170 drivers/dos/virtual.S \
171 drivers/dos/vesa.c \
172 drivers/dos/blit.S \
173 drivers/dos/vga.c \
174 drivers/dos/dpmi.c
175 endif
176
177 SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)
178
179 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
180
181 X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
182
183 .c.o:
184 $(CC) -o $@ $(CFLAGS) -c $<
185 .S.o:
186 $(CC) -o $@ $(CFLAGS) -c $<
187 .s.o:
188 $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
189
190 all: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP)
191
192 $(LIBDIR)/$(GL_LIB): $(OBJECTS)
193 $(AR) $(ARFLAGS) $@ $^
194
195 $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP): $(OBJECTS)
196 ifeq ($(HAVEDXE3),)
197 $(warning Missing DXE3 package... Skipping $(GL_DXE))
198 else
199 ifeq ($(FX),1)
200 -dxe3gen -o $(LIBDIR)/$(GL_DXE) -Y $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -P glide3x.dxe -U $^
201 else
202 -dxe3gen -o $(LIBDIR)/$(GL_DXE) -Y $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -U $^
203 endif
204 endif
205
206 $(X86_OBJECTS): x86/matypes.h
207
208 x86/matypes.h: x86/gen_matypes.exe
209 $< > $@
210
211 x86/gen_matypes.exe: x86/gen_matypes.c
212 $(CC) -o $@ $(CFLAGS) -s $<
213
214 clean:
215 -$(call UNLINK,array_cache/*.o)
216 -$(call UNLINK,glapi/*.o)
217 -$(call UNLINK,main/*.o)
218 -$(call UNLINK,math/*.o)
219 -$(call UNLINK,swrast/*.o)
220 -$(call UNLINK,swrast_setup/*.o)
221 -$(call UNLINK,tnl/*.o)
222 -$(call UNLINK,x86/*.o)
223 -$(call UNLINK,drivers/dos/*.o)
224 -$(call UNLINK,drivers/glide/*.o)