Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / Makefile
1 # src/mesa/Makefile
2
3 TOP = ../..
4 include $(TOP)/configs/current
5
6 include sources.mak
7
8 .SUFFIXES : .cpp
9
10 .c.o:
11 $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
12
13 .cpp.o:
14 $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@
15
16 .S.o:
17 $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
18
19
20
21 # Default: build dependencies, then asm_subdirs, then convenience
22 # libs (.a) and finally the device drivers:
23 default: depend asm_subdirs libmesa.a libglapi.a driver_subdirs
24
25
26 # Default: build dependencies, then asm_subdirs, then convenience
27 # libs (.a) and finally the device drivers:
28 default: depend asm_subdirs libmesa.a $(GLAPI_LIB) driver_subdirs
29
30 ######################################################################
31 # Helper libraries used by many drivers:
32
33 # Make archive of core mesa object files
34 libmesa.a: $(MESA_OBJECTS)
35 @ $(MKLIB) -o mesa -static $(MESA_OBJECTS)
36
37 # Make archive of gl* API dispatcher functions only
38 libglapi.a: $(GLAPI_OBJECTS)
39 @ $(MKLIB) -o glapi -static $(GLAPI_OBJECTS)
40
41 # Make archive of gl* API dispatcher functions only
42 $(GLAPI_LIB): $(GLAPI_OBJECTS)
43 @if [ "${WINDOW_SYSTEM}" = "dri" ] ; then \
44 touch libglapi.a ; \
45 else \
46 $(TOP)/bin/mklib -o glapi -static $(GLAPI_OBJECTS) ; \
47 fi
48
49 ######################################################################
50 # Device drivers
51 driver_subdirs: libmesa.a libglapi.a
52 (cd drivers && $(MAKE))
53
54
55 ######################################################################
56 # Assembly subdirs
57 asm_subdirs:
58 @ if echo "$(ASM_FLAGS)" | grep -q USE_X86_ASM ; then \
59 (cd x86 && $(MAKE)) || exit 1 ; \
60 fi
61 @ if echo "$(ASM_FLAGS)" | grep -q USE_X86_64_ASM ; then \
62 (cd x86 && $(MAKE)) || exit 1 ; \
63 (cd x86-64 && $(MAKE)) || exit 1 ; \
64 fi
65
66
67 ######################################################################
68 # Dependency generation
69
70 depend: $(ALL_SOURCES)
71 @ echo "running $(MKDEP)"
72 @ touch depend
73 @$(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \
74 > /dev/null 2>/dev/null
75
76
77 ######################################################################
78 # Installation rules
79
80 # this isn't fleshed out yet but is probably the way to go in the future
81 new_install:
82 (cd drivers && $(MAKE) install)
83
84
85 # XXX replace this with new_install above someday
86 install: default
87 @for driver in $(DRIVER_DIRS) ; do \
88 case "$$driver" in \
89 osmesa) if [ "$(DRIVER_DIRS)" = osmesa ]; then \
90 $(MAKE) install-headers install-osmesa || exit 1 ; \
91 else \
92 $(MAKE) install-osmesa || exit 1 ; \
93 fi ;; \
94 dri) $(MAKE) install-libgl install-dri || exit 1 ;; \
95 *) $(MAKE) install-libgl || exit 1 ;; \
96 esac ; \
97 done
98
99
100 gl_pcedit = sed \
101 -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
102 -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
103 -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
104 -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
105 -e 's,@GL_PC_REQ_PRIV@,$(GL_PC_REQ_PRIV),' \
106 -e 's,@GL_PC_LIB_PRIV@,$(GL_PC_LIB_PRIV),' \
107 -e 's,@GL_PC_CFLAGS@,$(GL_PC_CFLAGS),'
108
109 gl.pc: gl.pc.in
110 $(gl_pcedit) $< > $@
111
112 osmesa_pcedit = sed \
113 -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
114 -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
115 -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
116 -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
117 -e 's,@OSMESA_LIB@,$(OSMESA_LIB),' \
118 -e 's,@OSMESA_PC_REQ@,$(OSMESA_PC_REQ),' \
119 -e 's,@OSMESA_PC_LIB_PRIV@,$(OSMESA_PC_LIB_PRIV),'
120
121 osmesa.pc: osmesa.pc.in
122 $(osmesa_pcedit) $< > $@
123
124 install-headers:
125 $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
126 $(INSTALL) -m 644 $(TOP)/include/GL/*.h \
127 $(DESTDIR)$(INSTALL_INC_DIR)/GL
128
129 install-libgl: default gl.pc install-headers
130 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
131 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
132 $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \
133 $(DESTDIR)$(INSTALL_LIB_DIR)
134 $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
135
136 install-osmesa: default osmesa.pc
137 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
138 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
139 $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
140 $(DESTDIR)$(INSTALL_LIB_DIR)
141 $(INSTALL) -m 644 osmesa.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
142
143 install-dri: default
144 cd drivers/dri && $(MAKE) install
145
146
147
148 # Emacs tags
149 tags:
150 etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
151
152
153 clean:
154 -rm -f */*.o
155 -rm -f */*/*.o
156 -rm -f depend depend.bak libmesa.a libglapi.a
157 -rm -f drivers/*/*.o
158 -rm -f *.pc
159 -@cd drivers/dri && $(MAKE) clean
160 -@cd drivers/x11 && $(MAKE) clean
161 -@cd drivers/osmesa && $(MAKE) clean
162 -@cd x86 && $(MAKE) clean
163 -@cd x86-64 && $(MAKE) clean
164
165
166 -include depend