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