nvfx: move declarations before code to silence warnings
[mesa.git] / src / gallium / Makefile.template
index 4e462b5c9769eac9fce7cf2311f45f1d4c26d20a..b5a9938c74093637d272f2e277a592f36f9213f3 100644 (file)
@@ -1,64 +1,69 @@
-# -*-makefile-*-
+# src/gallium/Makefile.template
 
-
-# We still have a dependency on the "dri" buffer manager.  Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
+# Template makefile for gallium libraries.
+#
+# Usage:
+#   The minimum that the including makefile needs to define
+#   is TOP, LIBNAME and one of of the *_SOURCES.
 #
-COMMON_SOURCES = 
+# Optional defines:
+#   LIBRARY_INCLUDES are appended to the list of includes directories.
+#   LIBRARY_DEFINES is not used for makedepend, but for compilation.
 
-OBJECTS = $(C_SOURCES:.c=.o) \
-          $(CPP_SOURCES:.cpp=.o) \
-         $(ASM_SOURCES:.S=.o) 
+### Basic defines ###
 
+OBJECTS = $(C_SOURCES:.c=.o) \
+       $(CPP_SOURCES:.cpp=.o) \
+       $(ASM_SOURCES:.S=.o)
 
-### Include directories
 INCLUDES = \
        -I. \
        -I$(TOP)/src/gallium/include \
        -I$(TOP)/src/gallium/auxiliary \
        -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/include \
-        $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
-       $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES)  $< -o $@
+       $(LIBRARY_INCLUDES)
 
 
 ##### TARGETS #####
 
-default: depend symlinks $(LIBNAME)
+default: depend lib$(LIBNAME).a $(PROGS)
 
+lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
+       $(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS)
 
-$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
-       $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
        rm -f depend
        touch depend
-       $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
-               $(ASM_SOURCES) 2> /dev/null
+       $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null
 
+$(PROGS): % : %.o
+       $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group  $(LIBS) -Wl,--end-group
 
 # Emacs tags
 tags:
-       etags `find . -name \*.[ch]` `find ../include`
-
+       etags `find . -name \*.[ch]` `find $(TOP)/src/gallium/include -name \*.h`
 
 # Remove .o and backup files
-clean::
-       -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
-       -rm -f depend depend.bak
+clean:
+       rm -f $(OBJECTS) $(GENERATED_SOURCES) $(PROGS) lib$(LIBNAME).a depend depend.bak
+
+# Dummy target
+install:
+       @echo -n ""
+
+##### 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 $@
 
 
-include depend
+sinclude depend