Mesa (glsl-pp-rework-2): Build mesa glsl with make.

Michał Król michal at kemper.freedesktop.org
Thu Dec 10 09:53:13 UTC 2009


Module: Mesa
Branch: glsl-pp-rework-2
Commit: 068596c9a7e8d330ffdff8ad8700bd6093b5bdea
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=068596c9a7e8d330ffdff8ad8700bd6093b5bdea

Author: michal <michal at transistor.(none)>
Date:   Thu Dec 10 01:03:15 2009 +0100

Build mesa glsl with make.

Still don't know how to add glsl to mesa dependencies.

---

 Makefile                               |    4 ++
 configs/default                        |    2 +-
 src/glsl/Makefile                      |   15 +++++++++
 src/glsl/Makefile.template             |   50 +++++++++++++++++++++++++++++
 src/glsl/apps/Makefile                 |   42 ++++++++++++++++++++++++
 src/glsl/cl/Makefile                   |   13 +++++++
 src/glsl/pp/Makefile                   |   26 +++++++++++++++
 src/mesa/Makefile                      |   15 ++++++--
 src/mesa/shader/slang/library/Makefile |   55 ++++++++++----------------------
 9 files changed, 179 insertions(+), 43 deletions(-)

diff --git a/Makefile b/Makefile
index ea00e81..0f759d8 100644
--- a/Makefile
+++ b/Makefile
@@ -225,6 +225,10 @@ MAIN_FILES = \
 	$(DIRECTORY)/include/GL/vms_x_fix.h				\
 	$(DIRECTORY)/include/GL/wglext.h				\
 	$(DIRECTORY)/include/GL/wmesa.h					\
