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