1: .PHONY: all clean distclean
2:
3: # Figure out root of library, unless used as submodule
4: ROOTDIR ?= $(shell pwd)
5:
6: CC ?= $(CROSS)gcc
7: AR ?= $(CROSS)ar
8: STRIP ?= $(CROSS)strip
9: INSTALL := install --backup=off
10: STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755
11:
12: CPPFLAGS += -D_GNU_SOURCE
13: ARFLAGS = crus
14:
15: # Default to silent build, use V=1 to get verbose mode.
16: ifeq ($V,1)
17: Q =
18: PRINT = @true
19: REDIRECT =
20: MAKEFLAGS =
21: VERBOSE = -v
22: else
23: Q = @
24: PRINT = @printf
25: REDIRECT = >/dev/null
26: MAKEFLAGS = --no-print-directory --silent
27: VERBOSE =
28: endif
29:
30: # Some tests may need to be run as root, e.g. pidfile()
31: ifeq ($(ASROOT), 1)
32: SUDO = sudo -n
33: else
34: SUDO =
35: endif
36:
37: # Default install paths
38: prefix ?= /usr/local
39: libdir ?= $(prefix)/lib
40: datadir ?= $(prefix)/share/doc/$(LIBNAME)
41: incdir ?= $(prefix)/include
42:
43: # Pretty printing and GCC -M for auto dep files
44: %.o: %.c
45: $(PRINT) " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
46: $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -MMD -MP -o $@ $<
47:
48: %: %.o
49: $(PRINT) " LINK $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
50: $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-Map,$@.map -o $@ $^ $(LDLIBS$(LDLIBS-$(@)))
51:
52: .PHONY: %.test
53: %.test: %.c
54: $(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n"
55: $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -g -o $@ -DUNITTEST $< $(OBJS)
56: $(Q)$(RM) $(OBJS)
57: $(Q)$(SUDO) ./$@ $(VERBOSE) $(REDIRECT)
58:
59:
60: # Default build rules for both main and unit test makefiles
61: all:: $(TARGET)
62:
63: clean::
64: -$(Q)$(RM) $(OBJS) $(DEPS) $(TARGET) $(SOLIB) $(STATICLIB)
65:
66: distclean::
67: -$(Q)$(RM) $(JUNK) unittest *.o *.a *.so* *.unittest *.test
68:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>