-
Notifications
You must be signed in to change notification settings - Fork 16
/
fix.sh
executable file
·170 lines (150 loc) · 5.09 KB
/
fix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/sh
#
# Sets up the Allegro package for building with the specified compiler,
# and if possible converting text files to the desired target format.
#
proc_help()
{
echo
echo "Usage: $0 <platform> [--quick|--dtou|--utod|--utom|--mtou]"
echo
echo "Where platform is one of: bcc32, beos, djgpp, mingw, qnx, unix"
echo "mac, macosx, macosx-universal and watcom."
echo "The --quick parameter turns off text file conversion, --dtou converts from"
echo "DOS/Win32 format to Unix, --utod converts from Unix to DOS/Win32 format,"
echo "--utom converts from Unix to Macintosh format and --mtou converts from"
echo "Macintosh to Unix format. If no parameter is specified --quick is assumed."
echo
AL_NOCONV="1"
}
proc_fix()
{
echo "Configuring Allegro for $1 ..."
if [ "$2" != "none" ]; then
echo "# generated by fix.sh" > makefile
echo "MAKEFILE_INC = $2" >> makefile
echo "include makefile.all" >> makefile
fi
echo "/* generated by fix.sh */" > include/allegro/platform/alplatf.h
echo "#define $3" >> include/allegro/platform/alplatf.h
}
proc_fix_osx_ub()
{
echo "Configuring Allegro for Mac OSX Universal Binary ..."
echo "# generated by fix.sh" > makefile
echo "UB = 1" >> makefile
echo "MAKEFILE_INC = makefile.osx" >> makefile
echo "include makefile.all" >> makefile
echo "/* generated by fix.sh */" > include/allegro/platform/alplatf.h
echo "#define ALLEGRO_MACOSX" >> include/allegro/platform/alplatf.h
}
proc_filelist()
{
# common files.
AL_FILELIST=`find . -type f "(" ! -path "*/.*" ")" -a "(" \
-name "*.c" -o -name "*.cfg" -o -name "*.cpp" -o -name "*.def" -o \
-name "*.h" -o -name "*.hin" -o -name "*.in" -o -name "*.inc" -o \
-name "*.m" -o -name "*.m4" -o -name "*.mft" -o -name "*.s" -o \
-name "*.rc" -o -name "*.rh" -o -name "*.spec" -o -name "*.pl" -o \
-name "*.txt" -o -name "*._tx" -o -name "makefile*" -o \
-name "*.inl" -o -name "configure" -o -name "CHANGES" -o \
-name "AUTHORS" -o -name "THANKS" \
")"`
# touch unix shell scripts?
if [ "$1" != "omit_sh" ]; then
AL_FILELIST="$AL_FILELIST `find . -type f -name '*.sh'`"
fi
# touch DOS batch files?
if [ "$1" != "omit_bat" ]; then
AL_FILELIST="$AL_FILELIST `find . -type f -name '*.bat'`"
fi
}
proc_utod()
{
echo "Converting files from Unix to DOS/Win32 ..."
proc_filelist "omit_sh"
for file in $AL_FILELIST; do
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
unix2dos "$file"
else
echo "$file"
perl -p -e "s/([^\r]|^)\n/\1\r\n/" "$file" > _tmpfile
touch -r "$file" _tmpfile
mv _tmpfile "$file"
fi
done
}
proc_dtou()
{
echo "Converting files from DOS/Win32 to Unix ..."
proc_filelist "omit_bat"
for file in $AL_FILELIST; do
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
dos2unix "$file"
else
echo "$file"
mv "$file" _tmpfile
tr -d '\015' < _tmpfile > "$file"
touch -r _tmpfile "$file"
rm _tmpfile
fi
done
chmod +x *.sh misc/*.sh tools/x11/*.sh misc/*.pl
if [ -f configure ]; then
chmod +x configure
fi
}
proc_utom()
{
echo "Converting files from Unix to Macintosh ..."
proc_filelist "omit_sh"
for file in $AL_FILELIST; do
echo "$file"
mv "$file" _tmpfile
tr '\012' '\015' < _tmpfile > "$file"
touch -r _tmpfile "$file"
rm _tmpfile
done
}
proc_mtou()
{
echo "Converting files from Macintosh to Unix ..."
proc_filelist
for file in $AL_FILELIST; do
echo "$file"
mv "$file" _tmpfile
tr '\015' '\012' < _tmpfile > "$file"
touch -r _tmpfile "$file"
rm _tmpfile
done
}
# prepare allegro for the given platform.
case "$1" in
"bcc32" ) proc_fix "Windows (BCC32)" "makefile.bcc" "ALLEGRO_BCC32";;
"beos" ) proc_fix "BeOS" "makefile.be" "ALLEGRO_BEOS";;
"djgpp" ) proc_fix "DOS (djgpp)" "makefile.dj" "ALLEGRO_DJGPP";;
"mingw" ) proc_fix "Windows (MinGW)" "makefile.mgw" "ALLEGRO_MINGW32";;
"mingw32" ) proc_fix "Windows (MinGW)" "makefile.mgw" "ALLEGRO_MINGW32";;
# The 'msvc' target is undocumented in the help message, but is used
# during the release process by misc/zipup.sh.
"msvc" ) proc_fix "Windows (MSVC)" "makefile.vc" "ALLEGRO_MSVC";;
"qnx" ) proc_fix "QNX" "makefile.qnx" "ALLEGRO_QNX";;
"unix" ) proc_fix "Unix" "none" "ALLEGRO_UNIX";;
"mac" ) proc_fix "Mac" "none" "ALLEGRO_MPW";;
"macosx" ) proc_fix "MacOS X" "makefile.osx" "ALLEGRO_MACOSX";;
"macosx-universal" ) proc_fix_osx_ub ;;
"watcom" ) proc_fix "DOS (Watcom)" "makefile.wat" "ALLEGRO_WATCOM";;
"help" ) proc_help;;
* ) proc_help;;
esac
# convert all text-file line endings.
if [ "$AL_NOCONV" != "1" ]; then
case "$2" in
"--utod" ) proc_utod "$1";;
"--dtou" ) proc_dtou "$1";;
"--utom" ) proc_utom "$1";;
"--mtou" ) proc_mtou "$1";;
"--quick" ) echo "No text file conversion performed ...";;
esac
fi
echo "Done!"