1 | #------------------------------------------------------------------------------ |
---|
2 | # Make rules for building and installing a 3rdparty package. |
---|
3 | # |
---|
4 | # This file is intended for use in Makefile via the include directive, e.g. |
---|
5 | # |
---|
6 | # include $(BUILD_DIR)/package_rules.mk |
---|
7 | # |
---|
8 | # It is assumed that the environment has been set by sourcing the build |
---|
9 | # resource file (buildrc). |
---|
10 | # |
---|
11 | # This file defines the following rules for library modules: |
---|
12 | # |
---|
13 | # all, clean, install |
---|
14 | # |
---|
15 | # Copyright (C) 2001, WSI Corporation |
---|
16 | #------------------------------------------------------------------------------ |
---|
17 | # |
---|
18 | # For portability, use the Bourne shell within Makefiles. |
---|
19 | # There have been problems using the C-shell under Linux. |
---|
20 | # |
---|
21 | SHELL=/bin/sh |
---|
22 | |
---|
23 | # |
---|
24 | # RULE for building a package. |
---|
25 | # |
---|
26 | # make all will decompress the package from a compressed tar file. |
---|
27 | # If decompression is successful, the tar file will be removed. |
---|
28 | # |
---|
29 | # It will then configure, make, check, and install the package using the |
---|
30 | # standard GNU mechanisms. It uses make -i to ignore errors. |
---|
31 | # |
---|
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. |
---|
36 | # |
---|
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. |
---|
41 | # |
---|
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; |
---|
69 | |
---|
70 | # |
---|
71 | # RULE for installing a package. |
---|
72 | # |
---|
73 | # This copies files from the packages install directory into the bin, |
---|
74 | # lib, or src/3rdparty directories associated with a product source tree. |
---|
75 | # |
---|
76 | # Relies on proper setting of INSTALLDIR (explained above). |
---|
77 | # Also relies on paths setup in buildrc. |
---|
78 | # |
---|
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; |
---|
114 | |
---|
115 | # |
---|
116 | # RULE for cleaning up a package. |
---|
117 | # |
---|
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. |
---|
120 | # |
---|
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 ; \ |
---|
130 | fi; |
---|
131 | |
---|