+	$(DIRECTORY)/src/glsl/Makefile					\
+	$(DIRECTORY)/src/glsl/*/Makefile				\
+	$(DIRECTORY)/src/glsl/*/SConscript				\
+	$(DIRECTORY)/src/glsl/*/*.[ch]					\
 	$(DIRECTORY)/src/Makefile					\
 	$(DIRECTORY)/src/mesa/Makefile*					\
 	$(DIRECTORY)/src/mesa/sources.mak				\
diff --git a/configs/default b/configs/default
index cb3ca10..f365931 100644
--- a/configs/default
+++ b/configs/default
@@ -83,7 +83,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
 
 # Directories to build
 LIB_DIR = lib
-SRC_DIRS = mesa gallium egl gallium/winsys glu glut/glx glew glw
+SRC_DIRS = glsl mesa gallium egl gallium/winsys glu glut/glx glew glw
 GLU_DIRS = sgi
 DRIVER_DIRS = x11 osmesa
 # Which subdirs under $(TOP)/progs/ to enter:
diff --git a/src/glsl/Makefile b/src/glsl/Makefile
new file mode 100644
index 0000000..ca7f2d2
--- /dev/null
+++ b/src/glsl/Makefile
@@ -0,0 +1,15 @@
+# src/glsl/Makefile
+
+TOP = ../..
+
+include $(TOP)/configs/current
+
+SUBDIRS = pp cl apps
+
+default install clean:
+	@for dir in $(SUBDIRS) ; do \
+		if [ -d $$dir ] ; then \
+			(cd $$dir && $(MAKE) $@) || exit 1; \
+		fi \
+	done
+
diff --git a/src/glsl/Makefile.template b/src/glsl/Makefile.template
new file mode 100644
index 0000000..974987a
--- /dev/null
+++ b/src/glsl/Makefile.template
@@ -0,0 +1,50 @@
+# src/glsl/Makefile.template
+
+# Template makefile for glsl libraries.
+#
+# Usage:
+#   The minimum that the including makefile needs to define
+#   is TOP, LIBNAME and one of of the *_SOURCES.
+#
+# Optional defines:
+#   LIBRARY_INCLUDES are appended to the list of includes directories.
+#   LIBRARY_DEFINES is not used for makedepend, but for compilation.
+
+
+### Basic defines ###
+
+OBJECTS = $(C_SOURCES:.c=.o)
+
+INCLUDES = \
+	-I. \
+	$(LIBRARY_INCLUDES)
+
+
+##### TARGETS #####
+
+default: depend lib$(LIBNAME).a
+
+lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
+	$(MKLIB) -o $(LIBNAME) -static $(OBJECTS)
+
+depend: $(C_SOURCES)
+	rm -f depend
+	touch depend
+	$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) 2> /dev/null
+
+# Remove .o and backup files
+clean:
+	rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
+
+# Dummy target
+install:
+	@echo -n ""
+
+
+##### RULES #####
+
+.c.o:
+	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+-include depend
+
diff --git a/src/glsl/apps/Makefile b/src/glsl/apps/Makefile
new file mode 100644
index 0000000..c80fcb9
--- /dev/null
+++ b/src/glsl/apps/Makefile
@@ -0,0 +1,42 @@
+# src/glsl/apps/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+LIBS = \
+	$(TOP)/src/glsl/pp/libglslpp.a \
+	$(TOP)/src/glsl/cl/libglslcl.a
+
+SOURCES = \
+	compile.c \
+	process.c \
+	purify.c \
+	tokenise.c \
+	version.c
+
+APPS = $(SOURCES:%.c=%)
+
+INCLUDES = -I.
+
+
+##### RULES #####
+
+.SUFFIXES:
+.SUFFIXES: .c
+
+.c:
+	$(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
+
+.c.o:
+	$(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: $(APPS)
+
+clean:
+	-rm -f $(APPS)
+	-rm -f *.o
+
diff --git a/src/glsl/cl/Makefile b/src/glsl/cl/Makefile
new file mode 100644
index 0000000..04a52df
--- /dev/null
+++ b/src/glsl/cl/Makefile
@@ -0,0 +1,13 @@
+#src/glsl/cl/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+LIBNAME = glslcl
+
+C_SOURCES = \
+	sl_cl_parse.c
+
+include ../Makefile.template
+
diff --git a/src/glsl/pp/Makefile b/src/glsl/pp/Makefile
new file mode 100644
index 0000000..819079f
--- /dev/null
+++ b/src/glsl/pp/Makefile
@@ -0,0 +1,26 @@
+#src/glsl/pp/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+LIBNAME = glslpp
+
+C_SOURCES = \
+	sl_pp_context.c \
+	sl_pp_define.c \
+	sl_pp_dict.c \
+	sl_pp_error.c \
+	sl_pp_expression.c \
+	sl_pp_extension.c \
+	sl_pp_if.c \
+	sl_pp_line.c \
+	sl_pp_macro.c \
+	sl_pp_pragma.c \
+	sl_pp_process.c \
+	sl_pp_purify.c \
+	sl_pp_token.c \
+	sl_pp_version.c
+
+include ../Makefile.template
+
diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index 8300b30..67cac2d 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -19,10 +19,10 @@ include sources.mak
 
 
 
-# Default: build dependencies, then asm_subdirs, then convenience
-# libs (.a) and finally the device drivers:
-default: depend asm_subdirs libmesa.a libmesagallium.a libglapi.a \
-	driver_subdirs
+# Default: build dependencies, then asm_subdirs, GLSL built-in lib,
+# then convenience libs (.a) and finally the device drivers:
+default: depend asm_subdirs glsl_builtin libmesa.a libmesagallium.a \
+	libglapi.a driver_subdirs
 
 
 
@@ -64,6 +64,12 @@ asm_subdirs:
 
 
 ######################################################################
+# GLSL built-in library
+glsl_builtin:
+	(cd shader/slang/library && $(MAKE)) || exit 1 ;
+
+
+######################################################################
 # Dependency generation
 
 depend: $(ALL_SOURCES)
@@ -156,6 +162,7 @@ clean:
 	-rm -f depend depend.bak libmesa.a libglapi.a
 	-rm -f drivers/*/*.o
 	-rm -f *.pc
