@@ -58,14 +58,24 @@ echo "ReactOS."
5858echo
5959
6060if [ " $1 " = " -h" ] || [ " $1 " = " -?" ] || [ " $1 " = " --help" ]; then
61- echo " Syntax: ./RosBE-Builder.sh [installdir ]"
61+ echo " Syntax: ./RosBE-Builder.sh [prefixdir] [destdir ]"
6262 echo
63- echo " installdir - Optional parameter to specify an installation directory. If you"
64- echo " do this, the script will check whether this directory does not"
65- echo " yet exist and in this case, it will perform an unattended"
66- echo " installation to this directory."
63+ echo " prefixdir - Optional parameter to specify an prefix directory. This parameter"
64+ echo " will be passed to the tools' configuration as the argument of"
65+ echo " '--prefix'."
66+ echo " [default: '$DEFAULT_INSTALL_DIR ']"
67+ echo " destdir - Optional parameter to specify an destination directory as system"
68+ echo " root path to install ReactOS build environment. This parameter is"
69+ echo " only used when you want to build RosBE but not install it right"
70+ echo " away, e.g. for build a sofware package. For who want to install"
71+ echo " RosBE directly, just leave it as default."
72+ echo " [default: '/']"
6773 echo
68- echo " Usually, you just call the script without any parameters and it will guide you"
74+ echo " This script will check whether the '\$ destdir\$ prefixdir' does not yet exist"
75+ echo " and in this case, it will treat this directory as root path then perform an"
76+ echo " unattended installation to this directory."
77+ echo
78+ echo " Usually, you just call the script without any parameters and it will guide you"
6979 echo " through all possible installation options."
7080 exit 0
7181fi
@@ -80,35 +90,35 @@ update=false
8090rs_boldmsg " Installation Directory"
8191
8292if [ " $1 " = " " ]; then
83- installdir =" "
93+ prefixdir =" "
8494
8595 echo " In which directory do you want to install it?"
8696 echo " Enter the path to the directory here or simply press ENTER to install it into the default directory."
8797
88- while [ " $installdir " = " " ]; do
89- read -p " [$DEFAULT_INSTALL_DIR ] " installdir
98+ while [ " $prefixdir " = " " ]; do
99+ read -p " [$DEFAULT_INSTALL_DIR ] " prefixdir
90100 echo
91101
92- if [ " $installdir " = " " ]; then
93- installdir =$DEFAULT_INSTALL_DIR
102+ if [ " $prefixdir " = " " ]; then
103+ prefixdir =$DEFAULT_INSTALL_DIR
94104 fi
95105
96106 # Make sure we have the absolute path to the installation directory
97- installdir =` eval echo $installdir `
107+ prefixdir =` eval echo $prefixdir `
98108
99109 # Check if the installation directory already exists
100- if [ -f " $installdir " ]; then
101- echo " The directory \" $installdir \" is a file! Please enter another directory!"
110+ if [ -f " $prefixdir " ]; then
111+ echo " The directory \" $prefixdir \" is a file! Please enter another directory!"
102112 echo
103- installdir =" "
104- elif [ -d " $installdir " ]; then
113+ prefixdir =" "
114+ elif [ -d " $prefixdir " ]; then
105115 # Check if the directory is empty
106- if [ ! " ` ls $installdir ` " = " " ]; then
107- if [ -f " $installdir /RosBE-Version" ]; then
108- installed_version=` cat " $installdir /RosBE-Version" `
116+ if [ ! " ` ls $prefixdir ` " = " " ]; then
117+ if [ -f " $prefixdir /RosBE-Version" ]; then
118+ installed_version=` cat " $prefixdir /RosBE-Version" `
109119 echo " ReactOS Build Environment $installed_version is already installed in this directory."
110120 else
111- echo " The directory \" $installdir \" is not empty."
121+ echo " The directory \" $prefixdir \" is not empty."
112122 fi
113123
114124 echo " Do you want to remove this directory and install the new Build Environment into it? (yes/no)"
@@ -117,11 +127,11 @@ if [ "$1" = "" ]; then
117127
118128 if [[ " $answer " != [yY][eE][sS] ]]; then
119129 echo " Please enter another directory!"
120- installdir =" "
130+ prefixdir =" "
121131 fi
122132 fi
123133 else
124- echo " The directory \" $installdir \" does not exist. It will be created for you."
134+ echo " The directory \" $prefixdir \" does not exist. It will be created for you."
125135 echo
126136 fi
127137 done
@@ -133,17 +143,31 @@ if [ "$1" = "" ]; then
133143 echo " Press Return to continue or Ctrl+C to exit."
134144 read
135145else
136- installdir=` eval echo $1 `
137-
146+ prefixdir=` eval echo $1 `
147+ if [ -n " $2 " ]; then
148+ destdir=` eval echo $2 `
149+ fi
150+ installdir=" $destdir /$prefixdir "
138151 if [ -e " $installdir " ]; then
139152 rs_redmsg " Installation directory \" $installdir \" already exists, aborted!"
140153 exit 1
141154 fi
155+ fi
142156
143- echo " Using \" $installdir \" "
144- echo
157+ if [ -n " $destdir " ]; then
158+ rs_destdir=" $destdir "
159+ else
160+ rs_destdir=" /"
145161fi
146162
163+ rs_prefixdir=" $prefixdir "
164+ rs_installdir=" $destdir$prefixdir "
165+ rs_archprefixdir=" $prefixdir /$TARGET_ARCH "
166+ rs_archinstalldir=" $destdir$prefixdir /$TARGET_ARCH "
167+
168+ echo " configured prefix: \" $rs_prefixdir \" "
169+ echo " output directory: \" $rs_destdir \" "
170+
147171rs_process_binutils=true
148172rs_process_bison=true
149173rs_process_cmake=true
@@ -154,65 +178,64 @@ rs_process_mingw_w64=true
154178rs_process_ninja=true
155179rs_process_scut=true
156180
157- rm -rf " $installdir " || exit 1
158- mkdir -p " $installdir " || exit 1
159-
160- rs_prefixdir=" $installdir "
161- rs_archprefixdir=" $installdir /$TARGET_ARCH "
181+ rm -rf " $rs_installdir " || exit 1
182+ mkdir -p " $rs_installdir " || exit 1
162183
163184# #### BEGIN almost shared buildtoolchain/RosBE-Unix building part #############
164185rs_boldmsg " Building..."
165186
166- mkdir -p " $rs_prefixdir /bin"
167- mkdir -p " $rs_archprefixdir /$rs_target "
187+ mkdir -p " $rs_installdir /bin"
188+ mkdir -p " $rs_archinstalldir /$rs_target "
168189
169190echo " Using CFLAGS=\" $CFLAGS \" "
170191echo " Using CXXFLAGS=\" $CXXFLAGS \" "
171192echo
172193
173194if $rs_process_cpucount ; then
174- rs_do_command $CC $CFLAGS $LDFLAGS -s -o " $rs_prefixdir /bin/cpucount" " $rs_scriptdir /tools/cpucount.c"
195+ rs_do_command $CC $CFLAGS $LDFLAGS -s -o " $rs_installdir /bin/cpucount" " $rs_scriptdir /tools/cpucount.c"
175196fi
176197
177- rs_cpucount=` $rs_prefixdir /bin/cpucount -x1`
198+ rs_cpucount=` $rs_installdir /bin/cpucount -x1`
178199
179200if $rs_process_scut ; then
180- rs_do_command $CC $CFLAGS $LDFLAGS -s -o " $rs_prefixdir /bin/scut" " $rs_scriptdir /tools/scut.c"
201+ rs_do_command $CC $CFLAGS $LDFLAGS -s -o " $rs_installdir /bin/scut" " $rs_scriptdir /tools/scut.c"
181202fi
182203
183204if rs_prepare_module " bison" ; then
184205 rs_do_command ../bison/configure --prefix=" $rs_prefixdir " --disable-nls
185206 rs_do_command $rs_makecmd -j $rs_cpucount
186- rs_do_command $rs_makecmd install
207+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
187208 rs_clean_module " bison"
188209fi
189210
190211if rs_prepare_module " flex" ; then
191212 rs_do_command ../flex/configure --prefix=" $rs_prefixdir " --disable-nls
192213 rs_do_command $rs_makecmd -j $rs_cpucount
193- rs_do_command $rs_makecmd install
214+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
194215 rs_clean_module " flex"
195216fi
196217
197218if rs_prepare_module " cmake" ; then
198219 rs_do_command ../cmake/bootstrap --prefix=" $rs_prefixdir " --parallel=$rs_cpucount -- -DCMAKE_USE_OPENSSL=OFF
199220 rs_do_command $rs_makecmd -j $rs_cpucount
200- rs_do_command $rs_makecmd install
221+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
201222 rs_clean_module " cmake"
202223fi
203224
204225if rs_prepare_module " binutils" ; then
205- rs_do_command ../binutils/configure --prefix=" $rs_archprefixdir " --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
226+ rs_do_command ../binutils/configure --prefix=" $rs_archprefixdir " \
227+ --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " \
228+ --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
206229 rs_do_command $rs_makecmd -j $rs_cpucount
207- rs_do_command $rs_makecmd install
230+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
208231 rs_clean_module " binutils"
209232fi
210233
211234if rs_prepare_module " mingw_w64" ; then
212235 rs_do_command ../mingw_w64/mingw-w64-headers/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target "
213236 rs_do_command $rs_makecmd -j $rs_cpucount
214- rs_do_command $rs_makecmd install
215- rs_do_command ln -s -f $rs_archprefixdir / $ rs_target $rs_archprefixdir /mingw
237+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
238+ rs_do_command ln -s -f $rs_target $rs_archinstalldir /mingw
216239 rs_clean_module " mingw_w64"
217240fi
218241
@@ -225,26 +248,35 @@ if rs_prepare_module "gcc"; then
225248
226249 export CFLAGS_FOR_TARGET=" $rs_target_cflags "
227250 export CXXFLAGS_FOR_TARGET=" $rs_target_cxxflags "
228-
229- rs_do_command ../gcc/configure --prefix=" $rs_archprefixdir " --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " --with-pkgversion=" RosBE-Unix" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --enable-sjlj-exceptions --disable-libstdcxx-verbose
251+ export PATH=" $rs_archinstalldir /bin:$PATH "
252+
253+ rs_do_command ../gcc/configure --prefix=" $rs_archprefixdir " \
254+ --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " \
255+ --with-build-sysroot=" $rs_archinstalldir " \
256+ --with-pkgversion=" RosBE-Unix" --enable-languages=c,c++ \
257+ --enable-fully-dynamic-string --enable-version-specific-runtime-libs \
258+ --disable-shared --disable-multilib --disable-nls --disable-werror \
259+ --disable-win32-registry --enable-sjlj-exceptions --disable-libstdcxx-verbose
230260 rs_do_command $rs_makecmd -j $rs_cpucount all-gcc
231- rs_do_command $rs_makecmd install-gcc
232- rs_do_command $rs_makecmd install-lto-plugin
261+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install-gcc
262+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install-lto-plugin
233263
234264 if rs_prepare_module " mingw_w64" ; then
235- export AR=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ar"
236- export AS=" $rs_archprefixdir /bin/${rs_target_tool_prefix} as"
237- export CC=" $rs_archprefixdir /bin/${rs_target_tool_prefix} gcc"
265+ export AR=" $rs_archinstalldir /bin/${rs_target_tool_prefix} ar"
266+ export AS=" $rs_archinstalldir /bin/${rs_target_tool_prefix} as"
267+ export CC=" $rs_archinstalldir /bin/${rs_target_tool_prefix} gcc"
238268 export CFLAGS=" $rs_target_cflags "
239- export CXX=" $rs_archprefixdir /bin/${rs_target_tool_prefix} g++"
269+ export CXX=" $rs_archinstalldir /bin/${rs_target_tool_prefix} g++"
240270 export CXXFLAGS=" $rs_target_cxxflags "
241- export DLLTOOL=" $rs_archprefixdir /bin/${rs_target_tool_prefix} dlltool"
242- export RANLIB=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ranlib"
243- export STRIP=" $rs_archprefixdir /bin/${rs_target_tool_prefix} strip"
271+ export DLLTOOL=" $rs_archinstalldir /bin/${rs_target_tool_prefix} dlltool"
272+ export RANLIB=" $rs_archinstalldir /bin/${rs_target_tool_prefix} ranlib"
273+ export STRIP=" $rs_archinstalldir /bin/${rs_target_tool_prefix} strip"
244274
245- rs_do_command ../mingw_w64/mingw-w64-crt/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target " --with-sysroot=" $rs_archprefixdir "
275+ rs_do_command ../mingw_w64/mingw-w64-crt/configure \
276+ --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target " \
277+ --with-sysroot=" $rs_archprefixdir " --with-build-sysroot=" $rs_archinstalldir "
246278 rs_do_command $rs_makecmd -j $rs_cpucount
247- rs_do_command $rs_makecmd install
279+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
248280 rs_clean_module " mingw_w64"
249281
250282 unset AR
@@ -260,7 +292,7 @@ if rs_prepare_module "gcc"; then
260292
261293 cd " $rs_workdir /gcc-build"
262294 rs_do_command $rs_makecmd -j $rs_cpucount
263- rs_do_command $rs_makecmd install
295+ rs_do_command $rs_makecmd DESTDIR= " $rs_destdir " install
264296 rs_clean_module " gcc"
265297
266298 unset CFLAGS_FOR_TARGET
269301
270302if rs_prepare_module " ninja" ; then
271303 rs_do_command ../ninja/configure.py --bootstrap
272- rs_do_command install ninja " $rs_prefixdir /bin"
304+ rs_do_command install ninja " $rs_installdir /bin"
273305 rs_clean_module " ninja"
274306fi
275307
@@ -278,10 +310,10 @@ echo
278310rs_boldmsg " Final actions"
279311
280312echo " Removing unneeded files..."
281- cd " $rs_prefixdir "
313+ cd " $rs_installdir "
282314rm -rf doc man share/info share/man
283315
284- cd " $rs_archprefixdir "
316+ cd " $rs_archinstalldir "
285317rm -rf $rs_target /doc $rs_target /share include info man mingw share
286318rm -f lib/* >& /dev/null
287319# #### END almost shared buildtoolchain/RosBE-Unix building part ###############
@@ -290,7 +322,7 @@ rm -f lib/* >& /dev/null
290322osname=` uname`
291323if [ " $osname " != " Darwin" ]; then
292324 echo " Removing debugging symbols..."
293- cd " $rs_prefixdir "
325+ cd " $rs_installdir "
294326 for exe in ` find -executable -type f -print` ; do
295327 objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
296328 objcopy --strip-debug $exe 2> /dev/null
@@ -299,36 +331,38 @@ if [ "$osname" != "Darwin" ]; then
299331
300332 # Executables are created for the host system while most libraries are linked to target components
301333 for exe in ` find -name " *.a" -type f -print` ; do
302- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
303- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --strip-debug $exe 2> /dev/null
304- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
334+ $rs_archinstalldir /bin/${rs_target_tool_prefix} objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
335+ $rs_archinstalldir /bin/${rs_target_tool_prefix} objcopy --strip-debug $exe 2> /dev/null
336+ $rs_archinstalldir /bin/${rs_target_tool_prefix} objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
305337 done
306338
307339 for exe in ` find -name " *.o" -type f -print` ; do
308- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
309- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --strip-debug $exe 2> /dev/null
310- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
340+ $rs_archinstalldir /bin/${rs_target_tool_prefix} objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
341+ $rs_archinstalldir /bin/${rs_target_tool_prefix} objcopy --strip-debug $exe 2> /dev/null
342+ $rs_archinstalldir /bin/${rs_target_tool_prefix} objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
311343 done
312344fi
313345
314346echo " Copying scripts..."
315- cp -R " $rs_scriptdir /scripts/" * " $installdir "
347+ cp -R " $rs_scriptdir /scripts/" * " $rs_installdir "
316348
317349echo " Writing version..."
318- echo " $ROSBE_VERSION " > " $installdir /RosBE-Version"
350+ echo " $ROSBE_VERSION " > " $rs_installdir /RosBE-Version"
319351echo
320352
321353# Finish
322- rs_boldmsg " Finished successfully!"
323- echo " To create a shortcut to the Build Environment on the Desktop, please switch back to your"
324- echo " normal User Account (I assume you ran this script as \" root\" )."
325- echo " Then execute the following command:"
326- echo
327- echo " $installdir /createshortcut.sh"
328- echo
329- echo " If you just want to start the Build Environment without using a shortcut, execute the"
330- echo " following command:"
331- echo
332- echo " $installdir /RosBE.sh [source directory] [color code] [architecture]"
333- echo
334- echo " All parameters for that script are optional."
354+ if [ -z " $1 " ]; then # manually install
355+ rs_boldmsg " Finished successfully!"
356+ echo " To create a shortcut to the Build Environment on the Desktop, please switch back to your"
357+ echo " normal User Account (I assume you ran this script as \" root\" )."
358+ echo " Then execute the following command:"
359+ echo
360+ echo " $rs_prefixdir /createshortcut.sh"
361+ echo
362+ echo " If you just want to start the Build Environment without using a shortcut, execute the"
363+ echo " following command:"
364+ echo
365+ echo " $rs_prefixdir /RosBE.sh [source directory] [color code] [architecture]"
366+ echo
367+ echo " All parameters for that script are optional."
368+ fi
0 commit comments