1 | #------------------------------------------------------------------------------ |
---|
2 | # Make rules for installing 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)/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 | # Installation of library modules works in a similiar fashion, with the |
---|
35 | # variables MOD_SRC and MOD_EXT taking the place of EXE_SRC and EXE_EXT. |
---|
36 | # In addition, the Makefile *MUST* specify a destination directory for |
---|
37 | # installation. Typically, this is set to a subdirectory of BASE_DIR, |
---|
38 | # e.g. MOD_DEST = $(BASE_DIR)/perllib for perl modules. |
---|
39 | # |
---|
40 | # The EXE_SRC variable only needs to be set executable scripts need to be |
---|
41 | # built. Likewise MOD_SRC determines if script modules should be built. |
---|
42 | # The logic to set "src" to "invalid" is used to prevent shell errors |
---|
43 | # if either or both of these variables are not set. |
---|
44 | # |
---|
45 | # However, if MOD_SRC is set, MOD_DEST must also be set to the location |
---|
46 | # of a valid directory. The same is also true for EXE_SRC and BIN_DEST, |
---|
47 | # but BIN_DEST is properly set when the buildrc resource file is sourced. |
---|
48 | # |
---|
49 | all : exe lib config |
---|
50 | |
---|
51 | exe: |
---|
52 | @src="$(EXE_SRC)" ; \ |
---|
53 | if [ -z "$${src}" ]; then \ |
---|
54 | src="invalid" ;\ |
---|
55 | else if [ -z "$(BIN_DEST)" ]; then \ |
---|
56 | echo "Error: Binary installation directory BIN_DEST not set" 1>&2;\ |
---|
57 | src="invalid" ;\ |
---|
58 | else if [ ! -d "$(BIN_DEST)" ]; then \ |
---|
59 | echo "Error: BIN_DEST directory $(BIN_DEST) not found" 1>&2 ;\ |
---|
60 | src="invalid" ;\ |
---|
61 | fi; fi; fi; \ |
---|
62 | for s in $${src}; do \ |
---|
63 | if [ "$${s}" = "invalid" ]; then \ |
---|
64 | continue ; \ |
---|
65 | fi ; \ |
---|
66 | out=`echo $${s} | egrep '.*\.cgi'` > /dev/null 2>&1; \ |
---|
67 | if [ "$${out}" != "" ]; then \ |
---|
68 | e="$${s}" ; \ |
---|
69 | else \ |
---|
70 | e=`echo $$s | sed -e 's/\..*//'` ; \ |
---|
71 | fi ; \ |
---|
72 | echo " Installing $$e in $(BIN_DEST)" ; \ |
---|
73 | cp -f $$s $(BIN_DEST)/$$e ; \ |
---|
74 | chmod 555 $(BIN_DEST)/$$e ; \ |
---|
75 | done |
---|
76 | |
---|
77 | lib: |
---|
78 | @src="$(MOD_SRC)" ; \ |
---|
79 | if [ -z "$${src}" ]; then \ |
---|
80 | src="invalid" ;\ |
---|
81 | else if [ -z "$(MOD_DEST)" ]; then \ |
---|
82 | echo "Error: Module installation directory MOD_DEST not set" 1>&2;\ |
---|
83 | src="invalid" ;\ |
---|
84 | else if [ ! -d "$(MOD_DEST)" ]; then \ |
---|
85 | echo "Error: MOD_DEST directory $(MOD_DEST) not found" 1>&2 ;\ |
---|
86 | src="invalid" ;\ |
---|
87 | fi; fi; fi; \ |
---|
88 | for s in $${src}; do \ |
---|
89 | if [ "$${s}" = "invalid" ]; then \ |
---|
90 | continue;\ |
---|
91 | fi;\ |
---|
92 | e=`basename $$s $(MOD_EXT)` ; \ |
---|
93 | echo " Installing $$e in $(MOD_DEST)" ; \ |
---|
94 | cp -f $$s $(MOD_DEST)/$$e ; \ |
---|
95 | chmod 444 $(MOD_DEST)/$$e ; \ |
---|
96 | done |
---|
97 | |
---|
98 | # |
---|
99 | # Include rules for installation of configuration files. |
---|
100 | # |
---|
101 | include $(BUILD_DIR)/config_rules.mk |
---|
102 | |
---|
103 | # |
---|
104 | # RULES that are not implemented. |
---|
105 | # |
---|
106 | archive linked_lib: .FORCE |
---|
107 | @echo " make $@ is not implemented for script modules" 1>&2 |
---|
108 | |
---|
109 | # |
---|
110 | # RULE for building unit test programs. |
---|
111 | # |
---|
112 | utest: .FORCE |
---|
113 | @if [ -d utest ] ; then \ |
---|
114 | echo "Making unit tests for `pwd`"; \ |
---|
115 | cd utest; \ |
---|
116 | make; \ |
---|
117 | cd ..; \ |
---|
118 | fi |
---|
119 | |
---|
120 | .FORCE: |
---|
121 | |
---|
122 | # |
---|
123 | # RULES for cleaning up derived files. |
---|
124 | # |
---|
125 | # 'clean' removes any extraneous artifacts of producing script modules or |
---|
126 | # executables. make clean also removes files core files and backup |
---|
127 | # files. |
---|
128 | # |
---|
129 | # 'clean_lib' removes the installed libraries or modules |
---|
130 | # 'clean_exe' removes the installed executable scripts |
---|
131 | # |
---|
132 | # A subsequent make will recreate the shared library from the compiled |
---|
133 | # object files. |
---|
134 | # |
---|
135 | clean_exe: |
---|
136 | @src="$(EXE_SRC)" ; \ |
---|
137 | if [ -z "$${src}" ]; then \ |
---|
138 | src="invalid" ;\ |
---|
139 | else if [ -z "$(BIN_DEST)" ]; then \ |
---|
140 | echo "Error: Binary installation directory BIN_DEST not set" 1>&2;\ |
---|
141 | src="invalid" ;\ |
---|
142 | else if [ ! -d "$(BIN_DEST)" ]; then \ |
---|
143 | echo "Error: BIN_DEST directory $(BIN_DEST) not found" 1>&2 ;\ |
---|
144 | src="invalid" ;\ |
---|
145 | fi; fi; fi; \ |
---|
146 | for s in $${src}; do \ |
---|
147 | if [ "$${s}" = "invalid" ]; then \ |
---|
148 | continue ; \ |
---|
149 | fi ; \ |
---|
150 | e=`echo $$s | sed -e 's/\..*//'` ;\ |
---|
151 | echo " Removing $$e from $(BIN_DEST)" ; \ |
---|
152 | rm -f $(BIN_DEST)/$$e ; \ |
---|
153 | done |
---|
154 | |
---|
155 | clean_lib: |
---|
156 | @src="$(MOD_SRC)" ; \ |
---|
157 | if [ -z "$${src}" ]; then \ |
---|
158 | src="invalid" ;\ |
---|
159 | else if [ -z "$(MOD_DEST)" ]; then \ |
---|
160 | echo "Error: Module installation directory MOD_DEST not set" 1>&2;\ |
---|
161 | src="invalid" ;\ |
---|
162 | else if [ ! -d "$(MOD_DEST)" ]; then \ |
---|
163 | echo "Error: MOD_DEST directory $(MOD_DEST) not found" 1>&2 ;\ |
---|
164 | src="invalid" ;\ |
---|
165 | fi; fi; fi; \ |
---|
166 | for s in $${src}; do \ |
---|
167 | if [ "$${s}" = "invalid" ]; then \ |
---|
168 | continue ; \ |
---|
169 | fi ; \ |
---|
170 | e=`basename $$s $(MOD_EXT)` ; \ |
---|
171 | echo " Removing $$e from $(MOD_DEST)" ; \ |
---|
172 | rm -f $(MOD_DEST)/$$e ; \ |
---|
173 | done |
---|
174 | |
---|
175 | clean: |
---|
176 | @echo " Cleaning up script directory `pwd`" ;\ |
---|
177 | /bin/rm -f Makefile.bak core *~ #*# |
---|
178 | |
---|
179 | # |
---|
180 | # Rules for making dependencies. |
---|
181 | # These are not implemented for scripts, so the rules do nothing. |
---|
182 | # |
---|
183 | depend clean_depend: .FORCE |
---|
184 | @: |
---|
185 | |
---|
186 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
---|