libamxo  4.3.4
Object Definition Language (ODL) parsing
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)/amxo/*.h)
20 SOURCES = $(wildcard $(SRCDIR)/*.c)
21 OBJECTS = $(addprefix $(OBJDIR)/,$(notdir $(SOURCES:.c=.o)))
22 OBJECTS += $(OBJDIR)/lex.amxo_parser.o \
23  $(OBJDIR)/amxo_parser.tab.o \
24 
25 
26 # compilation and linking flags
27 CFLAGS += -Werror -Wall -Wextra \
28  -Wformat=2 -Wshadow \
29  -Wwrite-strings -Wredundant-decls \
30  -Wpedantic -Wmissing-declarations -Wno-attributes \
31  -Wno-format-nonliteral \
32  -fPIC -g3 $(addprefix -I ,$(INCDIRS)) -I $(SRCDIR) -I$(OBJDIR)
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 -Wl,--version-script=libamxo.version -lamxc -lamxp -lamxd -lamxs -ldl
45 
46 # targets
47 all: ../include_priv/amxo_version.h $(TARGET_SO) $(TARGET_A)
48 
49 $(TARGET_SO): ../include_priv/amxo_version.h $(OBJECTS)
50  $(CC) -Wl,-soname,$(COMPONENT).so.$(VMAJOR) -o $@ $(OBJECTS) $(LDFLAGS)
51 
52 $(TARGET_A): ../include_priv/amxo_version.h $(OBJECTS)
53  $(AR) rcs $(@) $(OBJECTS)
54 
55 -include $(OBJECTS:.o=.d)
56 
57 $(OBJDIR)/lex.amxo_parser.o $(OBJDIR)/lex.amxo_parser.c: $(OBJDIR)/amxo_parser.tab.h amxo_parser.l | $(OBJDIR)/
58  flex --header-file=$(OBJDIR)/amxo_parser_flex.h -o $(OBJDIR)/lex.amxo_parser.c amxo_parser.l
59  $(CC) $(CFLAGS) -Wno-sign-compare -c -o $(OBJDIR)/lex.amxo_parser.o $(OBJDIR)/lex.amxo_parser.c
60 
61 $(OBJDIR)/amxo_parser.tab.c $(OBJDIR)/amxo_parser.tab.h: amxo_parser.y | $(OBJDIR)/
62  bison -Wconflicts-sr -d --verbose -o $(OBJDIR)/amxo_parser.tab.c amxo_parser.y
63 
64 $(OBJDIR)/amxo_parser.tab.o: $(OBJDIR)/amxo_parser.tab.c $(OBJDIR)/amxo_parser.tab.h
65  $(CC) $(CFLAGS) -c -o $(OBJDIR)/amxo_parser.tab.o $(OBJDIR)/amxo_parser.tab.c
66 
67 $(OBJDIR)/%.o: $(SRCDIR)/%.c $(OBJDIR)/amxo_parser.tab.h | $(OBJDIR)/
68  $(CC) $(CFLAGS) -c -o $@ $<
69  @$(CC) $(CFLAGS) -MM -MP -MT '$(@) $(@:.o=.d)' -MF $(@:.o=.d) $(<)
70 
71 ../include_priv/amxo_version.h : ../include_priv/amxo_version.h.m4
72  @echo "Current library version = $(VMAJOR).$(VMINOR).$(VBUILD)"
73  m4 -DMAJOR=$(VMAJOR) -DMINOR=$(VMINOR) -DBUILD=$(VBUILD) $(<) > $(@)
74 
75 $(OBJDIR)/:
76  $(MKDIR) -p $@
77 
78 clean:
79  rm -rf ../output/ ../$(COMPONENT)-*.* ../$(COMPONENT)_*.* ../include_priv/amxo_version.h
80  make -C ../test clean
81  find ../ -name "run_test" -delete
82 
83 .PHONY: all clean