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