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