Re: pcode compilation
Posted in 1997
On 14 Nov 1997, NCMis11 wrote: > I am setting up the environment for informix development. > I have some trouble creating libraries for pcode version. That isn't very surprising; there isn't any direct support for p-code libaries. > I have a makefile to compile all 4gl using c4gl in the library. > This works fine. Yes, it does. And thank you for using Make! > I cannot use this library to link to my 4gl modules compiled with fglpc . Correct. If you wrote an appropriate userfunc.c file (based on the template in $INFORMIXDIR/etc), you could build a custom runner with your userfunc.c file and your library. This should work, though I'd be leery of putting things like INPUT statements into the runner. > So my goal is to create a library of 4go's and link them at compilation time. Excellent. You need a librarian for the p-code object files, and you need a linker. You can use ar as the librarian, but you may be better off using your own. You can use cat as the librarian, but you get no selectivity when you link the library into your p-code interpretables. I did this on a project, and was generating 350 kB .4gi files; when I implemented a proper p-code libarian and linker, the 4gi files reduced to about 100 kB. That overhead was why I did the donkey work. > Also is there a way i can use the same makefile to compile 4ge and 4gi. Yes. Simply say: all: program.4ge program.4gi and write the appropriate rule for program.4gi. Better, use macros throughout: all: $(PROG.4ge) $(PROG.4gi) $(PROG.4gi): $(FILES.4go) $(LIBS.4ga) ... > The whole excersise to use the debugger If you aren't going to deploy the p-code files, then using cat as both the librarian and linker will work (which is dead easy), at the cost of extra overhead starting up the debugger when it loads a whole pile of object code which is not actually going to be used. However, the expense is minimal. Alternatively, you can do as I did and write your own p-code linker and librarian. I've done it twice now, once using ar for most of the archive handling and implementing a p-code equivalent to the archaic ranlib command; and once using a custom (proprietary) archive format. In both cases, the linker was purely custom code. I can't make either version available for proprietary reasons. A third alternative is to get NewEra 3.00 or later. If you are a pure I4GL shop, you could throw away almost everything except the fgllib and fgllink commands (you also need the fglrsrv.iem message file). These are my second implementation, and they understand the I4GL p-code versions as well as the NewEra p-code versions, so you could use them with your I4GL project. What I can provide is a pair of shell scripts, fgllib and fgllink, which implement cat-based libraries using (approximately?) the same interface as the NewEra fgllib and fgllink programs. They're in the shell archive below. Yours, Jonathan Leffler (johnl@informix.com) #include <witticism.h> : "@(#): shar.sh,v 1.10 1997/06/02 21:45:00 johnl Exp $" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Mon Nov 17 11:18:14 PST 1997 by johnl at Informix Software Ltd. # Files archived in this archive: # fgllib.sh # fgllink.sh # #-------------------- if [ -f fgllib.sh -a "$1" != "-c" ] then echo shar: fgllib.sh already exists else echo 'x - fgllib.sh (313 characters)' sed -e 's/^X//' >fgllib.sh <<'SHAR-EOF' X: "@(#)fgllib.sh 1.1 95/08/04" X# X# FGLLIB: concatenated .4go file librarian X Xfor lib in $* Xdo X case $lib in X *.4ga) X out=${lib%.4ga}.4gc X obj=`ar t $lib | grep -v __.RDSLIB` X ar x $lib $obj X cat $obj >$out X rm -f $obj X ;; X *) echo "`basename $0 .sh`: unrecognized file type $file" >&2 X exit 1;; X esac Xdone SHAR-EOF chmod 444 fgllib.sh if [ `wc -c <fgllib.sh` -ne 313 ] then echo shar: fgllib.sh unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f fgllink.sh -a "$1" != "-c" ] then echo shar: fgllink.sh already exists else echo 'x - fgllink.sh (864 characters)' sed -e 's/^X//' >fgllink.sh <<'SHAR-EOF' X: "@(#)fgllink.sh 1.1 95/08/04" X# X# FGLLINK: concatenated .4go file linker X Xarg0=`basename $0 .sh` XLIBDIRS="" XFILES="" X Xfindlib(){ X libname="" X for dir in $LIBDIRS X do X lib=$dir/lib$1.4gc X if [ -f $lib ] X then echo $lib X return X fi X done X echo "$arg0: cannot locate library for -l$1" >&2 X exit 1 X} X Xwhile [ $# -gt 0 ] Xdo X case $1 in X -o) X outfile=$2; shift;; X -L?*) X dir=`expr $1 : '-L\\(.*\\)'` X LIBDIRS="$LIBDIRS $dir";; X -l?*) X lib=`expr $1 : '-l\\(.*\\)'` X FILES="$FILES `findlib $lib`" X ;; X -L) X LIBDIRS="$LIBDIRS $2"; shift;; X -l) X FILES="$FILES `findlib $2`"; shift;; X -V) echo "$arg0 Version 1.1 (95/08/04)"; exit 0;; X -c) : OK;; X -d) : OK;; X -D*) : OK; shift;; X *.4g[ioa]) FILES="$FILES $1";; X *) X echo "$arg0: unrecognized file type $1" >&2 X exit 1;; X esac X shift Xdone X Xif [ -z "$outfile" ] Xthen outfile=fgllink.4gi Xfi X Xcat $FILES > $outfile SHAR-EOF chmod 444 fgllink.sh if [ `wc -c <fgllink.sh` -ne 864 ] then echo shar: fgllink.sh unpacked with wrong size fi # end of overwriting check fi echo All files extracted exit 0