automake,android: Build program/ into a helper lib (v2)
authorEric Anholt <eric@anholt.net>
Thu, 8 Nov 2012 00:33:39 +0000 (16:33 -0800)
committerChad Versace <chad.versace@linux.intel.com>
Mon, 12 Nov 2012 23:52:42 +0000 (15:52 -0800)
While simplifying mesa/Makefile.am, the more important feature of this commit
is allowing a file with the same name to appear in both main/ and program/.

v2: [chadv] Add changes to Android makefiles.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Signed-off-by: Chad Versace <chad.versace@linux.intel.com> (v2)
configure.ac
src/mesa/Android.gen.mk
src/mesa/Android.libmesa_dricore.mk
src/mesa/Android.libmesa_st_mesa.mk
src/mesa/Android.mk
src/mesa/Makefile.am
src/mesa/libdricore/Makefile.am
src/mesa/program/.gitignore
src/mesa/program/Android.mk [new file with mode: 0644]
src/mesa/program/Makefile.am [new file with mode: 0644]
src/mesa/sources.mak

index 6a7521fa3e4e33ed5f0676958f806e221fac675f..558c4aa65b13a84df2a5273cd7f00f2ea988d293 100644 (file)
@@ -2013,6 +2013,7 @@ AC_CONFIG_FILES([configs/current
                src/mesa/drivers/x11/Makefile
                src/mesa/libdricore/Makefile
                src/mesa/main/tests/Makefile
+               src/mesa/program/Makefile
                src/mesa/x86-64/Makefile
                src/mesa/x86/Makefile])
 
index ce6d65bbde884743f9b19d071bd90ac579a50ee7..5f0d73cffd67077e2cf7a79488118585634d2ef0 100644 (file)
@@ -32,9 +32,6 @@ intermediates := $(call local-intermediates-dir)
 # This is the list of auto-generated files: sources and headers
 sources := \
        main/enums.c \
-       main/api_exec.c \
-       program/program_parse.tab.c \
-       program/lex.yy.c \
        main/dispatch.h \
        main/remap_helper.h \
        main/get_hash.h
