Updated to Chris's latest cbuild.

SVN r22 (trunk)
This commit is contained in:
Randy Heit 2006-04-09 19:39:07 +00:00
parent 16c085e146
commit 810ebcb31d
2 changed files with 3116 additions and 1164 deletions

3730
cbuild.c

File diff suppressed because it is too large Load diff

View file

@ -1,224 +1,382 @@
do ifopt help
echo Available options are:
echo . debug - Build debug instead of release
echo . verbose - Show system commands instead of decorated messages
echo . clean - Clean temp files (use with debug to clean debug files)
echo . zdoom.wad - (Re)build just zdoom.wad, even if it already exists
echo .
echo To use with MinGW, compile cbuild.c into an executable using:
echo gcc -O2 -W -Wall -Werror -o cbuild.exe cbuild.c
echo .
echo Or if you have a sh-compatible shell, you can run the cbuild.c file
echo directly or have it automatically compile itself with GCC by passing
echo --make-compiled
echo .
exit 0
done
# Example cbuild script file, which can be used to build itself with GCC.
# Note: This is a comparitively simple example, and in no way showcases
# CBuild's extensive capabilities. For more in-depth information, please see
# the AWiki entry at <http://awiki.tomasu.org/bin/view/Main/CBUILD>
# Here's the main script. All commands are case in-sensitive.
# Everything past the first '#' character in a line is ignored. To put a '#'
# character in a line, escape it like '\#', or put it in quotes.
# Use ${var} to dereference the environment variable 'var', and $(cmd) to
# replace text using sub-command 'cmd'.
# &#xxxx; will give you the character the given number value represents, in
# UTF-8 (ie. &#169; or &#0xA9; will give you the copyright symbol on a UTF-8
# compatible console). In addition, the standard HTML entity names are also
# valid (ie. &copy; will also give you the copyright symbol).
# 'Ifopt' will check if the following word was passed on the command line, and execute the
# rest of the line if so. The reverse, 'ifnopt', also exists.
# All whitespace between a command and its option(s) are eaten by the parser.
# You can use 'echo' to print a line to the console. Use 'put' to print a
# line without a trailing newline
echo "CBuild &copy; 2006"
echo ""
# 'ifopt' checks the command line for the specified option. The rest of the
# line will only be processed if it was passed. Whitespace between the option
# name and next command is ignored. If the command line opt has a =, it will
# be treated as an opt=val pair and only the portion before the = needs to
# match.
# 'verbose' causes cbuild to display the commands being run for a number of
# commands, in place of the cleaner, more readable output.
ifopt verbose verbose 1
ifopt debug CONFIG = Debug
# VAR?=foo will only set the var if it's unset. Note that if you want spaces, put '' or ""
# quotes around the value. VAR+=foo will append foo to the very end of the existing var.
# And, VAR-=foo will remove all occurences of foo from the var.
CONFIG ?= Release
OPTLEVEL ?= 2
ARCH_TYPE ?= pentium
TUNE_TYPE ?= athlon-xp
RELEASETARGET ?= zdoomgcc
DEBUGTARGET ?= zdoomgccd
DEBUGOBJDIR = debugobj
RELEASEOBJDIR = releaseobj
CPPFLAGS = "-DHAVE_FILELENGTH -D__forceinline=inline -Izlib -IFLAC -Isrc -Isrc/sdl -Isrc/g_doom -Isrc/g_heretic -Isrc/g_hexen -Isrc/g_raven -Isrc/g_strife -Isrc/g_shared -Isrc/oplsynth -Isrc/sound"
LDFLAGS = "-lFLAC++ -lFLAC -lz -lfmod `sdl-config --libs`"
CFLAGS = "`sdl-config --cflags` "
# To keep the main directory clean, it's usually best to put the temporary
# object and dependancy files into subdirectories. Changing the variables
# OBJ_DIR and DEP_DIR will do just this.
do ifopt debug
OBJDIR = "${DEBUGOBJDIR}"
CFLAGS += "-Wall -Wno-unused -g3"
CPPFLAGS += " -D_DEBUG"
CXXFLAGS = "${CFLAGS}"
TARGET = "${DEBUGTARGET}"
else
OBJDIR = "${RELEASEOBJDIR}"
CFLAGS += "-march=${ARCH_TYPE} -mtune=${TUNE_TYPE} -Wall -Wno-unused -O${OPTLEVEL} -fomit-frame-pointer"
CPPFLAGS += " -DNDEBUG"
CXXFLAGS = "${CFLAGS}"
LDFLAGS += " -Wl,-Map=zdoomgcc.map"
TARGET = "${RELEASETARGET}"
OBJ_DIR = obj
DEP_DIR = dep
# The 'do' command allows cbuild to execute a block if the following if-type
# check passes. End the block with 'done' or use 'else' (which can also be
# followed by an if-type command) to make another block to run if the initial
# check failed. Indentation is unimportant.
do ifopt help
echo "
CBuild - a platform-independant build system using (mostly) ANSI C.
Available options:
verbose - Enable more verbose command printing
clean - Clean a previously compiled build
--install path - Installs the optimized executable to the specified path
--disable-gui - Disables using the GUI for installation on some platforms
help - Display this help message
For advanced scripting information, please see CBuild's AWiki entry at
<http://awiki.tomasu.org/bin/view/Main/CBUILD>
To report bugs, please email me at <kcat@strangesoft.net> or
<chris.kcat@gmail.com>.
"
# 'exit' returns from the script, and cbuild will return with the specified
# number as the exit code
exit 0
done
ifnplat win32 CPPFLAGS += " -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp"
# This is where the object and dependancy files go when compiled
OBJ_DIR = "${OBJDIR}"
DEP_DIR = "${OBJDIR}"
# 'goto' jumps to the specified label (prepended with ':') which can be ahead
# of or behind the current line.
do ifnopt clean
EVILCLEAN = 0
ifnexist "${OBJ_DIR}" mkdir "${OBJ_DIR}"
ifopt clean goto clean
ifopt zdoom.wad goto makewad
do if "${NOASM}"=""
# 'Loadlist' stores a list of words, and 'execlist' executes a command on each one,
# replacing <@> with the word. Unfortuantely this doesn't do dependancy checking.
loadlist 'a' 'blocks' 'misc' 'tmap' 'tmap2' 'tmap3'
do ifplat win32 execlist nasmw -o "${OBJ_DIR}/<@>${OBJ_EXT}" -f win32 "src/<@>.nas"
else ifplat unix execlist nasm -o "${OBJ_DIR}/<@>${OBJ_EXT}" -f elf -DM_TARGET_LINUX "src/<@>.nas"
else
echo .
echo Unsupported platform!
echo .
exit 1
done
CPPFLAGS = "-DUSEASM ${CPPFLAGS}"
else
CPPFLAGS = "-DNOASM ${CPPFLAGS}"
done
# Here we set some standard optimizing C flags. This only persists until
# another line is encountered that sets them differently. You can use ?=
# instead of = to set a variable only if its not already set. If you wish
# to start with spaces, encapsulate the value in ''s or ""s, or escape
# the first whitespace character with \
# Set the compile and link commands. 'Compile' will compile the list of sourcefiles and
# store their names until another Compile is encountered (if you wish to add to a previous
# list, use 'Compileadd').
#
# C sources are compiled with:
# ${CC} ${CPPFLAGS} ${CFLAGS} ${DEP_OPT}${DEP_DIR}/file-sans-ext${DEP_EXT} ${OUT_OPT}${OBJ_DIR}/file-sans-ext${OBJ_EXT} ${SRC_OPT}detected-source-path/file-with-ext
#
# and for C++ sources:
# ${CXX} ${CPPFLAGS} ${CXXFLAGS} ${DEP_OPT}${DEP_DIR}/file-sans-ext${DEP_EXT} ${OUT_OPT}${OBJ_DIR}/file-sans-ext${OBJ_EXT} ${SRC_OPT}detected-source-path/file-with-ext
#
# A source file will not be compiled if the object file exists and is newer than the source.
# Or if the associated dependancy file exists, all of the object's dependancies are older
# than the object.
#
# If DEP_OPT is unset, the whole DEP_* section will be removed from the command line. Files
# with unknown extensions are silently ignored (but will still be passed to Linkexec with
# their name "object-ified").
#
# 'Linkexec' executes:
# ${LD} ${OUT_OPT}file${EXE_EXT} <list of objects previously compiled> ${LDFLAGS}
#
# It will not link if the target executable exists and is newer than all of the objects it's
# linking with.
CFLAGS ?= "-O2 -W -Wall"
COMPILE = Compile
LINK = Linkexec
# This is where it can find the sources.
src_paths src src/g_doom src/g_heretic src/g_hexen src/g_raven src/g_strife $
src/g_shared src/oplsynth src/sound src/sdl
# Create the object and dependancy file directories. 'ifnexist' will run the
# following command if the specified file or directory doesn't exist. Testing
# "name/." will make sure "name" is actually a directory.
ifnexist "${OBJ_DIR}/." mkdir ${OBJ_DIR}
ifnexist "${DEP_DIR}/." mkdir ${DEP_DIR}
# There be a lot of funky magic in here. Only advanced users will want to worry
# about this.
define dialog 'noop'
define dcop 'noop'
do ifnopt --disable-gui
# Locate dcop and make sure it's running. Also, look for kdialog.
DCOP = $(*which dcop)
do ifnot ${'DCOP'}=''
@!call ${'DCOP'} >/dev/null
do ifret 0
DIALOG = $(*which kdialog)
if ${'DIALOG'}='' DCOP = ''
else
DCOP = ''
done
done
# If KDE's not available, bail out and go console-only
if ${'DCOP'}='' goto build_it
# Make sure we can write to a temporary file, where kdialog's talkback will
# be stored.
do ifnwrite /tmp/cbtmpxyz.txt
do ifnwrite /tmp/.
@!call ${'DIALOG'} --title "\"CBuild install error\"" --error "\"Unable to write to /tmp/cbtmpxyz.txt!
Install aborted!\"" 2>/dev/null
DCOP = ''
DIALOG = ''
goto build_it
done
done
# Set up a 4-part progress bar. The dcop reference will be stored in a temp
# file
@!call ${'DIALOG'} --title \"Building CBuild\" --progressbar \"Building CBuild, please wait...\" 4 >/tmp/cbtmpxyz.txt 2>/dev/null
ifnret 0 goto build_it
# Read in from the temp file
setinput /tmp/cbtmpxyz.txt
read DCOP_REF
# If reading failed, alert the user and continue without the GUI
do ifnret 0
@!call ${'DIALOG'} --title "\"CBuild install error\"" --warning "\"Unable to read DCOP reference from /tmp/cbtmpxyz.txt!\"" 2>/dev/null
DCOP = ''
DIALOG = ''
setinput
goto build_it
done
# Restore normal input and delete the temp file
setinput
@-rm /tmp/cbtmpxyz.txt
define dialog @!call \'${'DIALOG'}\' '"${@}"' >/tmp/cbtmpxyz.txt 2>/dev/null
define dcop @!call \'${'DCOP'}\' '\'${\'DCOP_REF\'}\'' '"${@}"' 2>/dev/null
# Setup an exit command, to make sure the progress bar is removed on exit
define atexit_dcop dclop close
else
# Override the compile and link commands with rmobj and rmexec. A quick way to delete
# the objects and executables while dealing with only one list. No, rmobj will not
# delete the specified source file, but rather the object and dependancy files that would
# result from compiling the specified source.
EVILCLEAN = 1
COMPILE = -rmobj
LINK = -rmexec
DCOP = ''
done
${COMPILE} autostart.cpp a.nas blocks.nas misc.nas tmap.nas tmap2.nas tmap3.nas $
am_map.cpp b_bot.cpp b_func.cpp b_game.cpp b_move.cpp b_think.cpp bbannouncer.cpp $
c_bind.cpp c_cmds.cpp c_console.cpp c_cvars.cpp c_dispatch.cpp c_expr.cpp $
cmdlib.cpp colormatcher.cpp configfile.cpp ct_chat.cpp d_dehacked.cpp d_main.cpp $
d_net.cpp d_netinfo.cpp d_protocol.cpp decallib.cpp decorations.cpp dobject.cpp $
doomdef.cpp doomstat.cpp dsectoreffect.cpp dthinker.cpp empty.cpp f_finale.cpp $
f_wipe.cpp farchive.cpp files.cpp g_game.cpp g_level.cpp gameconfigfile.cpp $
gi.cpp hu_scores.cpp info.cpp infodefaults.cpp lumpconfigfile.cpp m_alloc.cpp $
m_argv.cpp m_bbox.cpp m_cheat.cpp m_fixed.cpp m_menu.cpp m_misc.cpp m_options.cpp $
m_png.cpp m_random.cpp mus2midi.cpp nodebuild.cpp nodebuild_events.cpp $
nodebuild_extract.cpp nodebuild_gl.cpp nodebuild_utility.cpp p_acs.cpp $
p_buildmap.cpp p_ceiling.cpp p_conversation.cpp p_doors.cpp p_effect.cpp $
p_enemy.cpp p_floor.cpp p_interaction.cpp p_lights.cpp p_lnspec.cpp p_map.cpp $
p_maputl.cpp p_mobj.cpp p_pillar.cpp p_plats.cpp p_pspr.cpp p_saveg.cpp $
p_sectors.cpp p_setup.cpp p_sight.cpp p_spec.cpp p_switch.cpp p_teleport.cpp $
p_terrain.cpp p_things.cpp p_tick.cpp p_trace.cpp p_user.cpp p_writemap.cpp $
p_xlat.cpp po_man.cpp r_bsp.cpp r_data.cpp r_draw.cpp r_drawt.cpp r_main.cpp $
r_plane.cpp r_segs.cpp r_sky.cpp r_things.cpp r_polymost.cpp s_advsound.cpp $
s_environment.cpp s_playlist.cpp s_sndseq.cpp s_sound.cpp sc_man.cpp skins.cpp $
st_stuff.cpp stats.cpp stringtable.cpp tables.cpp tempfiles.cpp thingdef.cpp thingdef_codeptr.cpp $
v_collection.cpp v_draw.cpp v_font.cpp v_palette.cpp v_pfx.cpp v_text.cpp $
v_video.cpp vectors.cpp name.cpp zstring.cpp zstringpool.cpp zstrformat.cpp $
w_wad.cpp wi_stuff.cpp a_arachnotron.cpp a_archvile.cpp a_bossbrain.cpp $
a_bruiser.cpp a_cacodemon.cpp a_cyberdemon.cpp a_demon.cpp $
a_doomarmor.cpp a_doomartifacts.cpp a_doomdecorations.cpp a_doomhealth.cpp $
a_doomimp.cpp a_doomkeys.cpp a_doommisc.cpp a_doomplayer.cpp a_doomweaps.cpp $
a_fatso.cpp a_keen.cpp a_lostsoul.cpp a_painelemental.cpp a_possessed.cpp $
a_revenant.cpp a_scriptedmarine.cpp a_spidermaster.cpp doom_sbar.cpp a_beast.cpp $
a_chicken.cpp a_clink.cpp a_dsparil.cpp a_hereticambience.cpp a_hereticarmor.cpp $
a_hereticartifacts.cpp a_hereticdecorations.cpp a_hereticimp.cpp a_heretickeys.cpp $
a_hereticmisc.cpp a_hereticplayer.cpp a_hereticweaps.cpp a_ironlich.cpp $
a_knight.cpp a_mummy.cpp a_snake.cpp a_wizard.cpp heretic_sbar.cpp a_bats.cpp $
a_bishop.cpp a_blastradius.cpp a_boostarmor.cpp a_centaur.cpp a_clericboss.cpp $
a_clericflame.cpp a_clericholy.cpp a_clericmace.cpp a_clericplayer.cpp $
a_clericstaff.cpp a_demons.cpp a_dragon.cpp a_ettin.cpp a_fighteraxe.cpp $
a_fighterboss.cpp a_fighterhammer.cpp a_fighterplayer.cpp a_fighterquietus.cpp $
a_firedemon.cpp a_flame.cpp a_flechette.cpp a_fog.cpp a_healingradius.cpp $
a_heresiarch.cpp a_hexenarmor.cpp a_hexendecorations.cpp a_hexenkeys.cpp $
a_hexenspecialdecs.cpp a_iceguy.cpp a_korax.cpp a_mageboss.cpp a_magecone.cpp $
a_magelightning.cpp a_mageplayer.cpp a_magestaff.cpp a_magewand.cpp a_mana.cpp $
a_pig.cpp a_puzzleitems.cpp a_scriptprojectiles.cpp a_serpent.cpp a_speedboots.cpp $
a_spike.cpp a_summon.cpp a_teleportother.cpp a_weaponpiece.cpp a_wraith.cpp $
hexen_sbar.cpp a_artiegg.cpp a_artitele.cpp a_minotaur.cpp a_ravenambient.cpp $
a_ravenartifacts.cpp a_ravenhealth.cpp a_acolyte.cpp a_alienspectres.cpp $
a_beggars.cpp a_coin.cpp a_crusader.cpp a_entityboss.cpp a_inquisitor.cpp $
a_loremaster.cpp a_macil.cpp a_merchants.cpp a_oracle.cpp a_peasant.cpp $
a_programmer.cpp a_questitems.cpp a_ratbuddy.cpp a_reaver.cpp a_rebels.cpp $
a_sentinel.cpp a_spectral.cpp a_stalker.cpp a_strifeammo.cpp a_strifearmor.cpp $
a_strifebishop.cpp a_strifeitems.cpp a_strifekeys.cpp a_strifeplayer.cpp $
a_strifestuff.cpp a_strifeweapons.cpp a_templar.cpp a_thingstoblowup.cpp $
a_zombie.cpp strife_sbar.cpp a_action.cpp a_artifacts.cpp a_bridge.cpp $
a_camera.cpp a_debris.cpp a_decals.cpp a_flashfader.cpp a_fountain.cpp $
a_hatetarget.cpp a_keys.cpp a_lightning.cpp a_movingcamera.cpp a_pickups.cpp $
a_quake.cpp a_secrettrigger.cpp a_sectoraction.cpp a_sharedmisc.cpp a_skies.cpp $
a_soundenvironment.cpp a_spark.cpp a_splashes.cpp a_waterzone.cpp a_weapons.cpp $
hudmessages.cpp shared_sbar.cpp fmopl.cpp mlkernel.cpp mlopl.cpp mlopl_io.cpp $
opl_mus_player.cpp fmodsound.cpp i_music.cpp i_sound.cpp music_cd.cpp $
music_flac.cpp music_midi_midiout.cpp music_midi_stream.cpp music_midi_timidity.cpp $
music_mod.cpp music_mus_midiout.cpp music_mus_opl.cpp music_stream.cpp $
sample_flac.cpp crashcatcher.c i_input.cpp i_net.cpp i_cd.cpp i_main.cpp $
i_system.cpp hardware.cpp i_movie.cpp sdlvideo.cpp autozend.cpp
${LINK} "${TARGET}"
:build_it
echo "- Building optimized version -"
# If we're not cleaning and zdoom.wad exists, exit now.
if "${EVILCLEAN}"="0" ifexist zdoom.wad exit 0
#:makewad
LDFLAGS = ''
CFLAGS = '-Os -Wall -fomit-frame-pointer'
# This compiles a list of source files, one at a time. Files with the '.c'
# extension are compiled using the program specified in 'CC' (default: 'gcc').
# The source files will have their extension changed to 'OBJ_EXT' (default
# value: '.o') when compiled, and be placed in 'OBJ_DIR'. 'CFLAGS' and
# 'CPPFLAGS' will be applied to the command line for C files.
src_paths tools/makewad
${COMPILE} makewad.c
${LINK} tools/makewad/makewad
dcop setLabel "Compiling cbuild.c..."
compile cbuild.c
dcop setProgress 1
src_paths tools/xlatcc
${COMPILE} xlat-parse.tab.c gen.c
${LINK} tools/xlatcc/xlatcc
src_paths tools/dehsupp
${COMPILE} parse.tab.c
${LINK} tools/dehsupp/dehsupp
# linkexec will link the previously-compiled objects into the named file with
# the command named in 'LD' (default: 'gcc'). LDFLAGS will be applied to the
# end of the command line. The specified output file will have 'EXE_EXT'
# (default: '.exe' in Win32/DOS, nothing elsewhere) appended.
do if "${EVILCLEAN}"="1"
-rm "${OBJ_DIR}"
-rm "${DEP_DIR}"
-rm zdoomgcc.map
-rm zdoom.wad
else
call cd wadsrc && ../tools/makewad/makewad zdoom.lst
copy wadsrc/zdoom.wad ./
dcop setLabel "Linking cbuild"${'EXE_EXT'}"..."
linkexec cbuild
dcop setProgress 2
echo ""
echo "- Building debug version -"
# This sets some debug cflags and sets the object extension to '-dbg.o', causing
# the source file to compile as 'cbuild-dbg.o'
CFLAGS = "-MMD -g3"
OBJ_EXT = "-dbg.o"
dcop setLabel "Compiling cbuild.c..."
compile cbuild.c
dcop setProgress 3
dcop setLabel "Linking cbuild-dbg"${'EXE_EXT'}"..."
linkexec cbuild-dbg
dcop setProgress 4
echo ""
# The getoptval directive gives the value of an option passed to the command
# line in the form of 'option=value' or 'option value'. Prefixing the command
# name with * causes the returned string to be encapsulated in 'hard quotes'
# (important for dealing with user input which may contain $ characters).
INSTALL_PATH = $(*getoptval --install)
define atexit_dcop
dcop close
ifnot ${'DCOP'}='' goto kde_install
# 'ifnot' will run the following command(s) if the two values (in the form x=y)
# are not equal. Putting the variable name in 'hard quotes' causes the expanded
# string to be encapsulated similarly (important when dealing with unknown
# input which may contain $ characters)
do ifnot ${'INSTALL_PATH'}=''
INPUT = ${'INSTALL_PATH'}
goto check_dir
done
put "Do you wish to install CBuild? [y/N] "
# 'read' will read user keyboard input until enter/return is pressed
read INPUT
# 'ifnret' will execute the follow command if the previous command's return
# value is not the specified value. A return value of 0 typically indicates
# success (and non-0 is failure).
ifnret 0 exit 1
if ${'INPUT'}='' exit 0
if $(*tolower ${'INPUT'})='n' exit 0
if $(*tolower ${'INPUT'})='no' exit 0
if $(*tolower ${'INPUT'})='y' goto input_ok
if $(*tolower ${'INPUT'})='yes' goto input_ok
echo "Invalid response '"${'INPUT'}"'"
echo "Aborting installation"
exit 0
:input_ok
do ifplat win32
INSTALL_PATH = ${'WINDIR'}
else ifplat dos
INSTALL_PATH = C:/DOS
else
INSTALL_PATH = /usr/local/bin
done
# 'fixpath' converts \ directory seperators to / in the specified var. This
# is required for CBuild to behave properly with directories
fixpath INSTALL_PATH
echo ""
echo "CBuild will install to '"${'INSTALL_PATH'}"'."
echo "If you wish to use a different location, please specify it below (press enter"
echo "for the default, type 'abort' to abort installation)"
put "-> "
:get_path
read INPUT
ifnret 0 exit 1
fixpath INPUT
do ifnot ${'INPUT'}=''
if $(*tolower ${'INPUT'})='abort' exit 0
:check_dir
do ifnexist ${'INPUT'}/.
echo ""
echo "The directory '"${'INPUT'}"/' doesn't appear to be valid."
echo "Please specify a valid path, or 'abort' to abort installation."
put "-> "
goto get_path
done
INSTALL_PATH = ${'INPUT'}
done
:copy_files
copy cbuild${EXE_EXT} ${'INSTALL_PATH'}/
echo ""
exit 0
:clean
# Here's the cleanup area, accessible if you pass "clean" to cbuild. "rmexec"
# deletes the specified executables (prepending 'EXE_EXT' to the filenames),
# and "rmobj" deletes the object and dependancy files that would be generated
# by compiling the specified file. Prepending a command with "-" will cause
# cbuild to continue even if the command fails, while prepending with '!' will
# cause cbuild to continue without any error messages.
-rmexec cbuild cbuild-dbg
-rmobj cbuild
OBJ_EXT = "-dbg.o"
-rmobj cbuild
-rm "${OBJ_DIR}" "${DEP_DIR}"
exit 0
:kde_install
# This portion is used to install using KDE's kdialog program for user
# interaction. Much nicer than needing to use the keyboard.
# Ask if the user wants to install, if they didn't previously specify to
do if ${'INSTALL_PATH'}=''
dialog --title "Install CBuild?" --yesno "Do you wish to install CBuild?"
do ifnret 0
@-rm /tmp/cbtmpxyz.txt
exit 0
done
INSTALL_PATH = /usr/local/bin
:kde_get_path
# Get the install path from the user
dialog --title "Install CBuild in..." --getexistingdirectory ${'INSTALL_PATH'}
# Read the specified path
setinput /tmp/cbtmpxyz.txt
read INSTALL_PATH
setinput
@-rm /tmp/cbtmpxyz.txt
do ifnexist ${'INSTALL_PATH'}
dialog --title "CBuild install error" --error "Could not read install directory from kdialog!
Install aborted!"
echo "Install failed!"
@-rm /tmp/cbtmpxyz.txt
exit 1
done
done
# If we don't have write permissions, we'll need to use kdesu to try and get
# them. For larger projects, where you need to do much more than a simple copy,
# you can put the commands you need potential root access for into a seperate
# script, then call cbuild (with ${0}) using that script.
do ifwrite ${'INSTALL_PATH'}/.
@!call cp cbuild${'EXE_EXT'} ${'INSTALL_PATH'}/
else
@!call kdesu -t -c \"cp cbuild${'EXE_EXT'} ${'INSTALL_PATH'}/\" 2>/dev/null
done
# Make sure the copy succeeded
do ifnret 0
dialog --title "Error installing CBuild" --warningyesno "Could not copy cbuild to "${'INSTALL_PATH'}"!
This may be due to invalid permissions. Please check with your system administrator.
Select a different location?"
ifret 0 goto kde_get_path
echo "Install failed!"
@-rm /tmp/cbtmpxyz.txt
exit 1
done
dialog --title "Install succeeded" --msgbox "Installation was successful!
CBuild has been installed in "${'INSTALL_PATH'}
echo "Install succeeded!"
@-rm /tmp/cbtmpxyz.txt
exit 0