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