]> git.stg.codes - stg.git/blob - projects/sgconf_xml/Makefile
Minor changes for Darwin.
[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
44 ifneq ($(OS),darwin)
45 LDFLAGS += -Wl,-E
46 endif
47
48 LDFLAGS += $(STGLIBS_LIBS)
49
50 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
51 all: libs $(PROG) ../../Makefile.conf
52
53 libs:
54         $(MAKE) -C $(DIR_LIBSRC)
55
56 $(PROG): $(OBJS)
57         $(CXX) $^ $(LIBS) $(LDFLAGS) -o $(PROG)
58
59 clean:
60         rm -f deps $(PROG) *.o tags *.*~ .OS
61         rm -f .OS
62         rm -f .store
63         rm -f .db.sql
64         rm -f core*
65         $(MAKE) -C $(DIR_LIBSRC) clean
66
67 distclean: clean
68         rm -f ../../Makefile.conf
69
70 install: install-bin install-data
71
72 install-bin:
73 ifeq ($(DEBUG), yes)
74         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/sbin
75         install -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/sbin/$(PROG)
76 else
77         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/sbin
78         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
79 endif
80         $(MAKE) -C $(DIR_LIBSRC) install
81
82 uninstall: uninstall-bin uninstall-data
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