automake: Convert osmesa.pc to be generated by configure.
[mesa.git] / src / mesa / Makefile
1 # src/mesa/Makefile
2
3 TOP = ../..
4 include $(TOP)/configs/current
5
6 MESA_LIBS := libmesa.a libmesagallium.a
7 DEPENDS := depend
8
9 SRCDIR = .
10 include sources.mak
11
12 # define preprocessor flags
13 MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES)
14
15 # append include dirs
16 MESA_CPPFLAGS += $(INCLUDE_DIRS)
17
18 # tidy compiler flags
19 CFLAGS := $(filter-out $(DEFINES), $(CFLAGS))
20 CXXFLAGS := $(filter-out $(DEFINES), $(CXXFLAGS))
21
22 # LLVM is needed for the state tracker
23 MESA_CFLAGS := $(LLVM_CFLAGS) $(CFLAGS)
24 MESA_CXXFLAGS := $(LLVM_CFLAGS) $(CXXFLAGS)
25
26 %.o: %.c
27 $(CC) -c -o $@ $< $(MESA_CPPFLAGS) $(MESA_CFLAGS)
28
29 %.o: %.cpp
30 $(CXX) -c -o $@ $< $(MESA_CPPFLAGS) $(MESA_CXXFLAGS)
31
32 %.o: %.S
33 $(CC) -c -o $@ $< $(MESA_CPPFLAGS) $(MESA_CFLAGS)
34
35 # Default: build dependencies, then asm_subdirs, GLSL built-in lib,
36 # then convenience libs (.a) and finally the device drivers:
37 default: $(DEPENDS) asm_subdirs $(MESA_LIBS) driver_subdirs
38
39 .PHONY: main/git_sha1.h.tmp
40 main/git_sha1.h.tmp:
41 @touch main/git_sha1.h.tmp
42 @if test -d ../../.git; then \
43 if which git > /dev/null; then \
44 git log -n 1 --oneline | \
45 sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
46 > main/git_sha1.h.tmp ; \
47 fi \
48 fi
49
50 main/git_sha1.h: main/git_sha1.h.tmp
51 @echo "updating main/git_sha1.h"
52 @if ! cmp -s main/git_sha1.h.tmp main/git_sha1.h; then \
53 mv main/git_sha1.h.tmp main/git_sha1.h ;\
54 fi
55
56 # include glapi_gen.mk for generating glapi headers for GLES
57 GLAPI := $(TOP)/src/mapi/glapi/gen
58 include $(GLAPI)/glapi_gen.mk
59
60 BUILT_SOURCES = \
61 main/api_exec_es1_dispatch.h \
62 main/api_exec_es1_remap_helper.h \
63 main/api_exec_es2_dispatch.h \
64 main/api_exec_es2_remap_helper.h \
65 main/api_exec_es1.c \
66 main/api_exec_es2.c \
67 program/program_parse.tab.c \
68 program/program_parse.tab.h \
69 program/lex.yy.c
70
71 main/api_exec_es1_dispatch.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_dispatch_deps)
72 $(call glapi_gen_dispatch,$<,es1)
73
74 main/api_exec_es1_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_deps)
75 $(call glapi_gen_remap,$<,es1)
76
77 main/api_exec_es1.o: main/api_exec_es1_dispatch.h main/api_exec_es1_remap_helper.h
78
79 main/api_exec_es2_dispatch.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_dispatch_deps)
80 $(call glapi_gen_dispatch,$<,es2)
81
82 main/api_exec_es2_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_deps)
83 $(call glapi_gen_remap,$<,es2)
84
85 main/api_exec_es2.o: main/api_exec_es2_dispatch.h main/api_exec_es2_remap_helper.h
86
87 main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
88 $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES1.1 > $@
89
90 main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
91 $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES2.0 > $@
92
93 program/program_parse.tab.c program/program_parse.tab.h: program/program_parse.y
94 $(BISON) -v -d --output=program/program_parse.tab.c $<
95
96 program/lex.yy.c: program/program_lexer.l
97 $(FLEX) --never-interactive --outfile=$@ $<
98
99 ifneq (,$(DRICORE_LIBS))
100 DRICORE_TARGET = dricore
101 DRICORE_INSTALL_TARGET = install-dricore
102 endif
103
104 ######################################################################
105 # Helper libraries used by many drivers:
106
107 # Make archive of core mesa object files
108 libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS)
109 @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS)
110
111 # Make archive of subset of core mesa object files for gallium
112 libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
113 @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
114
115 dricore: $(BUILT_SOURCES)
116 @ (cd libdricore && $(MAKE))
117
118 ######################################################################
119 # Device drivers
120 driver_subdirs: $(MESA_LIBS) $(DRICORE_TARGET)
121 @ (cd drivers && $(MAKE))
122
123
124 ######################################################################
125 # Assembly subdirs
126 asm_subdirs:
127 @ if echo "$(DEFINES)" | grep -q USE_X86_ASM ; then \
128 (cd x86 && $(MAKE)) || exit 1 ; \
129 fi
130 @ if echo "$(DEFINES)" | grep -q USE_X86_64_ASM ; then \
131 (cd x86-64 && $(MAKE)) || exit 1 ; \
132 fi
133
134 ######################################################################
135 # Dependency generation
136
137 depend: $(ALL_FILES) main/git_sha1.h
138 @ echo "running $(MKDEP)"
139 @ touch depend
140 @$(MKDEP) $(MKDEP_OPTIONS) $(MESA_CPPFLAGS) \
141 $(ALL_FILES) > /dev/null 2>/dev/null
142
143 ######################################################################
144 # Installation rules
145
146 # this isn't fleshed out yet but is probably the way to go in the future
147 new_install:
148 (cd drivers && $(MAKE) install)
149
150 # XXX replace this with new_install above someday
151 install: default $(DRICORE_INSTALL_TARGET)
152 @for driver in $(DRIVER_DIRS) ; do \
153 case "$$driver" in \
154 osmesa) if [ "$(DRIVER_DIRS)" = osmesa ]; then \
155 $(MAKE) install-headers install-osmesa || exit 1 ; \
156 else \
157 $(MAKE) install-osmesa || exit 1 ; \
158 fi ;; \
159 dri) $(MAKE) install-libgl-pc install-dri || exit 1 ;; \
160 *) $(MAKE) install-libgl-pc || exit 1 ;; \
161 esac ; \
162 done
163
164 install-headers:
165 $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
166 $(INSTALL) -m 644 $(TOP)/include/GL/*.h \
167 $(DESTDIR)$(INSTALL_INC_DIR)/GL
168
169 install-libgl-pc: install-headers
170 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
171 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
172 $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
173
174 install-osmesa: default
175 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
176 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
177 $(MINSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
178 $(DESTDIR)$(INSTALL_LIB_DIR)
179 $(INSTALL) -m 644 osmesa.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
180
181 install-dri: default
182 cd drivers/dri && $(MAKE) install
183
184 install-dricore: default
185 @ (cd libdricore && $(MAKE) install)
186
187 # Emacs tags
188 tags:
189 etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
190
191 clean:
192 -rm -f */*.o
193 -rm -f */*/*.o
194 -rm -f depend depend.bak libmesa.a libmesagallium.a
195 -rm -f drivers/*/*.o
196 -rm -f $(BUILT_SOURCES)
197 -@cd drivers/dri && $(MAKE) clean
198 -@cd drivers/x11 && $(MAKE) clean
199 -@cd drivers/osmesa && $(MAKE) clean
200 -@cd x86 && $(MAKE) clean
201 -@cd x86-64 && $(MAKE) clean
202 -@cd libdricore && $(MAKE) clean
203
204
205 -include $(DEPENDS)