]> git.stg.codes - stg.git/blob - projects/rscriptd/Makefile
eq/neq fixes.
[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           crypto \
17           common
18
19 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
20 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
21
22 LIBS += $(addprefix -lstg,$(STGLIBS)) $(LIB_THREAD)
23
24 ifeq ($(OS),linux)
25 D_FLAG = -D
26 else
27 LIBS += -liconv
28 D_FLAG = -d
29 endif
30
31 SEARCH_DIRS = -I ../../include
32
33 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
34
35 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
36 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
37
38 ifneq ($(OS),darwin)
39 LDFLAGS += -Wl,-E
40 endif
41
42 LDFLAGS += $(STGLIBS_LIBS)
43
44 .PHONY: all clean distclean libs install uninstall
45 all: libs $(PROG) ../../Makefile.conf
46
47 libs:
48         $(MAKE) -C $(DIR_LIBSRC)
49
50 $(PROG): $(OBJS)
51         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
52
53 clean:
54         rm -f deps $(PROG) *.o tags *.*~ .OS
55         rm -f .OS
56         rm -f .store
57         rm -f .db.sql
58         rm -f core*
59         $(MAKE) -C $(DIR_LIBSRC) clean
60
61 distclean: clean
62         rm -f ../../Makefile.conf
63
64 install: install-bin install-data
65
66 install-bin:
67 ifeq ($(DEBUG), yes)
68         install $(D_FLAG) -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/sbin/$(PROG)
69 else
70         install $(D_FLAG) -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
71 endif
72         $(MAKE) -C $(DIR_LIBSRC) install
73
74 install-data:
75         # Install etc
76         mkdir -m $(DIR_MODE) -p $(PREFIX)/etc/rscriptd
77         install -m $(DATA_MODE) -o $(OWNER) ./rscriptd.conf $(PREFIX)/etc/rscriptd/rscriptd.conf
78 ifeq ($(OS), linux)
79         install $(D_FLAG) -m $(BIN_MODE) -o $(OWNER) ../stargazer/inst/linux/etc/stargazer/OnConnect $(PREFIX)/etc/rscriptd/
80         install $(D_FLAG) -m $(BIN_MODE) -o $(OWNER) ../stargazer/inst/linux/etc/stargazer/OnDisconnect $(PREFIX)/etc/rscriptd/
81 else
82         install $(D_FLAG) -m $(BIN_MODE) -o $(OWNER) ../stargazer/inst/freebsd/etc/stargazer/OnConnect $(PREFIX)/etc/rscriptd/
83         install $(D_FLAG) -m $(BIN_MODE) -o $(OWNER) ../stargazer/inst/freebsd/etc/stargazer/OnDisconnect $(PREFIX)/etc/rscriptd/
84 endif
85
86 uninstall: uninstall-bin uninstall-data
87
88 uninstall-bin:
89         rm -f $(PREFIX)/usr/sbin/$(PROG)
90
91 uninstall-data:
92         # Uninstall etc
93         rm -f $(PREFIX)/etc/rscriptd/rscriptd.conf
94         rm -f $(PREFIX)/etc/rscriptd/OnConnect
95         rm -f $(PREFIX)/etc/rscriptd/OnDisconnect
96
97 ifneq ($(MAKECMDGOALS),distclean)
98 ifneq ($(MAKECMDGOALS),clean)
99 ifneq ($(MAKECMDGOALS),uninstall)
100 -include deps
101 endif
102 endif
103 endif
104
105 deps:   $(SRCS) ../../Makefile.conf
106         $(MAKE) -C $(DIR_LIBSRC)
107         @>deps ;\
108         for file in $(SRCS); do\
109           echo "$$file" | grep ".c$$" > /dev/null;\
110           if [ $$? -eq 0 ];\
111           then\
112             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
113             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
114           else\
115             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
116             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
117           fi;\
118         done