Re: Makefiles with libraries

Mike Aubury <[email protected]> Tue, 27 Jun 2023 08:29:26 +0100
Newsgroups gmane.comp.lang.4gl.aubit.general
Message-ID <CAGAq4WHq_517vtr05+FuByDuFUC-rJaBr7gov3cP6UixXktboA@mail.gmail.com>
--===============6868919499615463357==
Content-Type: multipart/alternative; boundary="000000000000ef2a5705ff176d83"

--000000000000ef2a5705ff176d83
Content-Type: text/plain; charset="UTF-8"

Hi,
from what you've written I'm guessing you're coming from a 4gl RDS install
rather than the C compiler version, which explains the larger file sizes.
In RDS - it compiles down to a "P-Ccode" which is a lot smaller than an
executable.

That said - it also looks like your code is divided into a library and
"other" code - you can use this to your advantage by compiling the library
code into a shared library and reusing that with all your other programs
which will end up with smaller executables.

Eg in   ../../lib/lib.RDS

4glpc --as-dll -o libRDSLib.so zclfi02a.4gl zdefi00a.4gl zwork00a.4gl
ztish00a.4gl zglch00a.4gl librpt.4gl p_liball.4gl


You can then re-use that library in your code :

4glpc -o glch_read glch_read.4gl -L../../lib/lib.RDS -lRDSLib

Finally - for your makefiles themselves - the simplest way is probably to
use "strings" or something similar on your .4gis to see what 4gls are in
there and generate new makefiles from those - excluding any that are now in
your shared library.
If you have a "inSharedLib" which lists all your 4gls in your library -
something like :

strings somefile.4gi | grep ".4gl$" | grep -vf inSharedLib


You could easily script that up to generate your makefiles for all your
4gis.

On Tue, 27 Jun 2023 at 07:00, Michael Pope <[email protected]> wrote:

> Hello,
>
> I've got an old Informix 7.20 install, I've migrated all my data to
> PostgreSQL and compiled the Aubit4GL compiler under Debian 10. I can
> compile and link to the database using a command like so for my program
> called 'glch_read'
>
> $ 4glpc ../../lib/lib.RDS/zclfi02a.4gl ../../lib/lib.RDS/zdefi00a.4gl
> ../../lib/lib.RDS/zwork00a.4gl ../../lib/lib.RDS/ztish00a.4gl
> ../../lib/lib.RDS/zglch00a.4gl ../../lib/lib.RDS/librpt.4gl
> ../../lib/lib.RDS/p_liball.4gl glch_read.4gl -o glch_read
>
> I would like to use Makefiles instead.
>
> I have a program called glch_read and it sits in the api/glch_read
> directory. My library files are stored relative to that path in
> ../../lib/lib.RDS.
>
> Here is my original Informix Makefile
>
> #-----------------------------------------------------------------------
> #_name - program name
> NAME =      glch_read.4ge
>
> #_objfiles - program files
> OBJFILES =   glch_read.o
>
> #_forms - perform files
>
> #_libfiles - library list
> LIBFILES = ../../lib/lib.a
>
> #_all_rule - program compile rule
> all:
>      @echo "make: Cannot use make. use fg.make -f for $DL compile."
> #-----------------------------------------------------------------------
>
> NOTE: There are some helper script files which set the library
> dependencies.
>
>
> Here is the Aubit4GL Makefile which I've created
>
> #-----------------------------------------------------------------------
>
> include ../../makedefs
> #
> GPATH = ../../lib/lib.RDS
> .PHONY: all
> all: glch_read
> srcfiles = ../../lib/lib.RDS/zclfi02a.4gl ../../lib/lib.RDS/zdefi00a.4gl
> ../../lib/lib.RDS/zwork00a.4gl ../../lib/lib.RDS/ztish00a.4gl
> ../../lib/lib.RDS/zglch00a.4gl ../../lib/lib.RDS/librpt.4gl
> ../../lib/lib.RDS/p_liball.4gl glch_read.4gl
> objfiles = $(srcfiles:.4gl=.ao)
> glch_read : $(objfiles)
>      aubit 4glc -o [email protected] $^
>
> # Note the subtle difference here $^ (all prereqs are needed)
> # $? would link only the newly compiled objects
> #-----------------------------------------------------------------------
>
>
> Here is the makedefs
>
> #-----------------------------------------------------------------------
>
> # Declare the following suffixes meaningful to make
> .SUFFIXES: .afr .per
> .SUFFIXES: .ao .4gl
> .SUFFIXES: .iem .msg
>
> # Pattern rules for the above suffixes
> %.afr : %.per # equivalent to the old make form .per.afr:
>      aubit fcompile $<
> %.ao : %.4gl
>      aubit 4glc -c $?
> %.iem : %.msg
>      aubit amkmessage $< $@
>
> #-----------------------------------------------------------------------
>
>
> It compiles with 'make' and it does work.
>
> I've got a few problems though
>
> 1. It creates a very large executable (3.9MB instead of the informix
> compiled file of 810KB)
>
> 2. This would require me to change all 617 Makefiles in my project, I
> would rather convert the original Makefile if possible
>
> 3. Currently I have to manually find the dependency library files and
> add them, is there a linker which does this?
>
>
> I've read the manual a few times but I haven't done much with Makefiles
> before so maybe I'm missing something simple.
>
> Any help would be great.
>
> from
> Michael
>
>
> _______________________________________________
> Aubit4gl-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
>

