1# src/gallium/Makefile.template
2
3# Template makefile for gallium libraries.
4#
5# Usage:
6#   The minimum that the including makefile needs to define
7#   is TOP, LIBNAME and one of of the *_SOURCES.
8#
9# Optional defines:
10#   LIBRARY_INCLUDES are appended to the list of includes directories.
11#   LIBRARY_DEFINES is not used for makedepend, but for compilation.
12
13### Basic defines ###
14
15OBJECTS = $(C_SOURCES:.c=.o) \
16	$(CPP_SOURCES:.cpp=.o) \
17	$(ASM_SOURCES:.S=.o)
18
19INCLUDES = \
20	-I. \
21	-I$(TOP)/src/gallium/include \
22	-I$(TOP)/src/gallium/auxiliary \
23	-I$(TOP)/src/gallium/drivers \
24	$(LIBRARY_INCLUDES)
25
26ifeq ($(MESA_LLVM),1)
27LIBRARY_DEFINES += $(LLVM_CFLAGS)
28endif
29
30
31##### TARGETS #####
32
33default: depend lib$(LIBNAME).a $(PROGS)
34
35lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
36	$(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS)
37
38depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
39	rm -f depend
40	touch depend
41	$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null
42
43$(PROGS): % : %.o $(PROGS_DEPS)
44	$(LD) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group  $(LIBS) -Wl,--end-group
45
46# Emacs tags
47tags:
48	etags `find . -name \*.[ch]` `find $(TOP)/src/gallium/include -name \*.h`
49
50# Remove .o and backup files
51clean:
52	rm -f $(OBJECTS) $(GENERATED_SOURCES) $(PROGS) lib$(LIBNAME).a depend depend.bak $(CLEAN_EXTRA)
53
54# Dummy target
55install:
56	@echo -n ""
57
58##### RULES #####
59
60%.s: %.c
61	$(CC) -S $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
62
63%.o: %.c
64	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
65
66%.o: %.cpp
67	$(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
68
69%.o: %.S
70	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES)  $< -o $@
71
72
73sinclude depend
74