-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (141 loc) · 4.76 KB
/
Makefile
File metadata and controls
165 lines (141 loc) · 4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
TOP_DIR = $(KB_TOP)
include tools/Makefile.common
#MODULE_DIRS = $(wildcard modules/*)
#MODULES = $(notdir $(MODULE_DIRS))
MODULES = $(shell $(TOOLS_DIR)/module-order modules)
MODULE_DIRS = $(foreach mod,$(MODULES),modules/$(mod))
#
# Default deplyment target. May be overridden to deploy to an alternative location.
#
TARGET = /kb/deployment
DEPLOY_RUNTIME = /kb/runtime
all: build_modules
what:
@echo dirs $(MODULE_DIRS)
@echo modules $(MODULES)
deploy-setup: deploy-dirs deploy-user-env
deploy-dirs:
-mkdir $(TARGET)
-mkdir $(TARGET)/bin
-mkdir $(TARGET)/lib
-mkdir $(TARGET)/plbin
-mkdir $(TARGET)/pybin
-mkdir $(TARGET)/rsbin
-mkdir $(TARGET)/shbin
-mkdir $(TARGET)/services
# make the necessary deployment directories
# loop over each module and call its make deploy
# create a user-env.sh and put it in the deployment
# location (TARGET)
deploy: deploy-setup
for m in $(MODULE_DIRS); do \
if [ -d $$m ] ; then \
(cd $$m; make deploy TARGET=$(TARGET) DEPLOY_RUNTIME=$(DEPLOY_RUNTIME) ); \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
# make the necessary deployment directories
# loop over each module and call its make deploy
# create a user-env.sh and put it in the deployment
# location (TARGET)
deploy-client: deploy-setup
for m in $(MODULE_DIRS); do \
if [ -d $$m ] ; then \
(cd $$m; make deploy-client TARGET=$(TARGET) DEPLOY_RUNTIME=$(DEPLOY_RUNTIME) ); \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
# make the necessary deployment directories
# loop over each module and call its make deploy
# create a user-env.sh and put it in the deployment
# location (TARGET)
deploy-all: deploy-setup
for m in $(MODULE_DIRS); do \
if [ -d $$m ] ; then \
(cd $$m; make deploy-all TARGET=$(TARGET) DEPLOY_RUNTIME=$(DEPLOY_RUNTIME) ); \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
deploy-user-env:
-mkdir $(TARGET)
dest=$(TARGET)/user-env.sh; \
q='"'; \
echo "export KB_TOP=$$q$(TARGET)$$q" > $$dest; \
echo "export KB_RUNTIME=$$q$(DEPLOY_RUNTIME)$$q" >> $$dest; \
echo "export KB_PERL_PATH=$$q$(TARGET)/lib$$q" >> $$dest; \
echo "export PERL5LIB=\$$KB_PERL_PATH:\$$KB_PERL_PATH/perl5" >> $$dest; \
echo "export PYTHONPATH=$$q\$$KB_PERL_PATH:\$$PYTHONPATH$$q" >> $$dest; \
echo "export R_LIBS=$$q\$$KB_PERL_PATH:\$$KB_R_PATH$$q" >> $$dest; \
echo "export JAVA_HOME=$$q\$$KB_RUNTIME/java$$q" >> $$dest; \
echo "export CATALINA_HOME=$$q\$$KB_RUNTIME/tomcat$$q" >> $$dest; \
echo "export PATH=$$q\$$JAVA_HOME/bin:\$$KB_TOP/bin:\$$KB_RUNTIME/bin:\$$PATH$$q" >> $$dest;
dest=$(TARGET)/user-env.csh; \
q='"'; \
echo "setenv KB_TOP $$q$(TARGET)$$q" > $$dest; \
echo "setenv KB_RUNTIME $$q$(DEPLOY_RUNTIME)$$q" >> $$dest; \
echo "setenv KB_PERL_PATH $$q$(TARGET)/lib$$q" >> $$dest; \
echo "setenv PERL5LIB \$${KB_PERL_PATH}:\$$KB_PERL_PATH/perl5" >> $$dest; \
echo "if (\$$?PYTHONPATH) then" >> $$dest; \
echo " setenv PYTHONPATH $$q\$${KB_PERL_PATH}:\$$PYTHONPATH$$q" >> $$dest; \
echo "else" >> $$dest; \
echo " setenv PYTHONPATH $$q\$${KB_PERL_PATH}$$q" >> $$dest; \
echo "endif" >> $$dest; \
echo "if (\$$?KB_R_PATH) then" >> $$dest; \
echo " setenv R_LIBS $$q\$${KB_PERL_PATH}:\$$KB_R_PATH$$q" >> $$dest; \
echo "else" >> $$dest; \
echo " setenv R_LIBS $$q\$${KB_PERL_PATH}$$q" >> $$dest; \
echo "endif" >> $$dest; \
echo "setenv JAVA_HOME $$q\$$KB_RUNTIME/java$$q" >> $$dest; \
echo "setenv CATALINA_HOME $$q\$$KB_RUNTIME/tomcat$$q" >> $$dest; \
echo "setenv PATH $$q\$$JAVA_HOME/bin:\$$KB_TOP/bin:\$$KB_RUNTIME/bin:\$$PATH$$q" >> $$dest;
dest=$(TARGET)/service-env.sh ; \
q='"'; \
echo "source $(TARGET)/user-env.sh;" > $$dest; \
echo "for i in $(TARGET)/services/*/bin; do" >> $$dest; \
echo " export PATH=$q\$${PATH}:\$$i$q;" >> $$dest; \
echo "done" >> $$dest
dest=$(TARGET)/service-env.csh ; \
q='"'; \
echo "source $(TARGET)/user-env.csh;" > $$dest; \
echo "foreach i ($(TARGET)/services/*/bin)" >> $$dest; \
echo " setenv PATH $q\$${PATH}:\$$i$q;" >> $$dest; \
echo "end" >> $$dest
# this is called by the default target (make with no target provided)
# the modules will be deployed in the dev_container
# make the necessary directoris
# loop over each module and call its make file with no target (default target)
build_modules:
if [ ! -d bin ] ; then mkdir bin ; fi
for m in $(MODULE_DIRS); do \
if [ -d $$m ] ; then \
echo "Build $$m" ; \
(cd $$m; make ) ; \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
test:
# foreach module in modules, call make test on that module
for m in $(MODULE_DIRS); do \
if [ -d $$m ] ; then \
(cd $$m; make test DEPLOY_RUNTIME=$(DEPLOY_RUNTIME) ) ; \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
clean:
rm -rf $(TARGET)
realclean:
-rm -rf $(TARGET)
-rm -rf modules/*
-rm -rf bin
-rm runtime
-rm user-env.*