--000000000000ef2a5705ff176d83
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div>from what you&#39;ve=C2=A0written I&#39;m guessing=
 you&#39;re coming=C2=A0from a 4gl RDS install rather than the C compiler v=
ersion, which explains the larger file sizes.</div><div>In RDS - it compile=
s down to a &quot;P-Ccode&quot;=C2=A0which is a lot smaller than an executa=
ble.</div><div><br></div><div>That said - it also looks like your code is d=
ivided=C2=A0into a library and &quot;other&quot; code - you can use this to=
 your=C2=A0advantage by compiling the library code into a shared library an=
d reusing that with all your other programs which will end up with smaller =
executables.<br><br>Eg in=C2=A0 =C2=A0../../lib/lib.RDS</div><div><br></div=
><div>4glpc --as-dll -o libRDSLib.so zclfi02a.4gl zdefi00a.4gl zwork00a.4gl=
 ztish00a.4gl zglch00a.4gl librpt.4gl p_liball.4gl</div><div><br><br>You ca=
n then re-use that library in your code :=C2=A0</div><div><br></div><div>4g=
lpc -o glch_read glch_read.4gl -L../../lib/lib.RDS -lRDSLib<br><br>Finally =
- for your makefiles themselves - the simplest way is probably to use &quot=
;strings&quot; or something similar on your .4gis to see what 4gls are in t=
here and generate new makefiles from those - excluding any that are now in =
your shared library.</div><div>If you have a &quot;inSharedLib&quot; which =
lists all your 4gls in your library - something like :=C2=A0</div><div><br>=
</div><div>strings somefile.4gi | grep &quot;.4gl$&quot; | grep -vf inShare=
dLib=C2=A0<br></div><div><br><br>You could easily script that up to generat=
e your makefiles for all your 4gis.</div></div><br><div class=3D"gmail_quot=
e"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, 27 Jun 2023 at 07:00, Mich=
ael Pope &lt;<a href=3D"mailto:[email protected]">[email protected]=
</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
Hello,<br>
<br>
I&#39;ve got an old Informix 7.20 install, I&#39;ve migrated all my data to=
 <br>
