libamxs  0.6.0
Data Model Synchronization C API
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)
16 INCDIRS += $(if $(STAGINGDIR), $(STAGINGDIR)/include) $(if $(STAGINGDIR), $(STAGINGDIR)/usr/include)
17 STAGING_LIBDIR = $(if $(STAGINGDIR), -L$(STAGINGDIR)/lib) $(if $(STAGINGDIR), -L$(STAGINGDIR)/usr/lib)
18 
19 # files
20 HEADERS = $(wildcard $(INCDIR_PUB)/amxs/*.h)
21 SOURCES = $(wildcard $(SRCDIR)/*.c)
22 OBJECTS = $(addprefix $(OBJDIR)/,$(notdir $(SOURCES:.c=.o)))
23 
24 # compilation and linking flags
25 # -Werror=pedantic is removed because of the use of dlsym
26 # when added the following error occurs:
27 # error: ISO C forbids conversion of object pointer to function pointer type [-Werror=pedantic]
28 CFLAGS += -Werror -Wall -Wextra \
29  -Wformat=2 -Wshadow \
30  -Wwrite-strings -Wredundant-decls \
31  -Wmissing-declarations -Wno-format-nonliteral \
32  -fPIC -g3 $(addprefix -I ,$(INCDIRS))
33 
34 ifeq ($(CC_NAME),g++)
35  CFLAGS += -std=c++2a
36 else
37  CFLAGS += -Wstrict-prototypes \
38  -Wold-style-definition \
39  -Wdeclaration-after-statement \
40  -Wnested-externs \
41  -std=c11
42 endif
43 
44 LDFLAGS += $(STAGING_LIBDIR) -shared -fPIC
45 LDFLAGS += -lamxc -lamxp -lamxb -ldl
46 
47 # targets
48 all: $(TARGET_SO) $(TARGET_A)
49 
50 $(TARGET_SO): $(OBJECTS)
51  $(CC) -Wl,-soname,$(COMPONENT).so.$(VMAJOR) -o $@ $(OBJECTS) $(LDFLAGS)
52 
53 $(TARGET_A): $(OBJECTS)
54  $(AR) rcs $(@) $(OBJECTS)
55 
56 -include $(OBJECTS:.o=.d)
57 
58 $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)/
59  $(CC) $(CFLAGS) -c -o $@ $<
60  @$(CC) $(CFLAGS) -MM -MP -MT '$(@) $(@:.o=.d)' -MF $(@:.o=.d) $(<)
61 
62 $(OBJDIR)/:
63  $(MKDIR) -p $@
64 
65 clean:
66  rm -rf ../output/ ../$(COMPONENT)-*.* ../$(COMPONENT)_*.*
67  find . -name "run_test" -delete
68 
69 
70 .PHONY: all clean