updated top-level README and version_decl for V4.4.2 (#1795)
[WRF.git] / external / io_grib_share / build / library_rules.mk
blob90dd34f4e4654a62932a974accc5d2ab1f7bb80d
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.
22 SHELL=/bin/sh
23 MAKE=make
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:
40 @s="$(SUB_DIRS)" ; \
41 if [ -z "$${s}" ]; then \
42 s="foobar" ;\
43 fi; \
44 for d in $$s ; do \
45 if [ "$$d" = "foobar" ]; then\
46 continue ;\
47 fi ; \
48 if [ ! -d "$$d" ]; then \
49 echo " Error: subdir $$d is NOT a directory!"; \
50 contiuue ;\
51 fi ; \
52 if [ ! -r "$$d/Makefile" ]; then\
53 echo " Error: subdir $$d does NOT contain a Makefile!"; \
54 continue ;\
55 fi ; \
56 echo " Doing make $@ on library subdirectory $$d" ;\
57 cd $$d ; \
58 $(MAKE) $@;\
59 cd ..; \
60 done; \
61 $(MAKE) thisdir_$@
63 clean_exe:
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 \
98 pwd = `pwd` ; \
99 cd $(LIB_DEST) ; \
100 echo " Creating tcl package index in $(MOD_DEST)" ;\
101 exec echo "pkg_mkIndex . \*Pkg.so \*.tcl" | tclsh;\
102 cd "$$(pwd)"; \
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.
113 utest: .FORCE
114 @if [ -d utest ] ; then \
115 echo "Making unit tests for `pwd`"; \
116 cd utest; \
117 make; \
118 cd ..; \
121 .FORCE:
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.
129 exe:
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
145 # object files.
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 \
151 cd utest; \
152 make clean; \
153 cd ..; \
156 thisdir_clean_lib:
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
167 # extensions.
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"; \
176 cd utest; \
177 $(MAKE) clean_depend; \
178 cd ..; \
181 thisdir_depend: generic_depend
182 @if [ -d utest ] ; then \
183 echo " Doing make depend on utest subdirectory"; \
184 cd utest; \
185 $(MAKE) depend; \
186 cd ..; \
189 include $(BUILD_DIR)/depend_rules.mk