Page 1 of 1

Shell Scripts to Update FiveLinux libraries.

Posted: Mon Sep 08, 2008 12:13 pm
by xProgrammer
Hi Antonio

I am writing shell scripts to update the FiveLinux libraries from the source you provide as modified. In doing so I discovered that printers.c won't compile - not because of any direct problem with your code but rather due to an issue with the libgnomeprint libraries. Your code includes them as:

Code: Select all

#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-job.h>
#include <libgnomeprintui/gnome-print-dialog.h>
whereas given where apt-get install puts them they would have to be included as:

Code: Select all

#include <libgnomeprint-2.2/libgnomeprint/gnome-print.h>
#include <libgnomeprint-2.2/libgnomeprint/gnome-print-job.h>
#include <libgnomeprint-2.2/libgnomeprintui/gnome-print-dialog.h>
which you would think would fix matters but unfortunately these files include other libgnomeprint files. For example the following is in gnome-print.h

Code: Select all

#include <libgnomeprint/gnome-print-config.h>
#include <libgnomeprint/gnome-font.h>
#include <libgnomeprint/gnome-glyphlist.h>
So the libgnomeprint authors must have intended a different location for these files and / or changed things and not realised what they had done. But there doesn't seem to be any update at least in the Ubuntu repositories.

In case anyone is interested here is a shell script to update libfivex.a:

Code: Select all

#!/bin/bash
# updclassesx.sh

check_errs()
{
  # Parameter 1 is the return code
  # Parameter 2 is text to display on failure.
  if [ "${1}" -ne "0" ]; then
    echo "ERROR # ${1} : ${2}"
    exit ${1}
  fi
}

compile_prg()
{
  # Parameter 1 is the module name  
  echo compiling $1.prg xHarbour code to C code
  ./../../../xharbour/bin/harbour $1.prg -n -I./../../include -I./../../../xharbour/include -q0 
  check_errs $? "compiling ${1}.prg"
  echo compiling $1.c to object code
  gcc $1.c -c -I./../../include -I./../../../xharbour/include `pkg-config --cflags gtk+-2.0`
  check_errs $? "compiling ${1}.c"
  rm $1.c
  echo updating libfivex.a with $1.o
  ar rc ./../../lib/libfivex.a ./$1.o
  rm $1.o
}

sources="bar
button
checkbox
clipboard
combobox
control
dialog
folder
get
group
image
listbox
menu
menuitem
mget
msgbar
pdmenu
printer
progres
radio
radmenu
say
scrollbar
timer
wbcolumn
wbrowse
window"

echo
echo Updating xHarbour classes
echo

for m in ${sources}
do
  compile_prg ${m}
done

echo done!


It should be copied to fivelinux/source/classes and run from there.

Here's one for updating libfivec.a:

Code: Select all

#!/bin/bash
# updwinapix.sh

check_errs()
{
  # Parameter 1 is the return code
  # Parameter 2 is text to display on failure.
  if [ "${1}" -ne "0" ]; then
    echo "ERROR # ${1} : ${2}"
    exit ${1}
  fi
}

compile_c()
{
  # Parameter 1 is the module name  
  echo compiling $1.c to object code
  gcc $1.c -c -I./../../include -I./../../../xharbour/include `pkg-config --cflags gtk+-2.0`
  check_errs $? "compiling ${1}.c"
  echo updating libfivex.c with $1.o
  ar rc ./../../lib/libfivex.c ./$1.o
  rm $1.o
}

sources="bars
buttons
checkboxes
clipboards
comboboxes
dialogs
folders
getcolor
getfile
getfont
gets
groups
images
listboxes
menus
mgets
msgbars
msgbox
progress
radios
says
scrollbars
wbrowses
windows"

echo
echo Updating xHarbour classes
echo

for m in ${sources}
do
  compile_c ${m}
done

echo done!
I have left printers.c out of this for the reasons above.

Regards
Doug

PS I got four cast warnings from compilation of msgbox.c

Posted: Mon Sep 08, 2008 7:36 pm
by Antonio Linares
Doug,

Thanks for your feedback :-)

We use a makefile instead of a shell script, as the makefile will recompile only the modified files, so it is much faster.

We can provide you a makefile example if you want to.

Posted: Tue Sep 09, 2008 2:26 am
by xProgrammer
Hi Antonio
We can provide you a makefile example if you want to.
Probably a good idea as I should include that sort of information on the wiki

Regards
Doug

Posted: Tue Sep 09, 2008 8:36 am
by Antonio Linares
Doug,

This is the FiveLinux Makefile. It has to be named as Makefile (first M uppercase). Its enough to run "make" from a terminal window, placed where the Makefile is located.

Makefile

Code: Select all

# FiveLinux makefile (c) FiveTech Software

all : ./lib/libfive.a ./lib/libfivex.a ./lib/libfivec.a

