summaryrefslogtreecommitdiffstats
path: root/src/gbm/backends
diff options
context:
space:
mode:
Diffstat (limited to 'src/gbm/backends')
-rw-r--r--src/gbm/backends/Makefile14
-rw-r--r--src/gbm/backends/Makefile.template65
2 files changed, 79 insertions, 0 deletions
diff --git a/src/gbm/backends/Makefile b/src/gbm/backends/Makefile
new file mode 100644
index 00000000000..97eaac496d2
--- /dev/null
+++ b/src/gbm/backends/Makefile
@@ -0,0 +1,14 @@
+# src/gbm/backends/Makefile
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+SUBDIRS = $(GBM_BACKEND_DIRS)
+
+
+default install clean:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir ; $(MAKE) $@) || exit 1 ; \
+ fi \
+ done
diff --git a/src/gbm/backends/Makefile.template b/src/gbm/backends/Makefile.template
new file mode 100644
index 00000000000..90b239a94d0
--- /dev/null
+++ b/src/gbm/backends/Makefile.template
@@ -0,0 +1,65 @@
+# src/gbm/backends/Makefile.template
+#
+# Backends should define
+#
+# GBM_BACKEND, the driver name
+# GBM_SOURCES, the driver sources
+# GBM_INCLUDES, the include pathes
+# GBM_CFLAGS, additional CFLAGS
+# GBM_LIBS, additional LIBS
+#
+# before including this template.
+#
+
+
+GBM_BACKEND_PATH = $(TOP)/$(LIB_DIR)/gbm/$(GBM_BACKEND).so
+GBM_OBJECTS = $(GBM_SOURCES:.c=.o)
+
+# built-in or external
+ifeq ($(GBM_BUILTIN), true)
+GBM_TARGET = lib$(GBM_BACKEND).a
+GBM_INSTALL =
+else
+GBM_TARGET = $(GBM_BACKEND_PATH)
+GBM_INSTALL = install-so
+endif
+
+default: depend $(GBM_TARGET)
+
+$(GBM_BACKEND_PATH): $(GBM_BACKEND).so
+ @$(INSTALL) -d $(TOP)/$(LIB_DIR)/gbm
+ $(INSTALL) $< $(TOP)/$(LIB_DIR)/gbm
+
+$(GBM_BACKEND).so: $(GBM_OBJECTS) Makefile $(TOP)/src/gbm/backends/Makefile.template
+ @$(MKLIB) -o $(GBM_BACKEND).so -noprefix \
+ -linker '$(CC)' -ldflags '-L$(TOP)/$(LIB_DIR) $(LDFLAGS)' \
+ $(MKLIB_OPTIONS) \
+ $(GBM_OBJECTS) $(GBM_LIBS) -l$(GBM_LIB)
+
+lib$(GBM_BACKEND).a: $(GBM_OBJECTS) Makefile $(TOP)/src/gbm/backends/Makefile.template
+ @$(MKLIB) -o $(GBM_BACKEND) -static $(GBM_OBJECTS)
+
+.c.o:
+ $(CC) -c $(GBM_INCLUDES) $(CFLAGS) $(GBM_CFLAGS) $< -o $@
+
+install-so: $(GBM_BACKEND_PATH)
+ $(INSTALL) -d $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR)
+ $(MINSTALL) $(GBM_BACKEND_PATH) $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR)
+
+install: $(GBM_INSTALL)
+
+clean:
+ rm -f $(GBM_BACKEND).so
+ rm -f lib$(GBM_BACKEND).a
+ rm -f $(GBM_OBJECTS)
+ rm -f depend depend.bak
+
+depend: $(GBM_SOURCES)
+ @ echo "running $(MKDEP)"
+ @ rm -f depend
+ @ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(GBM_INCLUDES) $(GBM_SOURCES) \
+ >/dev/null 2>/dev/null
+
+sinclude depend
+# DO NOT DELETE