]> git.stg.codes - stg.git/blob - projects/rscriptd/Makefile
Fix libs order (for --as-needed)
[stg.git] / projects / rscriptd / Makefile
1 ###############################################################################
2 # $Id: Makefile,v 1.18 2010/02/11 12:22:01 faust Exp $
3 ###############################################################################
4
5 include ../../Makefile.conf
6
7 PROG = rscriptd
8
9 SRCS = ./main.cpp \
10        ./listener.cpp \
11        ./pidfile.cpp
12
13 STGLIBS = scriptexecuter \
14           conffiles \
15           logger \
16           locker \
17           crypto \
18           common
19
20 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
21 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
22
23 LIBS += $(addprefix -lstg,$(STGLIBS)) $(LIB_THREAD)
24
25 ifneq ($(OS),linux)
26 LIBS += -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 install uninstall
38 all: libs $(PROG) ../../Makefile.conf
39
40 libs:
41         $(MAKE) -C $(DIR_LIBSRC)
42
43 $(PROG): $(OBJS)
44         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
45
46 clean:
47         rm -f deps $(PROG) *.o tags *.*~ .OS
48         rm -f .OS
49         rm -f .store
50         rm -f .db.sql
51         rm -f core*
52         $(MAKE) -C $(DIR_LIBSRC) clean
53
54 distclean: clean
55         rm -f ../../Makefile.conf
56
57 install: install-bin install-data
58
59 install-bin:
60         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
61         $(MAKE) -C $(DIR_LIBSRC) install
62
63 install-data:
64         # Install etc
65         mkdir -m $(DIR_MODE) -p $(PREFIX)/etc/stargazer
66         install -m $(DATA_MODE) -o $(OWNER) ./rscriptd.conf $(PREFIX)/etc/stargazer/rscriptd.conf
67
68 uninstall: uninstall-bin uninstall-data
69
70 uninstall-bin:
71         rm -f $(PREFIX)/usr/sbin/$(PROG)
72
73 uninstall-data:
74         # Uninstall etc
75         rm -f $(PREFIX)/etc/stragazer/rscriptd.conf
76
77
78 ifneq ($(MAKECMDGOALS),distclean)
79 ifneq ($(MAKECMDGOALS),clean)
80 ifneq ($(MAKECMDGOALS),uninstall)
81 -include deps
82 endif
83 endif
84 endif
85
86 deps:   $(SRCS) ../../Makefile.conf
87         $(MAKE) -C $(DIR_LIBSRC)
88         @>deps ;\
89         for file in $(SRCS); do\
90           echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
91           echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
92         done