Amxb_Ubus  3.3.1
Ambiorix Ubus 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
8 TARGET_LIB_SO = $(OBJDIR)/libamxb_ubus.so.$(VERSION)
9 TARGET_LIB_A = $(OBJDIR)/libamxb_ubus.a
10 
11 # directories
12 # source directories
13 SRCDIR = .
14 INCDIR_PUB = ../include
15 INCDIR_PRIV = ../include_priv
16 INCDIRS = $(INCDIR_PUB) $(INCDIR_PRIV) $(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)/$(TARGET_NAME)/*.h)
21 SOURCES = $(wildcard $(SRCDIR)/*.c)
22 OBJECTS = $(addprefix $(OBJDIR)/,$(notdir $(SOURCES:.c=.o)))
23 
24 # compilation and linking flags
25 CFLAGS += -Werror -Wall \
26  -Wformat=2 -Wshadow \
27  -Wwrite-strings -Wredundant-decls \
28  -Wmissing-declarations -Wno-attributes \
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=gnu11
35 endif
36 
37 LDFLAGS += $(STAGING_LIBDIR) -shared -fPIC -lamxc -lamxp -lamxd -lamxb -lubox -lubus
38 
39 # targets
40 all: ../include_priv/amxb_ubus_version.h $(TARGET_SO) $(TARGET_LIB_SO) $(TARGET_LIB_A)
41 
42 $(TARGET_SO): $(OBJECTS)
43  $(CC) -Wl,-soname,$(COMPONENT).so -o $@ $(OBJECTS) $(LDFLAGS)
44 
45 $(TARGET_LIB_SO): $(OBJECTS)
46  $(CC) -Wl,-soname,libamxb_ubus.so.$(VMAJOR) -o $@ $(OBJECTS) $(LDFLAGS)
47 
48 $(TARGET_LIB_A): $(OBJECTS)
49  $(AR) rcs $(@) $(OBJECTS)
50 
51 -include $(OBJECTS:.o=.d)
52 
53 $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)/
54  $(CC) $(CFLAGS) -c -o $@ $<
55  @$(CC) $(CFLAGS) -MM -MP -MT '$(@) $(@:.o=.d)' -MF $(@:.o=.d) $(<)
56 
57 $(OBJDIR)/:
58  $(MKDIR) -p $@
59 
60 ../include_priv/amxb_ubus_version.h: ../include_priv/amxb_ubus_version.h.m4
61  @echo "Current backend version = $(VMAJOR).$(VMINOR).$(VBUILD)"
62  m4 -DMAJOR=$(VMAJOR) -DMINOR=$(VMINOR) -DBUILD=$(VBUILD) $(<) > $(@)
63 
64 clean:
65  rm -rf ../output/ ../$(COMPONENT)-*.* ../$(COMPONENT)_*.* ../include_priv/amxb_ubus_version.h
66  make -C ../test clean
67  find ../test -name "run_test" -delete
68  find ../test -name "*.so" -delete
69 
70 .PHONY: all clean