@@ -62,30 +59,12 @@ dispatch_deps := \
        $(wildcard $(glapi)/*.py) \
        $(wildcard $(glapi)/*.xml)
 
-define local-l-to-c
-       @mkdir -p $(dir $@)
-       @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
-       $(hide) $(LEX) -o$@ $<
-endef
-
-define mesa_local-y-to-c-and-h
-       @mkdir -p $(dir $@)
-       @echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
-       $(hide) $(YACC) -o $@ -p "_mesa_program_" $<
-endef
-
 define es-gen
        @mkdir -p $(dir $@)
        @echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
        $(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
 endef
 
-$(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program/program_parse.y
-       $(mesa_local-y-to-c-and-h)
-
-$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
-       $(local-l-to-c)
-
 $(intermediates)/main/git_sha1.h:
        @mkdir -p $(dir $@)
        @echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
index 48a37a1973045cbc266cdff4118da44bfa4b518b..093d7a18940bb59008a48a03a1343431471324d4 100644 (file)
@@ -53,9 +53,13 @@ LOCAL_CFLAGS := \
    $(patsubst %,-DFEATURE_%=1,$(MESA_ENABLED_APIS))
 
 LOCAL_C_INCLUDES := \
+       $(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
        $(MESA_TOP)/src/mapi \
        $(MESA_TOP)/src/glsl
 
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+       libmesa_program
+
 include $(LOCAL_PATH)/Android.gen.mk
 include $(MESA_COMMON_MK)
 include $(BUILD_STATIC_LIBRARY)
index a0621e35231b3006b536aa580827e677b92a84e3..79914caf17e395a903d50b2756f52fa3823bdadd 100644 (file)
@@ -49,11 +49,15 @@ endif # x86
 endif # MESA_ENABLE_ASM
 
 LOCAL_C_INCLUDES := \
+       $(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
        $(MESA_TOP)/src/gallium/auxiliary \
        $(MESA_TOP)/src/gallium/include \
        $(MESA_TOP)/src/glsl \
        $(MESA_TOP)/src/mapi
 
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+       libmesa_program
+
 include $(LOCAL_PATH)/Android.gen.mk
 include $(MESA_COMMON_MK)
 include $(BUILD_STATIC_LIBRARY)
index 01055cc18e145d5c29faa6ac7e275c5bf920a0cd..20f781948beefa8dc48cf9e3a5eff53e1c48fd00 100644 (file)
@@ -24,3 +24,5 @@ include $(LOCAL_PATH)/Android.mesa_gen_matypes.mk
 include $(LOCAL_PATH)/Android.libmesa_glsl_utils.mk
 include $(LOCAL_PATH)/Android.libmesa_dricore.mk
 include $(LOCAL_PATH)/Android.libmesa_st_mesa.mk
+
+include $(LOCAL_PATH)/program/Android.mk
index 34e8c82fdb1b5d510e683e346dd3ce202d90ea9f..9809ee437cc93eee1afcbd82fd5616328ea8bb7f 100644 (file)
@@ -23,7 +23,7 @@ if NEED_LIBDRICORE
 DRICORE_SUBDIR = libdricore
 endif
 
-SUBDIRS = x86 x86-64 . $(DRICORE_SUBDIR) drivers
+SUBDIRS = program x86 x86-64 . $(DRICORE_SUBDIR) drivers
 
 gldir = $(includedir)/GL
 gl_HEADERS = $(top_srcdir)/include/GL/*.h
@@ -53,22 +53,11 @@ include $(GLAPI)/glapi_gen.mk
 
 BUILT_SOURCES = \
        main/git_sha1.h \
-       main/get_hash.h \
-       program/program_parse.tab.c \
-       program/program_parse.tab.h \
-       program/lex.yy.c
+       main/get_hash.h
 CLEANFILES = \
        $(BUILT_SOURCES) \
        git_sha1.h.tmp
 
-program/program_parse.tab.c program/program_parse.tab.h: program/program_parse.y
-       $(MKDIR_P) program
-       $(AM_V_GEN) $(YACC) -p "_mesa_program_" -v -d --output=program/program_parse.tab.c $<
-
-program/lex.yy.c: program/program_lexer.l
-       $(MKDIR_P) program
-       $(AM_V_GEN) $(LEX) --never-interactive --outfile=$@ $<
-
 GET_HASH_GEN = main/get_hash_generator.py
 GET_HASH_GEN_FLAGS := $(patsubst -DFEATURE_%=1,-a %, \
                        $(patsubst -DFEATURE_%=0,,$(API_DEFINES)))
@@ -124,14 +113,21 @@ libmesa_la_SOURCES = \
        $(MESA_FILES) \
         $(MESA_ASM_FILES_FOR_ARCH)
 
-libmesa_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
+libmesa_la_LIBADD = \
+        $(top_builddir)/src/glsl/libglsl.la \
+        $(top_builddir)/src/mesa/program/libprogram.la \
+        $()
 libmesa_la_LDFLAGS =
 
 libmesagallium_la_SOURCES = \
        $(MESA_GALLIUM_FILES) \
         $(MESA_ASM_FILES_FOR_ARCH)
 
-libmesagallium_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
+libmesagallium_la_LIBADD = \
+        $(top_builddir)/src/glsl/libglsl.la \
+        $(top_builddir)/src/mesa/program/libprogram.la \
+        $()
+
 libmesagallium_la_LDFLAGS =
 
 if HAVE_GALLIUM
index 6958e327a3e7fa31179cd776d5d3e53ce712c2e2..21454aad723e74281972ffaa4b76e557f54aa440 100644 (file)
@@ -41,7 +41,9 @@ libdricore@VERSION@_la_SOURCES = \
        $(BUILTIN_COMPILER_GENERATED_CXX_FILES) \
        $(top_builddir)/src/glsl/builtin_function.cpp
 libdricore@VERSION@_la_LDFLAGS = -version-number 1:0
-libdricore@VERSION@_la_LIBADD = libdricore-asm.la
+libdricore@VERSION@_la_LIBADD = \
+        ../program/libdricore_program.la \
+        libdricore-asm.la
 
 # This is separated from libdricore to avoid conflics in object
 # outputs between main/clip.c and sparc/clip.c.  The documented way to
index 4c20872e14a891ceb0940fd9f2ed0d7f4b1d8e92..bc48ef673ed8ae898bce0b0f23c118ff57490d50 100644 (file)
@@ -1,3 +1,4 @@
+/Makefile
 program_parse.output
 lex.yy.c
 program_parse.tab.c
diff --git a/src/mesa/program/Android.mk b/src/mesa/program/Android.mk
new file mode 100644 (file)
index 0000000..5eb0439
--- /dev/null
@@ -0,0 +1,84 @@
+# Copyright 2012 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+LOCAL_PATH := $(call my-dir)
+
+define local-l-to-c
+       @mkdir -p $(dir $@)
+       @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
+       $(hide) $(LEX) -o$@ $<
+endef
+
+define mesa_local-y-to-c-and-h
+       @mkdir -p $(dir $@)
+       @echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
+       $(hide) $(YACC) -o $@ -p "_mesa_program_" $<
+endef
+
+# ----------------------------------------------------------------------
+# libmesa_program.a
+# ----------------------------------------------------------------------
+
+# Import the following variables:
+#     PROGRAM_FILES
+include $(MESA_TOP)/src/mesa/sources.mak
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libmesa_program
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+
+intermediates := $(call local-intermediates-dir)
+
+MESA_ENABLED_APIS := ES1 ES2
+
+# TODO(chadv): In sources.mak, move these vars to a different list so we can
+# remove this kludge.
+generated_sources_basenames := \
+       lex.yy.c \
+       program_parse.tab.c \
+       program_parse.tab.h
+
+LOCAL_SRC_FILES := \
+       $(filter-out $(generated_sources_basenames),$(subst program/,,$(PROGRAM_FILES)))
+
+LOCAL_GENERATED_SOURCES := \
+       $(addprefix $(intermediates)/program/,$(generated_sources_basenames))
+
+$(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program_parse.y
+       $(mesa_local-y-to-c-and-h)
+
+$(intermediates)/program/program_parse.tab.h: $(LOCAL_PATH)/program_parse.y
+       $(mesa_local-y-to-c-and-h)
+
+$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program_lexer.l
+       $(local-l-to-c)
+
+LOCAL_CFLAGS := \
+       $(patsubst %,-DFEATURE_%=1,$(MESA_ENABLED_APIS))
+
+LOCAL_C_INCLUDES := \
+       $(intermediates) \
+       $(MESA_TOP)/src/mapi \
+       $(MESA_TOP)/src/mesa \
+       $(MESA_TOP)/src/glsl
+
+include $(MESA_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/src/mesa/program/Makefile.am b/src/mesa/program/Makefile.am
new file mode 100644 (file)
index 0000000..db6616c
--- /dev/null
@@ -0,0 +1,57 @@
+# Copyright © 2012 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+include ../sources.mak
+
+AM_CPPFLAGS = $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS)
+AM_CFLAGS = $(VISIBILITY_CFLAGS)
+AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
+libdricore_program_la_CFLAGS = $(NOVISIBILITY_CFLAGS)
+libdricore_program_la_CXXFLAGS = $(NOVISIBILITY_CXXFLAGS)
+
+SRCDIR = $(top_srcdir)/src/mesa/
+BUILDDIR = $(top_builddir)/src/mesa/
+
+if NEED_LIBDRICORE
+DRICORE_LIB = libdricore_program.la
+endif
+
+noinst_LTLIBRARIES = $(DRICORE_LIB)
+if NEED_LIBMESA
+noinst_LTLIBRARIES += libprogram.la
+else
+check_LTLIBRARIES = libprogram.la
+endif
+
+libprogram_la_SOURCES = $(PROGRAM_FILES)
+libdricore_program_la_SOURCES = $(PROGRAM_FILES)
+
+lex.yy.c: program_lexer.l
+       $(AM_V_GEN) $(LEX) --never-interactive --outfile=$@ $<
+
+program_parse.tab.c program_parse.tab.h: program_parse.y
+       $(AM_V_GEN) $(YACC) -p "_mesa_program_" -v -d --output=program_parse.tab.c $<
+
+BUILT_SOURCES = \
+       program_parse.tab.c \
+       program_parse.tab.h \
+       lex.yy.c
+CLEANFILES = $(BUILT_SOURCES)
index 07076c60a5dbbe28524a8aeb89b646c70bf2b3b1..93d466b440e5ee38a77f2f8af56d410c201cbf59 100644 (file)
@@ -316,7 +316,6 @@ MESA_FILES = \
        $(MATH_XFORM_FILES)     \
        $(VBO_FILES)            \
        $(TNL_FILES)            \
-       $(PROGRAM_FILES)        \
        $(SWRAST_FILES) \
        $(SWRAST_SETUP_FILES)   \
        $(COMMON_DRIVER_FILES)\
@@ -328,7 +327,6 @@ MESA_GALLIUM_FILES = \
        $(MATH_FILES)           \
        $(VBO_FILES)            \
        $(STATETRACKER_FILES)   \
-       $(PROGRAM_FILES)        \
        $(SRCDIR)x86/common_x86.c
 
 # All the core C sources, for dependency checking