Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / external / io_grib_share / build / package_rules.mk
blob632fb026402f27f9c2da65aa73cb94af6ffb02c8
1 #------------------------------------------------------------------------------
2 # Make rules for building and installing a 3rdparty package.
4 # This file is intended for use in Makefile via the include directive, e.g.
6 # include $(BUILD_DIR)/package_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, clean, install
15 # Copyright (C) 2001, WSI Corporation
16 #------------------------------------------------------------------------------
18 # For portability, use the Bourne shell within Makefiles.
19 # There have been problems using the C-shell under Linux.
21 SHELL=/bin/sh
24 # RULE for building a package.
26 # make all will decompress the package from a compressed tar file.
27 # If decompression is successful, the tar file will be removed.
29 # It will then configure, make, check, and install the package using the
30 # standard GNU mechanisms. It uses make -i to ignore errors.
32 # After the standard GNU make is complete, an executable called custom_build
33 # will be executed, if such a script is found in the same directory as the
34 # Makefile that includes these rules. The custom_build executable should
35 # accept the PACKAGE and INSTALLDIR as arguments.
37 # This relies on settings for the variables:
38 # BASEDIR - absolute path where Makefile resides.
39 # PACKAGE - directory relative to BASEDIR containing package to build.
40 # INSTALLDIR - directory relative to BASEDIR into which to install package.
42 all:
43 @if [ ! -d $(PACKAGE) ]; then \
44 if [ -e $(PACKAGE).tar.gz ]; then \
45 gunzip $(PACKAGE).tar.gz ; \
46 tar -xf $(PACKAGE).tar ; \
47 rm -f $(PACKAGE).tar ; \
48 fi ; \
49 fi ; \
50 if [ ! -d $(PACKAGE) ]; then \
51 echo "Could not find or successfully decompress package " $(PACKAGE) ;\
52 exit 1 ; \
53 fi ; \
54 if [ ! -d $(INSTALLDIR) ]; then \
55 mkdir $(INSTALLDIR) ; \
56 if [ ! -d $(INSTALLDIR) ]; then \
57 echo "Cannot create installation directory " $(INSTALLDIR) ;\
58 fi ; \
59 fi ; \
60 cd $(PACKAGE) ;\
61 sh ./configure --prefix=$(BASEDIR)/$(INSTALLDIR) ;\
62 make ;\
63 make check ;\
64 make install ;\
65 cd .. ;\
66 if [ -x ./custom_build ]; then \
67 ./custom_build $(PACKAGE) $(INSTALLDIR) ;\
68 fi;
71 # RULE for installing a package.
73 # This copies files from the packages install directory into the bin,
74 # lib, or src/3rdparty directories associated with a product source tree.
76 # Relies on proper setting of INSTALLDIR (explained above).
77 # Also relies on paths setup in buildrc.
79 install:
80 @cd $(INSTALLDIR) ; \
81 if [ -d bin ]; then \
82 cd bin ;\
83 echo " Installing executables in $(BIN_DEST)" ;\
84 for f in *; do \
85 if [ ! -d $$f ]; then \
86 echo " $$f"; \
87 cp $$f $(BIN_DEST) ;\
88 fi ;\
89 done ;\
90 cd .. ; \
91 fi; \
92 if [ -d lib ]; then \
93 cd lib ;\
94 echo " Installing libraries in $(LIB_DEST)" ;\
95 for f in *; do \
96 if [ ! -d $$f ]; then \
97 echo " $$f"; \
98 cp $$f $(LIB_DEST) ;\
99 fi ;\
100 done ;\
101 cd .. ; \
102 fi; \
103 if [ -d include ]; then \
104 cd include ;\
105 echo " Installing header files in $(THIRDPARTY_DIR)" ;\
106 for f in *; do \
107 if [ ! -d $$f ]; then \
108 echo " $$f"; \
109 cp $$f $(THIRDPARTY_DIR) ;\
110 fi ;\
111 done ;\
112 cd .. ; \
113 fi;
116 # RULE for cleaning up a package.
118 # make clean will do both the standard GNU make clean and make distclean rules.
119 # After that, it will tar and compress the package.
121 clean:
122 @if [ -d $(PACKAGE) ]; then \
123 cd $(PACKAGE) ;\
124 make clean;\
125 make distclean;\
126 cd ..;\
127 tar -cf $(PACKAGE).tar $(PACKAGE);\
128 rm -fr $(PACKAGE);\
129 gzip $(PACKAGE).tar ; \