Re: Makefiles with libraries

Mike Aubury <[email protected]> Wed, 28 Jun 2023 07:24:38 +0100
Newsgroups gmane.comp.lang.4gl.aubit.general
Message-ID <CAGAq4WEtBBVGBschKxUS-PAOQUACqo0zMc0DcksSf5uT+Wd_Vw@mail.gmail.com>
--===============3978245954210789874==
Content-Type: multipart/alternative; boundary="000000000000f98ede05ff2aa366"

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

I'd group the libraries into functional units.
I don't know what that breaks down to with your code, but I doubt it's just
one module per library.

On Wed, 28 Jun 2023, 00:56 Michael Pope, <[email protected]> wrote:

> Thanks Mike,
>
> That worked. I had to add my library path to the LD_LIBRARY_PATH
> environment variable and I'm going to compile the libraries separately as
> they are reused heavily through the application. This way I can mix and
> match the shared libraries depending on the requirements.
>
> OR am I better compiling all my libraries into one big .so file and just
> linking to that? I have 359 shared library 4gl files but I'm thinking that
> keeping them separate might isolate issues and make it easier to debug. On
> the other hand to convert my program over the Aubit4GL putting all the
> libraries into one big .so file would make it easier to compile all my
> programs as I could just point to that one shared .so file.
>
> Here are my current working steps
>
>         1. Setup environment
>            : export
> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/code/pais_legacy/lib/lib.RDS
>
>         2. Compile libraries
>            : 4glpc --as-dll -o libzclfi02a.so zclfi02a.4gl
>            : 4glpc --as-dll -o libzdefi00a.so zdefi00a.4gl
>            : 4glpc --as-dll -o libzwork00a.so zwork00a.4gl
>            : 4glpc --as-dll -o libztish00a.so ztish00a.4gl
>            : 4glpc --as-dll -o libzglch00a.so zglch00a.4gl
>            : 4glpc --as-dll -o liblibrpt.so librpt.4gl
>            : 4glpc --as-dll -o libp_liball.so p_liball.4gl
>
>         3. Compile program
>            : 4glpc -o glch_read glch_read.4gl -L../../lib/lib.RDS
> -lzclfi02a -l zdefi00a -l zwork00a -l ztish00a -lzglch00a -l librpt -l
> p_liball
>
>         4. Run
>            : ./glch_read T1 1
>
>
>
> Regards,
>
> *Michael Pope*
>
> On 27/6/23 17:29, Mike Aubury wrote:
>
> 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
>>
> _______________________________________________
> Aubit4gl-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
>

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

<div dir=3D"auto">I&#39;d group the libraries into functional units.<div di=
r=3D"auto">I don&#39;t know what that breaks down to with your code, but I =
doubt it&#39;s just one module per library.=C2=A0</div></div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, 28 Jun 2023,=
 00:56 Michael Pope, &lt;<a href=3D"mailto:[email protected]">michael@d=
tcorp.com.au</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 =20
   =20
 =20
  <div>
    <p>Thanks Mike,</p>
    <p>That worked. I had to add my library path to the LD_LIBRARY_PATH
      environment variable and I&#39;m going to compile the libraries
      separately as they are reused heavily through the application.
      This way I can mix and match the shared libraries depending on the
      requirements. <br>
    </p>
    <p>OR am I better compiling all my libraries into one big .so file
      and just linking to that? I have 359 shared library 4gl files but
      I&#39;m thinking that keeping them separate might isolate issues and
      make it easier to debug. On the other hand to convert my program
      over the Aubit4GL putting all the libraries into one big .so file
      would make it easier to compile all my programs as I could just
      point to that one shared .so file.</p>
    <p>Here are my current working steps<br>
    </p>
    <p>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1. Setup environment<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : export
      LD_LIBRARY_PATH=3D$LD_LIBRARY_PATH:~/code/pais_legacy/lib/lib.RDS<br>
      <br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2. Compile libraries<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o libzclfi02a.so zclfi02a.4gl <br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o libzdefi00a.so zdefi00a.4gl<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o libzwork00a.so zwork00a.4gl<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o libztish00a.so ztish00a.4gl<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o libzglch00a.so zglch00a.4gl <br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o liblibrpt.so librpt.4gl<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
--as-dll -o libp_liball.so p_liball.4gl<br>
      <br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 3. Compile program<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 4glpc =
-o glch_read glch_read.4gl -L../../lib/lib.RDS
      -lzclfi02a -l zdefi00a -l zwork00a -l ztish00a -lzglch00a -l
      librpt -l p_liball<br>
      <br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4. Run<br>
      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : ./glch=
_read T1 1</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div>
      <div dir=3D"ltr">
        <div>Regards,</div>
        <div><br>
        </div>
        <div><b>Michael Pope</b><br>
        </div>
        <div><br>
        </div>
      </div>
    </div>
    <div>On 27/6/23 17:29, Mike Aubury wrote:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      <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 version, which
          explains the larger file sizes.</div>
        <div>In RDS - it compiles down to a &quot;P-Ccode&quot;=C2=A0which =
is a lot
          smaller than an executable.</div>
        <div><br>
        </div>
        <div>That said - it also looks like your code is divided=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 and
          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</d=
iv>
        <div><br>
          <br>
          You can then re-use that library in your code :=C2=A0</div>
        <div><br>
        </div>
        <div>4glpc -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 there 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 4gl=
s in
          your library - something like :=C2=A0</div>
        <div><br>
        </div>
        <div>strings somefile.4gi | grep &quot;.4gl$&quot; | grep -vf inSha=
redLib=C2=A0<br>
        </div>
        <div><br>
          <br>
          You could easily script that up to generate your makefiles for
          all your 4gis.</div>
      </div>
      <br>
      <div class=3D"gmail_quote">
        <div dir=3D"ltr" class=3D"gmail_attr">On Tue, 27 Jun 2023 at 07:00,
          Michael Pope &lt;<a href=3D"mailto:[email protected]" target=
=3D"_blank" rel=3D"noreferrer">[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 f=
g.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
          Makefiles <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" rel=3D"noreferrer">[email protected]</a><b=
r>
          <a href=3D"https://lists.sourceforge.net/lists/listinfo/aubit4gl-=
discuss" rel=3D"noreferrer noreferrer" target=3D"_blank">https://lists.sour=
ceforge.net/lists/listinfo/aubit4gl-discuss</a><br>
        </blockquote>
      </div>
    </blockquote>
  </div>

_______________________________________________<br>
Aubit4gl-discuss mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank"=
 rel=3D"noreferrer">[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss" r=
el=3D"noreferrer noreferrer" target=3D"_blank">https://lists.sourceforge.ne=
t/lists/listinfo/aubit4gl-discuss</a><br>
</blockquote></div>

--000000000000f98ede05ff2aa366--


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


--===============3978245954210789874==
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

--===============3978245954210789874==--