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