gallium: Create a Xorg driver template Makefile
authorJakob Bornecrantz <jakob@vmware.com>
Tue, 1 Jun 2010 08:04:29 +0000 (09:04 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Tue, 1 Jun 2010 08:41:00 +0000 (09:41 +0100)
src/gallium/targets/Makefile.xorg [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/Makefile

diff --git a/src/gallium/targets/Makefile.xorg b/src/gallium/targets/Makefile.xorg
new file mode 100644 (file)
index 0000000..610cf45
--- /dev/null
@@ -0,0 +1,72 @@
+# src/gallium/targets/Makefile.xorg
+
+# Template makefile for gallium xorg drivers.
+#
+# Usage:
+#   The minimum that the including makefile needs to define
+#   is TOP, LIBNAME and one of of the *_SOURCES.
+#
+# Optional defines:
+#   DRIVER_INCLUDES are appended to the list of includes directories.
+#   DRIVER_DEFINES is not used for makedepend, but for compilation.
+#   DRIVER_LINKS are flags given to the linker
+
+### Basic defines ###
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+       $(CPP_SOURCES:.cpp=.o) \
+       $(ASM_SOURCES:.S=.o)
+
+INCLUDES = \
+       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       $(DRIVER_INCLUDES)
+
+LIBNAME_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
+
+
+##### TARGETS #####
+
+default: depend $(LIBNAME) $(LIBNAME_STAGING)
+
+$(LIBNAME): $(OBJECTS) Makefile $(LIBS)
+       $(MKLIB) -noprefix -o $@ $(OBJECTS) $(DRIVER_LINKS)
+
+depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null
+
+$(LIBNAME_STAGING): $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+clean:
+       rm -f $(OBJECTS) $(GENERATED_SOURCES) $(LIBNAME).a depend depend.bak
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+
+##### RULES #####
+
+%.s: %.c
+       $(CC) -S $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+%.o: %.c
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+%.o: %.cpp
+       $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+%.o: %.S
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES)  $< -o $@
+
+sinclude depend
+
+.PHONY: default clean install
index 01a10b6f1984157f15fb8404c919e6a81aa5ddc0..c0ff999116533913c491e658ad8e3d879457cd6e 100644 (file)
@@ -1,72 +1,30 @@
 TOP = ../../../..
 include $(TOP)/configs/current
 
-TARGET = vmwgfx_drv.so
+LIBNAME = vmwgfx_drv.so
 
-CFILES = \
+C_SOURCES = \
        vmw_xorg.c \
        vmw_video.c \
        vmw_ioctl.c \
        vmw_ctrl.c \
        vmw_screen.c
 
-OBJECTS = $(patsubst %.c,%.o,$(CFILES))
-
-INCLUDES = \
-       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary \
+DRIVER_INCLUDES = \
        -I$(TOP)/src/gallium
 
-LIBS = \
+DRIVER_DEFINES = \
+       -std=gnu99 \
+       -DHAVE_CONFIG_H
+
+DRIVER_LINKS = \
        $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
        $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/rbug/librbug.a \
        $(TOP)/src/gallium/drivers/svga/libsvga.a \
-       $(GALLIUM_AUXILIARIES)
-
-LINKS = \
+       $(GALLIUM_AUXILIARIES) \
        $(shell pkg-config --libs --silence-errors libkms) \
        $(shell pkg-config --libs libdrm)
 
-DRIVER_DEFINES = \
-       -std=gnu99 \
-       -DHAVE_CONFIG_H
-
-TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
-
-#############################################
-
-
-
-all default: $(TARGET) $(TARGET_STAGING)
-
-$(TARGET): $(OBJECTS) Makefile $(LIBS)
-       $(MKLIB) -noprefix -o $@ $(OBJECTS) $(LIBS) $(LINKS)
-
-$(TOP)/$(LIB_DIR)/gallium:
-       mkdir -p $@
-
-$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-
-clean:
-       rm -rf $(OBJECTS) $(TARGET)
-
-install:
-       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-
-##############################################
-
-
-.c.o:
-       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
-
-
-##############################################
-
-.PHONY = all clean install
+include ../Makefile.xorg