merge standard release WRF/WPS V3.0.1.1 into wrffire
[wrffire.git] / wrfv2_fire / external / io_grib_share / build / library_rules.mk
blobeaf9c24309e44fc258923f848e77e85a1e0aa057
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 *.mod *.f90 core so_locations Makefile.bak *~ #*#
149 @/bin/rm -fr ii_files
150 @if [ -d utest ] ; then \
151 echo " Doing make clean on utest subdirectory"; \
152 cd utest; \
153 make clean; \
154 cd ..; \
157 thisdir_clean_lib:
158 @/bin/rm -f $(LIB_DEST)/lib$(LIB_NAME).*
161 # RULES for creating the include dependencies.
163 # 'depend' creates the dependencies and appends them to the end of this file.
164 # Depend uses some customized logic to determine the name of the source
165 # code file associated with each object file in OBJS. This means that we
166 # can mix source code extensions in the same library (e.g. use C and C++
167 # source interchangeably). See compile_rules.mk for supported file name
168 # extensions.
170 # 'clean_depend' removes the dependencies from this file, which makes the
171 # Makefile much smaller. make clean_depend should be done before
172 # checking a Makefile into revision control.
174 thisdir_clean_depend: generic_clean_depend
175 @if [ -d utest ] ; then \
176 echo " Doing make clean_depend on utest subdirectory"; \
177 cd utest; \
178 $(MAKE) clean_depend; \
179 cd ..; \
182 thisdir_depend: generic_depend
183 @if [ -d utest ] ; then \
184 echo " Doing make depend on utest subdirectory"; \
185 cd utest; \
186 $(MAKE) depend; \
187 cd ..; \
190 include $(BUILD_DIR)/depend_rules.mk