Merged mga branch with trunk
[platform/upstream/libdrm.git] / linux / Makefile.linux
1 # Makefile -- For the Direct Rendering Manager module (drm)
2 # Created: Mon Jan  4 09:26:53 1999 by faith@precisioninsight.com
3 # Revised: Sun Feb 13 23:15:59 2000 by kevin@precisioninsight.com
4 #
5 # Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6 # All rights reserved.
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining a
9 # copy of this software and associated documentation files (the "Software"),
10 # to deal in the Software without restriction, including without limitation
11 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 # and/or sell copies of the Software, and to permit persons to whom the
13 # Software is furnished to do so, subject to the following conditions:
14
15 # The above copyright notice and this permission notice (including the next
16 # paragraph) shall be included in all copies or substantial portions of the
17 # Software.
18
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22 # PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 # DEALINGS IN THE SOFTWARE.
26
27 # $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.6 2000/02/23 04:47:25 martin Exp $
28
29
30 .SUFFIXES:
31
32 # *** Setup
33
34 # **** End of SMP/MODVERSIONS detection
35
36 MODS=           gamma.o tdfx.o
37 LIBS=           libdrm.a
38 PROGS=          drmstat
39
40 DRMOBJS=        init.o memory.o proc.o auth.o context.o drawable.o bufs.o \
41                 lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o
42 DRMHEADERS=     drm.h drmP.h
43
44 GAMMAOBJS=      gamma_drv.o gamma_dma.o
45 GAMMAHEADERS=   gamma_drv.h $(DRMHEADERS)
46
47 TDFXOBJS=       tdfx_drv.o tdfx_context.o
48 TDFXHEADERS=    tdfx_drv.h $(DRMHEADERS)
49
50 PROGOBJS=       drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po
51 PROGHEADERS=    xf86drm.h $(DRMHEADERS)
52
53 INC=            /usr/include
54
55 CFLAGS=         -O2 $(WARNINGS)
56 WARNINGS=       -Wall -Wwrite-strings -Wpointer-arith -Wcast-align \
57                 -Wstrict-prototypes -Wshadow -Wnested-externs \
58                 -Winline -Wpointer-arith
59 MODCFLAGS=      $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer
60 PRGCFLAGS=      $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
61                 -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
62                 -I../../../../../../include -I../../../../../../../../include \
63                 -I../../../../../../../../programs/Xserver/hw/xfree86/common
64 PRGLIBS=
65
66 # **** Start of SMP/MODVERSIONS detection
67
68 # First, locate correct tree for this kernel version.  If we find a
69 # matching tree, we assume that we can rely on that tree's autoconf.h.
70 # This may not be correct, but it is the best assumption we can make.
71
72 VERSION := $(shell uname -r)
73 A := /usr/src/linux-$(VERSION)/include
74 B := /usr/src/linux/include
75 C := /usr/include
76
77 V := $(shell gcc -E -nostdinc -I$A picker.c 2>/dev/null \
78       | grep -s 'RELEASE = ' | cut -d' ' -f3)
79 ifeq ($(V),"$(VERSION)")
80 TREE := $A
81 else
82   V := $(shell gcc -E -nostdinc -I$B picker.c 2>/dev/null \
83         | grep -s 'RELEASE = ' | cut -d' ' -f3)
84 ifeq ($(V),"$(VERSION)")
85   TREE := $B
86 else
87     V := $(shell gcc -E -nostdinc -I$C picker.c 2>/dev/null \
88           | grep -s 'RELEASE = ' | cut -d' ' -f3)
89 ifeq ($(V),"$(VERSION)")
90     TREE := $C
91 else
92     TREE := 0
93 endif
94 endif
95 endif
96
97 # To override this determination, pass the path on the make command line:
98 #       make TREE=/usr/my-kernel-tree/include
99 # or hardcode a value for TREE here:
100 # TREE:=/usr/include
101
102 ifeq ($(TREE),0)
103 all:; @echo Error: Could not locate kernel tree in $A $B $C
104 else
105 SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
106         | grep -s 'SMP = ' | cut -d' ' -f3)
107 MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \
108         | grep -s 'MODVERSIONS = ' | cut -d' ' -f3)
109 AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
110         | grep -s 'AGP = ' | cut -d' ' -f3)
111 ifeq ($(AGP),0)
112 AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
113         | grep -s 'AGP_MODULE = ' | cut -d' ' -f3)
114 endif
115
116 ifeq ($(AGP),1)
117 MODCFLAGS += -DDRM_AGP
118 DRMOBJS += agpsupport.o
119 MODS += mga.o i810.o
120
121 MGAOBJS=        mga_drv.o mga_dma.o mga_bufs.o mga_state.o mga_context.o
122 MGAHEADERS=     mga_drv.h $(DRMHEADERS)
123
124 I810OBJS=       i810_drv.o i810_dma.o i810_bufs.o i810_context.o
125 I810HEADERS=    i810_drv.h $(DRMHEADERS)
126 endif
127
128 all::;@echo KERNEL HEADERS IN $(TREE): SMP=${SMP} MODVERSIONS=${MODVERSIONS} \
129         AGP=${AGP}
130 all:: $(LIBS) $(MODS) $(PROGS)
131 endif
132
133 # **** End of SMP/MODVERSIONS detection
134
135 # **** Handle SMP/MODVERSIONS
136 ifeq ($(SMP),1)
137 MODCFLAGS += -D__SMP__
138 endif
139 ifeq ($(MODVERSIONS),1)
140 MODCFLAGS += -DMODVERSIONS -include $(TREE)/linux/modversions.h
141 endif
142
143
144 # **** End of configuration
145
146 libdrm.a: $(DRMOBJS)
147         -$(RM) -f $@
148         $(AR) rcs $@ $(DRMOBJS)
149
150 gamma.o: $(GAMMAOBJS) $(LIBS)
151         $(LD) -r $^ -o $@
152
153 tdfx.o: $(TDFXOBJS) $(LIBS)
154         $(LD) -r $^ -o $@
155
156 ifeq ($(AGP),1)
157 mga.o: $(MGAOBJS) $(LIBS)
158         $(LD) -r $^ -o $@
159
160 i810.o: $(I810OBJS) $(LIBS)
161         $(LD) -r $^ -o $@
162 endif
163
164 drmstat: $(PROGOBJS)
165         $(CC) $(PRGCFLAGS) $^ $(PRGLIBS) -o $@
166
167 .PHONY: ChangeLog
168 ChangeLog:
169         @rm -f Changelog
170         @rcs2log -i 2 -r -l \
171                 | sed 's,@.*alephnull.com,@precisioninsight.com,' > ChangeLog
172
173
174 # .o files are used for modules
175 %.o: %.c
176         $(CC) $(MODCFLAGS) -c $< -o $@
177
178 %.po: %.c
179         $(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@
180
181
182 $(DRMOBJS): $(DRMHEADERS)
183 $(GAMMAOBJS): $(GAMMAHEADERS)
184 $(TDFXOBJS): $(TDFXHEADERS)
185 ifeq ($(AGP),1)
186 $(MGAOBJS): $(MGAHEADERS)
187 $(I810OBJS): $(I810HEADERS)
188 endif
189 $(PROGOBJS): $(PROGHEADERS)
190
191 clean:
192         rm -f *.o *.a *.po *~ core $(PROGS)