SAH_Trace  1.1.0
SAHTRACE Module
makefile
Go to the documentation of this file.
1 include ../makefile.inc
2 
3 # build destination directories
4 OBJDIR = ../output/$(MACHINE)
5 
6 # TARGETS
7 TARGET_SO = $(OBJDIR)/$(COMPONENT).so
8 TARGET_A = $(OBJDIR)/$(COMPONENT).a
9 
10 # directories
11 # source directories
12 SRCDIR = .
13 INCDIR_PUB =
14 INCDIR_PRIV = $(realpath ../include_priv)
15 INCDIRS = $(INCDIR_PUB) $(INCDIR_PRIV) $(if $(STAGINGDIR), $(STAGINGDIR)/include $(STAGINGDIR)/usr/include)
16 STAGING_LIBDIR = $(if $(STAGINGDIR), -L$(STAGINGDIR)/lib -L$(STAGINGDIR)/usr/lib)
17 
18 # files
19 HEADERS =
20 SOURCES = $(wildcard $(SRCDIR)/*.c)
21 OBJECTS = $(addprefix $(OBJDIR)/,$(notdir $(SOURCES:.c=.o)))
22 
23 # compilation and linking flags
24 CFLAGS += -Werror -Wall -Wextra \
25  -Wformat=2 -Wshadow \
26  -Wwrite-strings -Wredundant-decls \
27  -Wpedantic -Wmissing-declarations -Wno-attributes \
28  -Wno-format-nonliteral \
29  -fPIC -g3 $(addprefix -I ,$(INCDIRS))
30 
31 ifeq ($(CC_NAME),g++)
32  CFLAGS += -std=c++2a
33 else
34  CFLAGS += -Wstrict-prototypes -Wold-style-definition -Wnested-externs -std=c11
35 endif
36 
37 LDFLAGS += $(STAGING_LIBDIR) -shared -fPIC -lamxc -lamxd -lamxo -lsahtrace
38 
39 # targets
40 all: $(TARGET_SO) $(TARGET_A)
41 
42 $(TARGET_SO): $(OBJECTS)
43  $(CC) -Wl,-soname,$(COMPONENT).so -o $(@) $(OBJECTS) $(LDFLAGS)
44 
45 $(TARGET_A): $(OBJECTS)
46  $(AR) rcs $(@) $^
47 
48 -include $(OBJECTS:.o=.d)
49 
50 $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)/
51  $(CC) $(CFLAGS) -c -o $@ $<
52  @$(CC) $(CFLAGS) -MM -MP -MT '$(@) $(@:.o=.d)' -MF $(@:.o=.d) $(<)
53 
54 $(OBJDIR)/:
55  $(MKDIR) -p $@
56 
57 clean:
58  rm -rf ../output/ ../$(COMPONENT)-*.* ../$(COMPONENT)_*.*
59 
60 .PHONY: all clean