libamxd  6.4.1
Data Model Manager
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.$(VERSION)
8 TARGET_A = $(OBJDIR)/$(COMPONENT).a
9 
10 # directories
11 # source directories
12 SRCDIR = .
13 INCDIR_PUB = ../include
14 INCDIR_PRIV = ../include_priv
15 INCDIRS = $(INCDIR_PUB) $(INCDIR_PRIV) $(if $(STAGINGDIR), $(STAGINGDIR)/include) $(if $(STAGINGDIR), $(STAGINGDIR)/usr/include)
16 STAGING_LIBDIR = $(if $(STAGINGDIR), -L$(STAGINGDIR)/lib) $(if $(STAGINGDIR), -L$(STAGINGDIR)/usr/lib)
17 
18 # files
19 HEADERS = $(wildcard $(INCDIR_PUB)/amxd/*.h)
20 SOURCES = $(wildcard $(SRCDIR)/*.c)
21 OBJECTS = $(addprefix $(OBJDIR)/,$(notdir $(SOURCES:.c=.o)))
22 OBJECTS += $(addprefix $(OBJDIR)/,$(notdir $(VARIANTS:.c=.o)))
23 
24 # compilation and linking flags
25 CFLAGS += -Werror -Wall -Wextra -Wformat=2 -Wshadow -Wwrite-strings \
26  -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 -Wdeclaration-after-statement -Wnested-externs -std=c11
35 endif
36 
37 LDFLAGS += $(STAGING_LIBDIR) -shared -fPIC -lamxc -lamxp
38 
39 # targets
40 all: $(TARGET_SO) $(TARGET_A)
41 
42 $(TARGET_SO): $(OBJECTS)
43  $(CC) -Wl,-soname,$(COMPONENT).so.$(VMAJOR) -o $@ $(OBJECTS) $(LDFLAGS)
44 
45 $(TARGET_A): $(OBJECTS)
46  $(AR) rcs $(@) $(OBJECTS)
47 
48 -include $(OBJECTS:.o=.d)
49 
50 $(OBJDIR)/%.o: $(SRCDIR)/variants/%.c | $(OBJDIR)/
51  $(CC) $(CFLAGS) -c -o $@ $<
52  @$(CC) $(CFLAGS) -MM -MP -MT '$(@) $(@:.o=.d)' -MF $(@:.o=.d) $(<)
53 
54 $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)/
55  $(CC) $(CFLAGS) -c -o $@ $<
56  @$(CC) $(CFLAGS) -MM -MP -MT '$(@) $(@:.o=.d)' -MF $(@:.o=.d) $(<)
57 
58 $(OBJDIR)/:
59  $(MKDIR) -p $@
60 
61 clean:
62  rm -rf ../output/ ../$(COMPONENT)-*.* ../$(COMPONENT)_*.*
63  find . -name "run_test" -delete
64 
65 
66 .PHONY: all clean