1 #------------------------------------------------------------------------------
2 # Make rules for installing tcl scripts and script-modules.
4 # This file is intended for use in Makefile via the include directive, e.g.
6 # include $(BUILD_DIR)/tcl_script_rules.mk
8 # It is assumed that the environment has been set by sourcing the build
9 # resource file (buildrc).
11 # This file defines the following rules for library modules:
13 # all, lib, archive, linked_lib, utest, exe, clean, clean_lib, clean_exe,
14 # clean_depend, depend.
16 # Copyright (C) 2002, WSI Corporation
17 #------------------------------------------------------------------------------
19 # For portability, use the Bourne shell within Makefiles.
20 # There have been problems using the C-shell under Linux.
25 # RULES for installing scripts and script modules
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".
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
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.
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.
55 if
[ -z
"$${src}" ]; then \
57 else if
[ -z
"$(BIN_DEST)" ]; then \
58 echo
"Error: Binary installation directory BIN_DEST not set" 1>&2;\
60 else if
[ ! -d
"$(BIN_DEST)" ]; then \
61 echo
"Error: BIN_DEST directory $(BIN_DEST) not found" 1>&2 ;\
64 for s in
$${src}; do \
65 if
[ "$${s}" = "invalid" ]; then \
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 ; \
76 if
[ -z
"$${src}" ]; then \
78 else if
[ -z
"$(MOD_DEST)" ]; then \
79 echo
"Error: Module installation directory MOD_DEST not set" 1>&2;\
81 else if
[ ! -d
"$(MOD_DEST)" ]; then \
82 echo
"Error: MOD_DEST directory $(MOD_DEST) not found" 1>&2 ;\
86 if
[ -f
$(MOD_DEST
)/$(MOD_NAME
) ]; then \
87 echo
" Removing $(MOD_DEST)/$(MOD_NAME)"; \
88 rm -f
$(MOD_DEST
)/$(MOD_NAME
); \
90 for s in
$${src}; do \
91 if
[ "$${s}" = "invalid" ]; then \
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"; \
99 ext
=`echo $$s | sed -e 's/.*\.//'` ;\
101 chmod
444 $(MOD_DEST
)/$(MOD_NAME
) ; \
103 echo
" Creating tcl package index in $(MOD_DEST)" ;\
104 exec echo
"pkg_mkIndex . \*Pkg.so \*.tcl" | tclsh
;\
108 # Include rules for installation of configuration files.
110 include $(BUILD_DIR
)/config_rules.mk
113 # RULES that are not implemented.
115 archive linked_lib
: .FORCE
116 @echo
" make $@ is not implemented for script modules" 1>&2
119 # RULE for building unit test programs.
122 @if
[ -d utest
] ; then \
123 echo
"Making unit tests for `pwd`"; \
132 # RULES for cleaning up derived files.
134 # 'clean' removes any extraneous artifacts of producing script modules or
135 # executables. make clean also removes files core files and backup
138 # 'clean_lib' removes the installed libraries or modules
139 # 'clean_exe' removes the installed executable scripts
141 # A subsequent make will recreate the shared library from the compiled
145 @src
="$(EXE_SRC)" ; \
146 if
[ -z
"$${src}" ]; then \
148 else if
[ -z
"$(BIN_DEST)" ]; then \
149 echo
"Error: Binary installation directory BIN_DEST not set" 1>&2;\
151 else if
[ ! -d
"$(BIN_DEST)" ]; then \
152 echo
"Error: BIN_DEST directory $(BIN_DEST) not found" 1>&2 ;\
155 for s in
$${src}; do \
156 if
[ "$${s}" = "invalid" ]; then \
159 e
=`echo $$s | sed -e 's/\..*//'` ;\
160 echo
" Removing $$e from $(BIN_DEST)" ; \
161 rm -f
$(BIN_DEST
)/$$e ; \
165 @name
="$(MOD_NAME)" ; \
166 if
[ -z
"$${src}" ]; then \
168 else if
[ -z
"$(MOD_DEST)" ]; then \
169 echo
"Error: Module installation directory MOD_DEST not set" 1>&2;\
171 else if
[ ! -d
"$(MOD_DEST)" ]; then \
172 echo
"Error: MOD_DEST directory $(MOD_DEST) not found" 1>&2 ;\
175 for s in
$${name}; do \
176 if
[ "$${s}" = "invalid" ]; then \
179 e
=`basename $$s $(MOD_EXT)` ; \
180 echo
" Removing $$e from $(MOD_DEST)" ; \
181 rm -f
$(MOD_DEST
)/$$e ; \
185 @echo
" Cleaning up script directory `pwd`" ;\
186 /bin
/rm -f Makefile.bak core
*~
#*#
189 # Rules for making dependencies.
190 # These are not implemented for scripts, so the rules do nothing.
192 depend clean_depend
: .FORCE
195 # DO NOT DELETE THIS LINE -- make depend depends on it.