1 | #------------------------------------------------------------------------------ |
---|
2 | # Make rules for installing tcl scripts and script-modules. |
---|
3 | # |
---|
4 | # This file is intended for use in Makefile via the include directive, e.g. |
---|
5 | # |
---|
6 | # include $(BUILD_DIR)/tcl_script_rules.mk |
---|
7 | # |
---|
8 | # It is assumed that the environment has been set by sourcing the build |
---|
9 | # resource file (buildrc). |
---|
10 | # |
---|
11 | # This file defines the following rules for library modules: |
---|
12 | # |
---|
13 | # all, lib, archive, linked_lib, utest, exe, clean, clean_lib, clean_exe, |
---|
14 | # clean_depend, depend. |
---|
15 | # |
---|
16 | # Copyright (C) 2002, WSI Corporation |
---|
17 | #------------------------------------------------------------------------------ |
---|
18 | # |
---|
19 | # For portability, use the Bourne shell within Makefiles. |
---|
20 | # There have been problems using the C-shell under Linux. |
---|
21 | # |
---|
22 | SHELL=/bin/sh |
---|
23 | |
---|
24 | # |
---|
25 | # RULES for installing scripts and script modules |
---|
26 | # |
---|
27 | # EXE_SRC specifies a list of files that contain executable scripts. |
---|
28 | # Each file in the list will be installed in the $(BIN_DEST) directory |
---|
29 | # and will be given executable permissions. If the variable EXE_EXT is |
---|
30 | # set, this extension will be stripped from the end of the source file |
---|
31 | # when it is installed, e.g. if EXE_SRC = "foo.pl" and EXE_EXT = ".pl", |
---|
32 | # the executable installed in BIN_DEST will be named "foo". |
---|
33 | # |
---|
34 | # For tcl packages, MOD_SRC specifies a list of files that contain the |
---|
35 | # source code that will make up the package. MOD_NAME specifies the |
---|
36 | # file name for the package (this is typically the module name with a |
---|
37 | # ".tcl" extension). In addition, the Makefile *MUST* specify a |
---|
38 | # destination directory for installation. Typically, this is set to a |
---|
39 | # subdirectory of BASE_DIR, e.g. MOD_DEST = $(BASE_DIR)/perllib for perl |
---|
40 | # modules. |
---|
41 | # |
---|
42 | # The EXE_SRC variable only needs to be set executable scripts need to be |
---|
43 | # built. Likewise MOD_SRC determines if script modules should be built. |
---|
44 | # The logic to set "src" to "invalid" is used to prevent shell errors |
---|
45 | # if either or both of these variables are not set. |
---|
46 | # |
---|
47 | # However, if MOD_SRC is set, MOD_DEST must also be set to the location |
---|
48 | # of a valid directory. The same is also true for EXE_SRC and BIN_DEST, |
---|
49 | # but BIN_DEST is properly set when the buildrc resource file is sourced. |
---|
50 | # |
---|
51 | all : exe lib config |
---|
52 | |
---|
53 | exe: |
---|
54 | @src="$(EXE_SRC)" ; \ |
---|
55 | if [ -z "$${src}" ]; then \ |
---|
56 | src="invalid" ;\ |
---|
57 | else if [ -z "$(BIN_DEST)" ]; then \ |
---|
58 | echo "Error: Binary installation directory BIN_DEST not set" 1>&2;\ |
---|
59 | src="invalid" ;\ |
---|
60 | else if [ ! -d "$(BIN_DEST)" ]; then \ |
---|
61 | echo "Error: BIN_DEST directory $(BIN_DEST) not found" 1>&2 ;\ |
---|
62 | src="invalid" ;\ |
---|
63 | fi; fi; fi; \ |
---|
64 | for s in $${src}; do \ |
---|
65 | if [ "$${s}" = "invalid" ]; then \ |
---|
66 | continue ; \ |
---|
67 | fi ; \ |
---|
68 | e=`echo $$s | sed -e 's/\..*//'` ;\ |
---|
69 | echo " Installing $$e in $(BIN_DEST)" ; \ |
---|
70 | cp -f $$s $(BIN_DEST)/$$e ; \ |
---|
71 | chmod 555 $(BIN_DEST)/$$e ; \ |
---|
72 | done |
---|
73 | |
---|
74 | lib: |
---|
75 | @src="$(MOD_SRC)" ; \ |
---|
76 | if [ -z "$${src}" ]; then \ |
---|
77 | src="invalid" ;\ |
---|
78 | else if [ -z "$(MOD_DEST)" ]; then \ |
---|
79 | echo "Error: Module installation directory MOD_DEST not set" 1>&2;\ |
---|
80 | src="invalid" ;\ |
---|
81 | else if [ ! -d "$(MOD_DEST)" ]; then \ |
---|
82 | echo "Error: MOD_DEST directory $(MOD_DEST) not found" 1>&2 ;\ |
---|
83 | src="invalid" ;\ |
---|
84 | fi; fi; fi; \ |
---|
85 | pwd=`pwd` ; \ |
---|
86 | if [ -f $(MOD_DEST)/$(MOD_NAME) ]; then \ |
---|
87 | echo " Removing $(MOD_DEST)/$(MOD_NAME)"; \ |
---|
88 | rm -f $(MOD_DEST)/$(MOD_NAME); \ |
---|
89 | fi; \ |
---|
90 | for s in $${src}; do \ |
---|
91 | if [ "$${s}" = "invalid" ]; then \ |
---|
92 | continue;\ |
---|
93 | fi;\ |
---|
94 | echo " Appending $$s to $(MOD_DEST)/$(MOD_NAME)" ; \ |
---|
95 | cat $$s >> $(MOD_DEST)/$(MOD_NAME) ; \ |
---|
96 | if [ $$? != 0 ]; then \ |
---|
97 | echo "Error with cat $$s"; \ |
---|
98 | fi; \ |
---|
99 | ext=`echo $$s | sed -e 's/.*\.//'` ;\ |
---|
100 | done; \ |
---|
101 | chmod 444 $(MOD_DEST)/$(MOD_NAME) ; \ |
---|
102 | cd $(MOD_DEST) ; \ |
---|
103 | echo " Creating tcl package index in $(MOD_DEST)" ;\ |
---|
104 | exec echo "pkg_mkIndex . \*Pkg.so \*.tcl" | tclsh;\ |
---|
105 | cd "$$(pwd)" |
---|
106 | |
---|
107 | # |
---|
108 | # Include rules for installation of configuration files. |
---|
109 | # |
---|
110 | include $(BUILD_DIR)/config_rules.mk |
---|
111 | |
---|
112 | # |
---|
113 | # RULES that are not implemented. |
---|
114 | # |
---|
115 | archive linked_lib: .FORCE |
---|
116 | @echo " make $@ is not implemented for script modules" 1>&2 |
---|
117 | |
---|
118 | # |
---|
119 | # RULE for building unit test programs. |
---|
120 | # |
---|
121 | utest: .FORCE |
---|
122 | @if [ -d utest ] ; then \ |
---|
123 | echo "Making unit tests for `pwd`"; \ |
---|
124 | cd utest; \ |
---|
125 | make; \ |
---|
126 | cd ..; \ |
---|
127 | fi |
---|
128 | |
---|
129 | .FORCE: |
---|
130 | |
---|
131 | # |
---|
132 | # RULES for cleaning up derived files. |
---|
133 | # |
---|
134 | # 'clean' removes any extraneous artifacts of producing script modules or |
---|
135 | # executables. make clean also removes files core files and backup |
---|
136 | # files. |
---|
137 | # |
---|
138 | # 'clean_lib' removes the installed libraries or modules |
---|
139 | # 'clean_exe' removes the installed executable scripts |
---|
140 | # |
---|
141 | # A subsequent make will recreate the shared library from the compiled |
---|
142 | # object files. |
---|
143 | # |
---|
144 | clean_exe: |
---|
145 | @src="$(EXE_SRC)" ; \ |
---|
146 | if [ -z "$${src}" ]; then \ |
---|
147 | src="invalid" ;\ |
---|
148 | else if [ -z "$(BIN_DEST)" ]; then \ |
---|
149 | echo "Error: Binary installation directory BIN_DEST not set" 1>&2;\ |
---|
150 | src="invalid" ;\ |
---|
151 | else if [ ! -d "$(BIN_DEST)" ]; then \ |
---|
152 | echo "Error: BIN_DEST directory $(BIN_DEST) not found" 1>&2 ;\ |
---|
153 | src="invalid" ;\ |
---|
154 | fi; fi; fi; \ |
---|
155 | for s in $${src}; do \ |
---|
156 | if [ "$${s}" = "invalid" ]; then \ |
---|
157 | continue ; \ |
---|
158 | fi ; \ |
---|
159 | e=`echo $$s | sed -e 's/\..*//'` ;\ |
---|
160 | echo " Removing $$e from $(BIN_DEST)" ; \ |
---|
161 | rm -f $(BIN_DEST)/$$e ; \ |
---|
162 | done |
---|
163 | |
---|
164 | clean_lib: |
---|
165 | @name="$(MOD_NAME)" ; \ |
---|
166 | if [ -z "$${src}" ]; then \ |
---|
167 | src="invalid" ;\ |
---|
168 | else if [ -z "$(MOD_DEST)" ]; then \ |
---|
169 | echo "Error: Module installation directory MOD_DEST not set" 1>&2;\ |
---|
170 | src="invalid" ;\ |
---|
171 | else if [ ! -d "$(MOD_DEST)" ]; then \ |
---|
172 | echo "Error: MOD_DEST directory $(MOD_DEST) not found" 1>&2 ;\ |
---|
173 | src="invalid" ;\ |
---|
174 | fi; fi; fi; \ |
---|
175 | for s in $${name}; do \ |
---|
176 | if [ "$${s}" = "invalid" ]; then \ |
---|
177 | continue ; \ |
---|
178 | fi ; \ |
---|
179 | e=`basename $$s $(MOD_EXT)` ; \ |
---|
180 | echo " Removing $$e from $(MOD_DEST)" ; \ |
---|
181 | rm -f $(MOD_DEST)/$$e ; \ |
---|
182 | done |
---|
183 | |
---|
184 | clean: |
---|
185 | @echo " Cleaning up script directory `pwd`" ;\ |
---|
186 | /bin/rm -f Makefile.bak core *~ #*# |
---|
187 | |
---|
188 | # |
---|
189 | # Rules for making dependencies. |
---|
190 | # These are not implemented for scripts, so the rules do nothing. |
---|
191 | # |
---|
192 | depend clean_depend: .FORCE |
---|
193 | @: |
---|
194 | |
---|
195 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
---|