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