4 include $(TOP)/configs/current
6 MESA_LIBS := libmesa.a libmesagallium.a
12 # define preprocessor flags
13 MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES)
16 MESA_CPPFLAGS += $(INCLUDE_DIRS)
19 CFLAGS := $(filter-out $(DEFINES), $(CFLAGS))
20 CXXFLAGS := $(filter-out $(DEFINES), $(CXXFLAGS))
22 # LLVM is needed for the state tracker
23 MESA_CFLAGS := $(LLVM_CFLAGS) $(CFLAGS)
24 MESA_CXXFLAGS := $(LLVM_CFLAGS) $(CXXFLAGS)
27 $(CC) -c -o $@ $< $(MESA_CPPFLAGS) $(MESA_CFLAGS)
30 $(CXX) -c -o $@ $< $(MESA_CPPFLAGS) $(MESA_CXXFLAGS)
33 $(CC) -c -o $@ $< $(MESA_CPPFLAGS) $(MESA_CFLAGS)
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
39 .PHONY: 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 ; \
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 ;\
56 # include glapi_gen.mk for generating glapi headers for GLES
57 GLAPI := $(TOP)/src/mapi/glapi/gen
58 include $(GLAPI)/glapi_gen.mk
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 \
67 program/program_parse.tab.c \
68 program/program_parse.tab.h \
71 main/api_exec_es1_dispatch.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_dispatch_deps)
72 $(call glapi_gen_dispatch,$<,es1)
74 main/api_exec_es1_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_deps)
75 $(call glapi_gen_remap,$<,es1)
77 main/api_exec_es1.o: main/api_exec_es1_dispatch.h main/api_exec_es1_remap_helper.h
79 main/api_exec_es2_dispatch.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_dispatch_deps)
80 $(call glapi_gen_dispatch,$<,es2)
82 main/api_exec_es2_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_deps)
83 $(call glapi_gen_remap,$<,es2)
85 main/api_exec_es2.o: main/api_exec_es2_dispatch.h main/api_exec_es2_remap_helper.h
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 > $@
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 > $@
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 $<
96 program/lex.yy.c: program/program_lexer.l
97 $(FLEX) --never-interactive --outfile=$@ $<
99 ifneq (,$(DRICORE_LIBS))
100 DRICORE_TARGET = dricore
101 DRICORE_INSTALL_TARGET = install-dricore
104 ######################################################################
105 # Helper libraries used by many drivers:
107 # Make archive of core mesa object files
108 libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS)
109 @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS)
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)
115 dricore: $(BUILT_SOURCES)
116 @ (cd libdricore && $(MAKE))
118 ######################################################################
120 driver_subdirs: $(MESA_LIBS) $(DRICORE_TARGET)
121 @ (cd drivers && $(MAKE))
124 ######################################################################
127 @ if echo "$(DEFINES)" | grep -q USE_X86_ASM ; then \
128 (cd x86 && $(MAKE)) || exit 1 ; \
130 @ if echo "$(DEFINES)" | grep -q USE_X86_64_ASM ; then \
131 (cd x86-64 && $(MAKE)) || exit 1 ; \
134 ######################################################################
135 # Dependency generation
137 depend: $(ALL_FILES) main/git_sha1.h
138 @ echo "running $(MKDEP)"
140 @$(MKDEP) $(MKDEP_OPTIONS) $(MESA_CPPFLAGS) \
141 $(ALL_FILES) > /dev/null 2>/dev/null
143 ######################################################################
146 # this isn't fleshed out yet but is probably the way to go in the future
148 (cd drivers && $(MAKE) install)
150 # XXX replace this with new_install above someday
151 install: default $(DRICORE_INSTALL_TARGET)
152 @for driver in $(DRIVER_DIRS) ; do \
154 osmesa) if [ "$(DRIVER_DIRS)" = osmesa ]; then \
155 $(MAKE) -f Makefile.old install-headers install-osmesa || exit 1 ; \
157 $(MAKE) -f Makefile.old install-osmesa || exit 1 ; \
159 dri) $(MAKE) -f Makefile.old install-libgl-pc install-dri || exit 1 ;; \
160 *) $(MAKE) -f Makefile.old install-libgl-pc || exit 1 ;; \
165 $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
166 $(INSTALL) -m 644 $(TOP)/include/GL/*.h \
167 $(DESTDIR)$(INSTALL_INC_DIR)/GL
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
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
182 cd drivers/dri && $(MAKE) install
184 install-dricore: default
185 @ (cd libdricore && $(MAKE) install)
189 etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
194 -rm -f depend depend.bak libmesa.a libmesagallium.a
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