+	-rm -f shader/slang/library/*_gc.h
 	- at cd drivers/dri && $(MAKE) clean
 	- at cd drivers/x11 && $(MAKE) clean
 	- at cd drivers/osmesa && $(MAKE) clean
diff --git a/src/mesa/shader/slang/library/Makefile b/src/mesa/shader/slang/library/Makefile
index 5033d88..c696451 100644
--- a/src/mesa/shader/slang/library/Makefile
+++ b/src/mesa/shader/slang/library/Makefile
@@ -4,9 +4,7 @@ TOP = ../../../../..
 
 include $(TOP)/configs/current
 
-INCDIR = $(TOP)/include
-
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
+GLSL_CL = $(TOP)/src/glsl/apps/compile
 
 #
 # targets
@@ -14,33 +12,14 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
 .PHONY: default clean
 
-default: syntax builtin
+default: builtin
 
 clean:
-	-rm -f syn_to_c gc_to_bin *_syn.h *_gc.h
-
-syntax: slang_shader_syn.h
+	-rm -f *_gc.h
 
 builtin: builtin_110 builtin_120
 
 #
-# executables
-#
-
-syn_to_c: syn_to_c.c
-	$(CC) syn_to_c.c -o syn_to_c
-
-gc_to_bin: gc_to_bin.c slang_shader_syn.h
-	$(CC) gc_to_bin.c -o gc_to_bin
-
-#
-# syntax scripts
-#
-
-slang_shader_syn.h: syn_to_c slang_shader.syn
-	./syn_to_c slang_shader.syn > slang_shader_syn.h
-
-#
 # builtin library sources
 #
 
@@ -49,24 +28,24 @@ builtin_110: slang_common_builtin_gc.h slang_core_gc.h slang_fragment_builtin_gc
 builtin_120: slang_120_core_gc.h slang_builtin_120_common_gc.h slang_builtin_120_fragment_gc.h
 
 
-slang_120_core_gc.h: gc_to_bin slang_120_core.gc
-	./gc_to_bin 1 slang_120_core.gc slang_120_core_gc.h
+slang_120_core_gc.h: slang_120_core.gc
+	$(GLSL_CL) fragment slang_120_core.gc slang_120_core_gc.h
 
-slang_builtin_120_common_gc.h: gc_to_bin slang_builtin_120_common.gc
-	./gc_to_bin 1 slang_builtin_120_common.gc slang_builtin_120_common_gc.h
+slang_builtin_120_common_gc.h: slang_builtin_120_common.gc
+	$(GLSL_CL) fragment slang_builtin_120_common.gc slang_builtin_120_common_gc.h
 
-slang_builtin_120_fragment_gc.h: gc_to_bin slang_builtin_120_fragment.gc
-	./gc_to_bin 1 slang_builtin_120_fragment.gc slang_builtin_120_fragment_gc.h
+slang_builtin_120_fragment_gc.h: slang_builtin_120_fragment.gc
+	$(GLSL_CL) fragment slang_builtin_120_fragment.gc slang_builtin_120_fragment_gc.h
 
-slang_common_builtin_gc.h: gc_to_bin slang_common_builtin.gc
-	./gc_to_bin 1 slang_common_builtin.gc slang_common_builtin_gc.h
+slang_common_builtin_gc.h: slang_common_builtin.gc
+	$(GLSL_CL) fragment slang_common_builtin.gc slang_common_builtin_gc.h
 
-slang_core_gc.h: gc_to_bin slang_core.gc
-	./gc_to_bin 1 slang_core.gc slang_core_gc.h
+slang_core_gc.h: slang_core.gc
+	$(GLSL_CL) fragment slang_core.gc slang_core_gc.h
 
-slang_fragment_builtin_gc.h: gc_to_bin slang_fragment_builtin.gc
-	./gc_to_bin 1 slang_fragment_builtin.gc slang_fragment_builtin_gc.h
+slang_fragment_builtin_gc.h: slang_fragment_builtin.gc
+	$(GLSL_CL) fragment slang_fragment_builtin.gc slang_fragment_builtin_gc.h
 
-slang_vertex_builtin_gc.h: gc_to_bin slang_vertex_builtin.gc
-	./gc_to_bin 2 slang_vertex_builtin.gc slang_vertex_builtin_gc.h
+slang_vertex_builtin_gc.h: slang_vertex_builtin.gc
+	$(GLSL_CL) vertex slang_vertex_builtin.gc slang_vertex_builtin_gc.h
 




More information about the mesa-commit mailing list