From 0785f09a42a52f77b1c6d4683edd18385006e1eb Mon Sep 17 00:00:00 2001 From: jaybinks Date: Mon, 3 Dec 2007 00:57:22 +0000 Subject: Added Makefile and lazres script from hennymcc ( on IRC ) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@657 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Makefile | 69 +++++++++++++++++++++++++++++++ Game/Code/lazres-UltraStar.sh | 94 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 Game/Code/Makefile create mode 100755 Game/Code/lazres-UltraStar.sh (limited to 'Game/Code') diff --git a/Game/Code/Makefile b/Game/Code/Makefile new file mode 100644 index 00000000..fcf534cd --- /dev/null +++ b/Game/Code/Makefile @@ -0,0 +1,69 @@ +## +# UltraStar bamboo build for linux +## + +# lazarus base-dir +# will be set by configure later on +LAZDIR := $(shell whereis lazarus | cut -d ' ' -f2) +#LAZDIR = /usr/local/share/lazarus + +# Directories added to the unit path +UNIT_FLAG = -Fu +UNIT_PATH = $(UNIT_FLAG)$(LAZDIR)/lcl/units/i386-linux \ + $(UNIT_FLAG)$(LAZDIR)/components/images/lib/i386-linux \ + $(UNIT_FLAG)$(LAZDIR)/components/jpeg \ + $(UNIT_FLAG). +# $(UNIT_FLAG)$(LAZDIR)/packager/units/i386-linux \ + +# Directory where compiled units (.ppu and .o) files are stored +CUNIT_DIR = build/linux/lazarus + +# Directories added to the includes path +INC_FLAG = -Fi +INC_PATH = $(INC_FLAG)lib/JEDI-SDLv1.0/SDL/Pas + +# Defines +DEFINES = -dLCL +DEFINES += -dFPC_V220 + +# Misc fpc options +COMPAT_FLAGS = -S2dgi +#COMPAT_FLAGS += -Mdelphi +VERBOSE_FLAGS = -vew -l +DEBUG_FLAGS = -gl +DEBUG_FLAGS += -g +#DEBUG_FLAGS = -dDEBUG +#-Crtoi +#OPTIMIZE_FLAGS_FPC204 = -OG2p3 +#OPTIMIZE_FLAGS_FPC220 = -O2p"NAME" +#OPTIMIZE_FLAGS = -dRELEASE +OPTIMIZE_FLAGS += -Xs +FLAGS = $(COMPAT_FLAGS) \ + $(VERBOSE_FLAGS) \ + $(DEBUG_FLAGS) \ + $(OPTIMIZE_FLAGS) \ + $(DEFINES) + +# lpr project file used as input +PROJECT_FILE = UltraStar.lpr +# name of executable +OUTPUT = UltraStar + +all: resource ultrastar +resource: UltraStar.lrs +ultrastar: clean_obj + mkdir -p $(CUNIT_DIR) + fpc $(FLAGS) $(INC_PATH) $(UNIT_PATH) -FU$(CUNIT_DIR) -o$(OUTPUT) $(PROJECT_FILE) +install: + mv $(OUTPUT) ../.. +clean: clean_obj clean_res +distclean: clean +clean_obj: + rm -f -r $(CUNIT_DIR)/*.o $(CUNIT_DIR)/*.ppu $(CUNIT_DIR)/*.rst + rm -f $(OUTPUT) +clean_res: + rm -f UltraStar.lrs link.res +UltraStar.lrs: UltraStar.rc + sh lazres-UltraStar.sh + +.PHONY: all resource ultrastar install clean distclean clean_obj clean_res diff --git a/Game/Code/lazres-UltraStar.sh b/Game/Code/lazres-UltraStar.sh new file mode 100755 index 00000000..1f5adb78 --- /dev/null +++ b/Game/Code/lazres-UltraStar.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +## +# Creates an .lrs resource-file. +# This script reads an rc resource definition file +# and uses lazres to compile it into an lrs-file. +## + +RCFILE=UltraStar.rc +OUTFILE=UltraStar.lrs +# set this to your lazarus directory if autodetection fails +LAZDIR_DEFAULT=/usr/local/share/lazarus + +LAZDIR=`whereis -b lazarus | cut -s -d ' ' -f2` +if [ ! -d "${LAZDIR}" ]; then + if [ ! -d "${LAZDIR_DEFAULT}" ]; then + echo "Autodetecting Lazarus-directory failed!" + echo "Set LAZDIR_DEFAULT to your Lazarus directory in this script." + exit 1 + fi + LAZDIR="${LAZDIR_DEFAULT}" +fi + +LAZRES="${LAZDIR}/tools/lazres" +LAZRES_SRC="${LAZRES}.pp" +LAZRES_PROJ="${LAZRES}.lpi" +LAZBUILD="${LAZDIR}/lazbuild" +UNIT_PATH=-Fu${LAZDIR}/lcl/units/i386-linux + +# check if lazres is available +if [ ! -x "${LAZRES}" ]; then + # lazres not available -> build it + echo -e "Building of lazres required...\n" + # check if lazres project-file exists + if [ ! -f "${LAZRES_SRC}" ]; then + echo -e "\n${LAZRES_SRC} not found!" + exit 1 + fi + # build lazres + fpc -dRELEASE "${UNIT_PATH}" "${LAZRES_SRC}" + #"${LAZBUILD}" "${LAZRES_PROJ}" + # did it fail? + if [ $? -ne 0 ]; then + echo -e "\nBuilding lazres failed!" + exit 1 + fi + echo -e "\nBuilding lazres finished!" +fi + +# create temp-dir for file renaming (do not use varname TMPDIR!) +RENAME_DIR=`mktemp -t -d usdxresXXXXXXXXXX` || exit 1 +echo "Temporary directory for file-renaming created! (${RENAME_DIR})" + +# read each line of RC-file and add resource-path to parameter-list +LAZRES_PARAMS="" +echo "Reading RC-file..." +{ +while read -r res_name res_type res_path; do + # check if line is commented out + if (echo ${res_name} | grep "^//" >/dev/null) ; then + echo "Skip resource: ${res_name}" + continue + fi + # add non-empty paths to parameter-list + if [ ! -z "${res_path}" ]; then + # replace backslashes (\\) and carriage return (\r) (MS-DOS line-ending) + RES_PATH=`echo "${res_path}" | tr '\r\\' '\0/'` + RES_NEW_PATH="${RENAME_DIR}/${res_name}.${res_type}" + eval cp "${RES_PATH}" "${RES_NEW_PATH}" + # append to parameter-list + LAZRES_PARAMS="${LAZRES_PARAMS} ${RES_NEW_PATH}" + fi +done +} < "${RCFILE}" + +# create resource file +rm -f ${OUTFILE} +echo "Creating resource file..." +"${LAZRES}" "${OUTFILE}" ${LAZRES_PARAMS} +RES=0 +if [ -f "${OUTFILE}" ]; then + echo -e "\nResource file successfully created!" + RES=1 +else + echo -e "\nCreation of resource file failed!" +fi + +# remove temp-directory +echo "Removing temporary directory..." +rm -rf "${RENAME_DIR}" + +if [ $RES -eq 1 ]; then + echo -e "\nReady." +fi -- cgit v1.2.3