1 #!/bin/zsh
2
3 BUILD_ROOT=$(pwd)
4 BUILD_DIR=$BUILD_ROOT/build
5 BUILD_INSTALL=$BUILD_ROOT/install
6
7 LIB_DIR=$BUILD_INSTALL/lib
8
9 export PKG_CONFIG_PATH=$BUILD_INSTALL/lib/pkgconfig:$BUILD_INSTALL/share/pkgconfig
10
11 rm -Rf $BUILD_DIR
12 rm -Rf $BUILD_INSTALL
13
14 src=(
15 "https://www.x.org/releases/individual/proto/xcb-proto-1.17.0.tar.gz"
16 "https://www.x.org/releases/individual/xcb/libpthread-stubs-0.5.tar.gz"
17 "https://www.x.org/releases/individual/proto/xproto-7.0.31.tar.bz2"
18 "https://www.x.org/releases/individual/lib/libXau-1.0.11.tar.gz"
19 "https://www.x.org/releases/individual/lib/libXdmcp-1.1.5.tar.gz"
20 "https://www.x.org/releases/individual/lib/libxcb-1.17.0.tar.gz"
21 "https://www.x.org/releases/individual/proto/xextproto-7.3.0.tar.bz2"
22 "https://www.x.org/releases/individual/lib/xtrans-1.5.2.tar.gz"
23 "https://www.x.org/releases/individual/proto/kbproto-1.0.7.tar.bz2"
24 "https://www.x.org/releases/individual/proto/inputproto-2.3.tar.bz2"
25 "https://www.x.org/releases/individual/lib/libX11-1.8.tar.gz"
26 "https://www.x.org/releases/individual/proto/renderproto-0.11.tar.bz2"
27 "https://www.x.org/releases/individual/lib/libXrender-0.9.11.tar.gz"
28 "https://www.zlib.net/zlib-1.3.1.tar.gz"
29 "https://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-1.6.34.tar.gz"
30 "https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.gz"
31 "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.15.0.tar.gz"
32 "https://www.x.org/releases/individual/lib/libXft-2.3.8.tar.gz"
33 "https://www.x.org/releases/individual/lib/libICE-1.1.1.tar.gz"
34 "https://www.x.org/releases/individual/lib/libSM-1.2.4.tar.gz"
35 "https://www.x.org/releases/individual/lib/libXt-1.3.1.tar.gz"
36 "https://www.x.org/releases/individual/lib/libXext-1.3.6.tar.gz"
37 "https://www.x.org/releases/individual/lib/libXmu-1.2.1.tar.gz"
38 "https://www.x.org/releases/individual/data/xbitmaps-1.1.3.tar.gz"
39 )
40
41 src_motif="https://pkg.unixwork.de/src/motif-2.3.8.tar.gz"
42
43 mkdir -p $BUILD_DIR
44
45 echo "enter build dir $BUILD_DIR"
46 echo
47 cd $BUILD_DIR
48
49 for url in "${src[@]}"; do
50 echo "------------------------------------------------------"
51 echo
52 echo "## download $url"
53 curl -L -O $url
54
55 dlfile=$(basename $url)
56 dirname=${dlfile%.tar.*}
57 tar xvfz $dlfile
58
59 echo
60 echo "##enter $BUILD_DIR/$dirname"
61 cd $dirname
62 if [ $? -ne 0 ]; then
63 echo "abort"
64 exit 1
65 fi
66
67 echo "### build $dirname"
68
69 ./configure --prefix=$BUILD_INSTALL --sysconfdir=/tmp/xnedit/etc --localstatedir=/tmp/xnedit/var
70 if [ $? -ne 0 ]; then
71 echo "abort"
72 exit 1
73 fi
74
75 make
76 if [ $? -ne 0 ]; then
77 echo "abort"
78 exit 1
79 fi
80
81 make install
82 if [ $? -ne 0 ]; then
83 echo "abort"
84 exit 1
85 fi
86
87 echo
88 echo "## leave $BUILD_DIR/$dirname"
89 cd ..
90 done
91
92
93 echo
94 echo "build motif"
95 echo "------------------------------------------------------"
96 echo
97
98 curl -L -O $src_motif
99 dlfile=$(basename $src_motif)
100 dirname=${dlfile%.tar.*}
101 tar xvfz $dlfile
102
103 cd $dirname
104
105 # apply patches
106 echo "## apply patches"
107 for file in ../../patches/*; do
108 patch -p1 < $file
109 done
110 echo "## build"
111
112
113 # compile motif
114
115 ./configure --prefix=$BUILD_INSTALL
116 if [ $? -ne 0 ]; then
117 echo "abort"
118 exit 1
119 fi
120
121 make
122 if [ $? -ne 0 ]; then
123 echo "abort"
124 exit 1
125 fi
126
127 make install
128 if [ $? -ne 0 ]; then
129 echo "abort"
130 exit 1
131 fi
132
133 echo
134 echo "update dylib IDs"
135 echo "------------------------------------------------------"
136 echo
137
138 for file in $(find $LIB_DIR -path "*.dylib" -type f); do
139 id=$(otool -L $file | sed '2q;d' | awk '{print $1}')
140 newid=${id/$LIB_DIR/@rpath}
141 echo install_name_tool -id $newid $file
142 install_name_tool -id $newid $file
143 if [ $? -ne 0 ]; then
144 echo "abort"
145 exit 1
146 fi
147
148 for dylib in $(otool -L $file | sed 1,2d | awk '{print $1}' | grep $LIB_DIR); do
149 echo install_name_tool -change $dylib ${dylib/$LIB_DIR/@rpath} $file
150 install_name_tool -change $dylib ${dylib/$LIB_DIR/@rpath} $file
151 if [ $? -ne 0 ]; then
152 echo "abort"
153 exit 1
154 fi
155 done
156 done
157
158