1 #------------------------------------------------------------------------------
2 # Make rules for producing a library module.
4 # This file is intended for use in Makefile via the include directive, e.g.
6 # include $(BUILD_DIR)/library_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,
14 # clean_depend, depend.
16 # Copyright (C) 2001, WSI Corporation
17 #------------------------------------------------------------------------------
19 # For portability, use the Bourne shell within Makefiles.
20 # There have been problems using the C-shell under Linux.
26 # RULES that can be passed through to subdirectories.
28 # Each of these rules executes the rule on this directory, then executes
29 # the same rule on each subdirectory specified in SUB_DIRS.
31 # The rules for this directory are specified as thisdir_<rulename> in
32 # this file, e.g. "thisdir_all" implements "make all" for this directory.
34 # The SUB_DIRS variable only needs to be set if building of subdirectories
35 # is desired. In this case, the list of subdirectories ($$s) is set to the
36 # no-op value of "foobar" to prevent the shell for seeing errors in the
37 # subsequent for loop when SUB_DIRS is not set.
39 all lib archive linked_lib
clean depend clean_depend clean_lib
:
41 if
[ -z
"$${s}" ]; then \
45 if
[ "$$d" = "foobar" ]; then\
48 if
[ ! -d
"$$d" ]; then \
49 echo
" Error: subdir $$d is NOT a directory!"; \
52 if
[ ! -r
"$$d/Makefile" ]; then\
53 echo
" Error: subdir $$d does NOT contain a Makefile!"; \
56 echo
" Doing make $@ on library subdirectory $$d" ;\
64 @echo
"make clean_exe does nothing for library modules"
66 thisdir_all
: thisdir_linked_lib config
69 # Include the RULES for compilation and installing config files
71 include $(BUILD_DIR
)/compile_rules.mk
72 include $(BUILD_DIR
)/config_rules.mk
75 # RULES for building a library.
77 # - 'lib' builds the library as a shared library.
78 # - 'archive' builds the library as an archive library.
79 # - 'linked_lib' builds the library as a shared library (if necessary), and
80 # links the shared library to its dependent libraries.
81 # - Specific library names are built depending on the update status of the
82 # library of the same name installed in $(LIB_DEST).
83 # - Libraries are built depending on the status of its object files (OBJS)
85 # NOTE: Shared libraries are linked against the libraries upon which they
86 # depend. This is not possible with archive libraries.
88 thisdir_lib
: lib
$(LIB_NAME
).
$(LIB_EXT
)
90 lib
$(LIB_NAME
).
$(LIB_EXT
): $(LIB_DEST
)/lib
$(LIB_NAME
).
$(LIB_EXT
)
92 $(LIB_DEST
)/lib
$(LIB_NAME
).
$(LIB_EXT
): $(OBJS
)
93 $(CXX
) $(LIB_FLAGS
) -o
$@
$(OBJS
)
95 thisdir_linked_lib
: $(OBJS
)
96 $(CXX
) $(LIB_FLAGS
) -o
$(LIB_DEST
)/lib
$(LIB_NAME
).
$(LIB_EXT
) $(OBJS
) $(DEP_LIBS
)
97 @if
[ `echo $(LIB_NAME) | grep Pkg` ] ; then \
100 echo
" Creating tcl package index in $(MOD_DEST)" ;\
101 exec echo
"pkg_mkIndex . \*Pkg.so \*.tcl" | tclsh
;\
105 thisdir_archive
: $(OBJS
) .FORCE
106 $(AR
) $(ARFLAGS
) $(LIB_DEST
)/lib
$(LIB_NAME
).a
$(OBJS
)
107 $(RANLIB
) $(LIB_DEST
)/lib
$(LIB_NAME
).a
110 # RULE for building unit test programs.
114 @if
[ -d utest
] ; then \
115 echo
"Making unit tests for `pwd`"; \
124 # RULE for building an executable.
126 # For library modules, these do nothing, but we define one so that make exe
127 # can be passed down to all source directories.
130 @echo
"make exe does nothing for library modules"
133 # RULES for cleaning up derived files.
135 # 'clean' removes all objects produced by this file, as well as other
136 # extraneous artifacts of compiling and building libraries.
138 # A subsequent make will both recompile the source code and recreate
139 # the shared library. clean also removes files core files and other
140 # auxilliary files created during compilation.
142 # 'clean_lib' removes only the libraries, both shared and archive.
144 # A subsequent make will recreate the shared library from the compiled
147 thisdir_clean
: thisdir_clean_lib
148 @
/bin
/rm -f
*.o
*.obj
*.mod
*.f90 core so_locations Makefile.bak
*~
#*#
149 @
/bin
/rm -fr ii_files
150 @if
[ -d utest
] ; then \
157 @
/bin
/rm -f
$(LIB_DEST
)/lib
$(LIB_NAME
).
*
160 # RULES for creating the include dependencies.
162 # 'depend' creates the dependencies and appends them to the end of this file.
163 # Depend uses some customized logic to determine the name of the source
164 # code file associated with each object file in OBJS. This means that we
165 # can mix source code extensions in the same library (e.g. use C and C++
166 # source interchangeably). See compile_rules.mk for supported file name
169 # 'clean_depend' removes the dependencies from this file, which makes the
170 # Makefile much smaller. make clean_depend should be done before
171 # checking a Makefile into revision control.
173 thisdir_clean_depend
: generic_clean_depend
174 @if
[ -d utest
] ; then \
175 echo
" Doing make clean_depend on utest subdirectory"; \
177 $(MAKE
) clean_depend
; \
181 thisdir_depend
: generic_depend
182 @if
[ -d utest
] ; then \
183 echo
" Doing make depend on utest subdirectory"; \
189 include $(BUILD_DIR
)/depend_rules.mk