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