]> git.stg.codes - stg.git/blob - projects/sgconf/Makefile
Ticket. ChangePolicyToString() function added.
[stg.git] / projects / sgconf / Makefile
1 ###############################################################################
2 # $Id: Makefile,v 1.21 2010/02/11 12:34:14 faust Exp $
3 ###############################################################################
4
5 include ../../Makefile.conf
6
7 PROG = sgconf
8
9 SRCS = ./main.cpp \
10        ./options.cpp \
11        ./api_action.cpp \
12        ./actions.cpp \
13        ./admins.cpp \
14        ./tariffs.cpp \
15        ./users.cpp \
16        ./services.cpp \
17        ./corps.cpp \
18        ./info.cpp \
19        ./xml.cpp
20
21 STGLIBS = srvconf \
22           crypto \
23           common
24
25 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
26 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
27
28 LIBS += $(addprefix -lstg,$(STGLIBS)) -lexpat $(LIB_THREAD)
29
30 ifeq ($(OS),linux)
31 else
32 LIBS += -lc \
33         -liconv
34 endif
35
36 SEARCH_DIRS = -I ../../include
37
38 ifeq ($(OS),bsd)
39 SEARCH_DIRS += -I/usr/local/include
40 CXXFLAGS += -DHAVE_DECL_GETOPT=1
41 endif
42
43 ifeq ($(OS),bsd5)
44 SEARCH_DIRS += -I/usr/local/include
45 CXXFLAGS += -DHAVE_DECL_GETOPT=1
46 endif
47
48 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
49
50 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
51 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
52 LDFLAGS += $(STGLIBS_LIBS)
53
54 ifneq ($(OS),darwin)
55 LDFLAGS += -Wl,-E
56 endif
57
58 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
59 all: libs $(PROG) ../../Makefile.conf
60
61 libs:
62         $(MAKE) -C $(DIR_LIBSRC)
63
64 $(PROG): $(OBJS)
65         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
66
67 clean:
68         rm -f deps $(PROG) *.o
69         $(MAKE) -C $(DIR_LIBSRC) clean
70
71 distclean: clean
72         rm -f ../../Makefile.conf
73
74 install: install-bin
75
76 install-bin:
77 ifeq ($(DEBUG), yes)
78         install -D -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/bin/$(PROG)
79 else
80         install -D -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/bin/$(PROG)
81 endif
82         $(MAKE) -C $(DIR_LIBSRC) install
83
84 uninstall: uninstall-bin
85
86 uninstall-bin:
87         rm -f $(PREFIX)/usr/sbin/$(PROG)
88
89
90 ifneq ($(MAKECMDGOALS),distclean)
91 ifneq ($(MAKECMDGOALS),clean)
92 ifneq ($(MAKECMDGOALS),uninstall)
93 -include deps
94 endif
95 endif
96 endif
97
98 deps: $(SRCS) ../../Makefile.conf
99         $(MAKE) -C $(DIR_LIBSRC)
100         @>deps ;\
101         for file in $(SRCS); do\
102           echo "$$file" | grep ".c$$" > /dev/null;\
103           if [ $$? -eq 0 ];\
104           then\
105             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
106             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
107           else\
108             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
109             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
110           fi;\
111         done