PostgreSQL and compiled the Aubit4GL compiler under Debian 10. I can <br>
compile and link to the database using a command like so for my program <br=
>
called &#39;glch_read&#39;<br>
<br>
$ 4glpc ../../lib/lib.RDS/zclfi02a.4gl ../../lib/lib.RDS/zdefi00a.4gl <br>
../../lib/lib.RDS/zwork00a.4gl ../../lib/lib.RDS/ztish00a.4gl <br>
../../lib/lib.RDS/zglch00a.4gl ../../lib/lib.RDS/librpt.4gl <br>
../../lib/lib.RDS/p_liball.4gl glch_read.4gl -o glch_read<br>
<br>
I would like to use Makefiles instead.<br>
<br>
I have a program called glch_read and it sits in the api/glch_read <br>
directory. My library files are stored relative to that path in <br>
../../lib/lib.RDS.<br>
<br>
Here is my original Informix Makefile<br>
<br>
#-----------------------------------------------------------------------<br=
>
#_name - program name<br>
NAME =3D=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 glch_read.4ge<br>
<br>
#_objfiles - program files<br>
OBJFILES =3D=C2=A0=C2=A0 glch_read.o<br>
<br>
#_forms - perform files<br>
<br>
#_libfiles - library list<br>
LIBFILES =3D ../../lib/lib.a<br>
<br>
#_all_rule - program compile rule<br>
all:<br>
=C2=A0=C2=A0=C2=A0 =C2=A0@echo &quot;make: Cannot use make. use fg.make -f =
for $DL compile.&quot;<br>
#-----------------------------------------------------------------------<br=
>
<br>
NOTE: There are some helper script files which set the library dependencies=
.<br>
<br>
<br>
Here is the Aubit4GL Makefile which I&#39;ve created<br>
<br>
#-----------------------------------------------------------------------<br=
>
<br>
include ../../makedefs<br>
#<br>
GPATH =3D ../../lib/lib.RDS<br>
.PHONY: all<br>
all: glch_read<br>
srcfiles =3D ../../lib/lib.RDS/zclfi02a.4gl ../../lib/lib.RDS/zdefi00a.4gl =
<br>
../../lib/lib.RDS/zwork00a.4gl ../../lib/lib.RDS/ztish00a.4gl <br>
../../lib/lib.RDS/zglch00a.4gl ../../lib/lib.RDS/librpt.4gl <br>
../../lib/lib.RDS/p_liball.4gl glch_read.4gl<br>
objfiles =3D $(srcfiles:.4gl=3D.ao)<br>
glch_read : $(objfiles)<br>
=C2=A0=C2=A0=C2=A0 =C2=A0aubit 4glc -o [email protected] $^<br>
<br>
# Note the subtle difference here $^ (all prereqs are needed)<br>
# $? would link only the newly compiled objects<br>
#-----------------------------------------------------------------------<br=
>
<br>
<br>
Here is the makedefs<br>
<br>
#-----------------------------------------------------------------------<br=
>
<br>
# Declare the following suffixes meaningful to make<br>
.SUFFIXES: .afr .per<br>
.SUFFIXES: .ao .4gl<br>
.SUFFIXES: .iem .msg<br>
<br>
# Pattern rules for the above suffixes<br>
%.afr : %.per # equivalent to the old make form .per.afr:<br>
=C2=A0=C2=A0=C2=A0 =C2=A0aubit fcompile $&lt;<br>
%.ao : %.4gl<br>
=C2=A0=C2=A0=C2=A0 =C2=A0aubit 4glc -c $?<br>
%.iem : %.msg<br>
=C2=A0=C2=A0=C2=A0 =C2=A0aubit amkmessage $&lt; $@<br>
<br>
#-----------------------------------------------------------------------<br=
>
<br>
<br>
It compiles with &#39;make&#39; and it does work.<br>
<br>
I&#39;ve got a few problems though<br>
<br>
1. It creates a very large executable (3.9MB instead of the informix <br>
compiled file of 810KB)<br>
<br>
2. This would require me to change all 617 Makefiles in my project, I <br>
would rather convert the original Makefile if possible<br>
<br>
3. Currently I have to manually find the dependency library files and <br>
add them, is there a linker which does this?<br>
<br>
<br>
I&#39;ve read the manual a few times but I haven&#39;t done much with Makef=
iles <br>
before so maybe I&#39;m missing something simple.<br>
<br>
Any help would be great.<br>
<br>
from<br>
Michael<br>
<br>
<br>
_______________________________________________<br>
Aubit4gl-discuss mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank"=
>[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss" r=
el=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/lis=
tinfo/aubit4gl-discuss</a><br>
</blockquote></div>

--000000000000ef2a5705ff176d83--


--===============6868919499615463357==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============6868919499615463357==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Aubit4gl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss

--===============6868919499615463357==--