[Gambas-devel] Starting writing a component quickly :-) (Was: Re: [Gambas-user] Gambas and AX25)
Benoit Minisini
gambas at ...1...
Fri Sep 3 12:40:05 CEST 2004
On Friday 03 September 2004 12:11, Berg Frank wrote:
> ...
> so my first question is: how do i write the beginning of the component..
>
> frank
>
I think the better way is starting from the sdl component, which is very
small.
So, let's suppose you want to write gb.xyz component, that depends on no other
component. This component needs the libxyz.so library and the xyz.h include
file. It needs multi-threading too.
1) Make a copy of the './src/lib/sdl' directory (with its contents) and name
it 'gb.xyz'.
2) Remove the sources files, but keep main.c and main.h. You will write your
own main.c and main.h by modifying them.
3) Edit the ./src/lib/xyz/Makefile.am file, and fills it as needed, as
explained in the wiki documentation. You will get something like that:
INCLUDES = -I$(top_srcdir)/src/share @XYZ_INC@
EXTRA_DIST = *.component
pkglib_LTLIBRARIES = lib.gb.xyz.la
lib_gb_xyz_la_LIBADD = @XYZ_LIB@
lib_gb_xyz_la_LDFLAGS = @LD_FLAGS@
lib_gb_xyz_la_SOURCES = \
main.h main.c \
myFirstClass.h myFirstClass.c \
mySecondClass.h mySecondClass.c \
...
install-exec-local:
@cp -f *.component $(pkglibdir)
4) Rename the './src/lib/xyz/lib.gb.sdl.component' file to
'lib.gb.xyz.component' and edit it. Be careful, this must be UTF-8 encoded.
[Component]
Key=gb.xyz
Name=The xyz component
Author=You
Alpha=1
5) Edit the ./src/lib/Makefile.am file (one directory up) and change the first
line to add '@XYZ_DIR@'
SUBDIRS = debug eval db compress @QT_DIR@ @NET_DIR@ @SDL_DIR@ @VB_DIR@
@XYZ_DIR@
5) Edit the configure.in file in the package root, and add the following
stuff:
GB_COMPONENT(
xyz,
XYZ,
[XYZ component],
[GB_FIND(xyz.h, /usr/local /usr, include xyz*/include include/xyz*)],
[GB_FIND(libxyz.$SHLIBEXT, /usr/local /usr, lib xyz*/lib lib/xyz*)],
[$C_LIB $THREAD_LIB -lxyz],
[$THREAD_INC])
6) At the end of the configure.in file, change the AC_OUTPUT macro:
dnl ---- Create makefiles
AC_OUTPUT( \
Makefile \
src/Makefile \
src/share/Makefile \
src/comp/Makefile \
src/exec/Makefile \
src/lib/Makefile \
...
src/lib/compress/Makefile \
src/lib/compress/zlib/Makefile \
src/lib/compress/bzlib2/Makefile \
src/lib/xyz/Makefile \
)
7) Open a terminal, go to the package root directory, and type:
$ ./reconf; ./configure
...
$ make
Everything should compile... if you didn't make a mistake of course :-)
8) To test the component, you must make three symbolic links from
the ./src/lib/xyz directory to the gambas installation directory. As root, of
course:
/usr/lib/gambas/lib.gb.xyz.component ----> ./src/lib/xyz/lib.gb.xyz.component
/usr/lib/gambas/lib.gb.xyz.so ----> ./src/lib/xyz/.libs/lib.gb.xyz.so
/usr/lib/gambas/lib.gb.xyz.la ----> ./src/lib/xyz/lib.gb.xyz.la
That's all. Tell me if something goes wrong.
If this how-to is useful, I will add it to the wiki.
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the Devel
mailing list