PRG_OBJS = ./obj/bar.o        \
           ./obj/button.o     \
           ./obj/checkbox.o   \
	   ./obj/combobox.o   \
	   ./obj/control.o    \
	   ./obj/dialog.o     \
	   ./obj/errsys.o     \
	   ./obj/file.o       \
	   ./obj/folder.o     \
	   ./obj/get.o        \
	   ./obj/group.o      \
	   ./obj/harbour.o    \
	   ./obj/image.o      \
	   ./obj/listbox.o    \
	   ./obj/menu.o       \
	   ./obj/menuitem.o   \
	   ./obj/mget.o       \
	   ./obj/msgbar.o     \
	   ./obj/pdmenu.o     \
	   ./obj/printer.o    \
	   ./obj/progres.o    \
	   ./obj/radio.o      \
	   ./obj/radmenu.o    \
	   ./obj/say.o        \
	   ./obj/scrollbar.o  \
	   ./obj/timer.o      \
	   ./obj/valblank.o   \
	   ./obj/wbrowse.o    \
	   ./obj/wbcolumn.o   \
           ./obj/window.o

PRGX_OBJS = ./objx/bar.o        \
           ./objx/button.o     \
           ./objx/checkbox.o   \
	   ./objx/combobox.o   \
	   ./objx/control.o    \
	   ./objx/dialog.o     \
	   ./objx/errsys.o     \
	   ./objx/file.o       \
	   ./objx/folder.o     \
	   ./objx/get.o        \
	   ./objx/group.o      \
	   ./objx/harbour.o    \
	   ./objx/image.o      \
	   ./objx/listbox.o    \
	   ./objx/menu.o       \
	   ./objx/menuitem.o   \
	   ./objx/mget.o       \
	   ./objx/msgbar.o     \
	   ./objx/pdmenu.o     \
	   ./objx/printer.o    \
	   ./objx/progres.o    \
	   ./objx/radio.o      \
	   ./objx/radmenu.o    \
	   ./objx/say.o        \
	   ./objx/scrollbar.o  \
	   ./objx/timer.o      \
	   ./objx/valblank.o   \
	   ./objx/wbrowse.o    \
	   ./objx/wbcolumn.o   \
           ./objx/window.o

C_OBJS = ./objc/bars.o        \
         ./objc/buttons.o     \
         ./objc/checkboxes.o  \
	 ./objc/comboboxes.o  \
	 ./objc/dialogs.o     \
	 ./objc/files.o       \
	 ./objc/folders.o     \
	 ./objc/getfile.o     \
	 ./objc/getfont.o     \
	 ./objc/gets.o        \
	 ./objc/groups.o      \
	 ./objc/images.o      \
	 ./objc/listboxes.o   \
         ./objc/lnx.o         \
         ./objc/menus.o       \
	 ./objc/mgets.o       \
	 ./objc/msgbars.o     \
         ./objc/msgbox.o      \
	 ./objc/printers.o    \
	 ./objc/progress.o    \
	 ./objc/radios.o      \
	 ./objc/says.o        \
	 ./objc/scrollbars.o  \
	 ./objc/spawn.o       \
         ./objc/wbrowses.o    \
	 ./objc/windows.o


./lib/libfive.a  : $(PRG_OBJS)
./lib/libfivex.a : $(PRGX_OBJS)
./lib/libfivec.a : $(C_OBJS)

./obj/%.c : ./source/classes/%.prg
	./../harbour/bin/harbour $< -o./$@ -n -I./../harbour/include -I./include

./obj/%.c : ./source/function/%.prg
	./../harbour/bin/harbour $< -o./$@ -n -I./../harbour/include -I./include

./obj/%.o : ./obj/%.c
	gcc -c -o $@ -I./../harbour/include $<
	ar rc ./lib/libfive.a $@

./objx/%.c : ./source/classes/%.prg
	./../xharbour/bin/harbour $< -o./$@ -n -I./../xharbour/include -I./include

./objx/%.c : ./source/function/%.prg
	./../xharbour/bin/harbour $< -o./$@ -n -I./../xharbour/include -I./include

./objx/%.o : ./objx/%.c
	gcc -c -o $@ -I./../xharbour/include $<
	ar rc ./lib/libfivex.a $@

./objc/%.o : ./source/function/%.c
	gcc `pkg-config --cflags gtk+-2.0` `pkg-config --cflags libgnomeprintui-2.2` -I./../harbour/include -I./include -Wall -c -o $@ $<
	ar rc ./lib/libfivec.a $@

./objc/%.o : ./source/winapi/%.c
	gcc `pkg-config --cflags gtk+-2.0` `pkg-config --cflags libgnomeprintui-2.2` -I./../harbour/include -I./include -Wall -c -o $@ $<
	ar rc ./lib/libfivec.a $@

./objc/%.o : ./source/internal/%.c
	gcc `pkg-config --cflags gtk+-2.0` `pkg-config --cflags libglade-2.0` -I./../harbour/include -I./include -Wall -c -o $@ $<
	ar rc ./lib/libfivec.a $@