cf75baa706d6c0bb490865ebda96038d911426f5
[mesa.git] / src / mesa / Makefile
1 # src/mesa/Makefile
2
3 TOP = ../..
4 include $(TOP)/configs/current
5
6 include sources
7
8
9 .SUFFIXES : .cpp
10
11 .c.o:
12 $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
13
14 .cpp.o:
15 $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@
16
17 .S.o:
18 $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
19
20
21
22 GLAPI_LIB = libglapi.a
23
24
25 # Default: build dependencies, then asm_subdirs, then convenience
26 # libs (.a) and finally the device drivers:
27 default: depend asm_subdirs libmesa.a $(GLAPI_LIB) driver_subdirs
28
29
30
31 ######################################################################
32 # Helper libraries used by many drivers:
33
34 # Make archive of core mesa object files
35 libmesa.a: $(MESA_OBJECTS)
36 @ $(TOP)/bin/mklib -o mesa -static $(MESA_OBJECTS)
37
38 # Make archive of gl* API dispatcher functions only
39 $(GLAPI_LIB): $(GLAPI_OBJECTS)
40 @if [ "${WINDOW_SYSTEM}" = "dri" ] ; then \
41 touch libglapi.a ; \
42 else \
43 $(TOP)/bin/mklib -o glapi -static $(GLAPI_OBJECTS) ; \
44 fi
45
46
47 ######################################################################
48 # Device drivers
49 driver_subdirs: libmesa.a $(GLAPI_LIB)
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 pcedit = sed \
99 -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
100 -e 's,@LIB_DIR@,$(LIB_DIR),' \
101 -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
102
103 gl.pc: gl.pc.in
104 $(pcedit) $< > $@
105
106 install-headers:
107 $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
108 $(INSTALL) -m 644 $(TOP)/include/GL/*.h \
109 $(DESTDIR)$(INSTALL_DIR)/include/GL
110
111 install-libgl: default gl.pc install-headers
112 $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
113 $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
114 $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)* \
115 $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
116 $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
117
118 install-osmesa: default
119 $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
120 $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME)* \
121 $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
122
123 install-dri: default
124 cd drivers/dri && $(MAKE) install
125
126
127
128 # Emacs tags
129 tags:
130 etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
131
132
133 clean:
134 -rm -f */*.o
135 -rm -f */*/*.o
136 -rm -f depend depend.bak libmesa.a $(GLAPI_LIB)
137 -rm -f drivers/*/*.o
138 -@cd drivers/dri && $(MAKE) clean
139 -@cd drivers/xorg && $(MAKE) clean
140 -@cd drivers/x11 && $(MAKE) clean
141 -@cd drivers/osmesa && $(MAKE) clean
142 -@cd x86 && $(MAKE) clean
143 -@cd x86-64 && $(MAKE) clean
144
145
146 -include depend