Re: Makefiles with libraries
Michael Pope <[email protected]> Wed, 28 Jun 2023 09:56:13 +1000
| Newsgroups | gmane.comp.lang.4gl.aubit.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --===============1071811267563072501== Content-Type: multipart/alternative; boundary="------------s4uf8CMMgrZ1jt41Ih4W40tY" Content-Language: en-US This is a multi-part message in MIME format. --------------s4uf8CMMgrZ1jt41Ih4W40tY Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > --------------s4uf8CMMgrZ1jt41Ih4W40tY Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>Thanks Mike,</p> <p>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. <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'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> 1. Setup environment<br> : export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/code/pais_legacy/lib/lib.RDS<br> <br> 2. Compile libraries<br> : 4glpc --as-dll -o libzclfi02a.so zclfi02a.4gl <br> : 4glpc --as-dll -o libzdefi00a.so zdefi00a.4gl<br> : 4glpc --as-dll -o libzwork00a.so zwork00a.4gl<br> : 4glpc --as-dll -o libztish00a.so ztish00a.4gl<br> : 4glpc --as-dll -o libzglch00a.so zglch00a.4gl <br> : 4glpc --as-dll -o liblibrpt.so librpt.4gl<br> : 4glpc --as-dll -o libp_liball.so p_liball.4gl<br> <br> 3. Compile program<br> : 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> 4. Run<br> : ./glch_read T1 1</p> <p><br> </p> <p><br> </p> <div class="moz-signature"> <div dir="ltr"> <div>Regards,</div> <div><br> </div> <div><b>Michael Pope</b><br> </div> <div><br> </div> </div> </div> <div class="moz-cite-prefix">On 27/6/23 17:29, Mike Aubury wrote:<br> </div> <blockquote type="cite" cite="mid:CAGAq4WHq_517vtr05+FuByDuFUC-rJaBr7gov3cP6UixXktboA@mail.gmail.com"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <div dir="ltr">Hi, <div>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.</div> <div>In RDS - it compiles down to a "P-Ccode" which is a lot smaller than an executable.</div> <div><br> </div> <div>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.<br> <br> Eg in ../../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 can then re-use that library in your code : </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 "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.</div> <div>If you have a "inSharedLib" which lists all your 4gls in your library - something like : </div> <div><br> </div> <div>strings somefile.4gi | grep ".4gl$" | grep -vf inSharedLib <br> </div> <div><br> <br> You could easily script that up to generate your makefiles for all your 4gis.</div> </div> <br> <div class="gmail_quote"> <div dir="ltr" class="gmail_attr">On Tue, 27 Jun 2023 at 07:00, Michael Pope <<a href="mailto:[email protected]" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> </div> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br> <br> I've got an old Informix 7.20 install, I'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 'glch_read'<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 = glch_read.4ge<br> <br> #_objfiles - program files<br> OBJFILES = glch_read.o<br> <br> #_forms - perform files<br> <br> #_libfiles - library list<br> LIBFILES = ../../lib/lib.a<br> <br> #_all_rule - program compile rule<br> all:<br> @echo "make: Cannot use make. use fg.make -f for $DL compile."<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've created<br> <br> #-----------------------------------------------------------------------<br> <br> include ../../makedefs<br> #<br> GPATH = ../../lib/lib.RDS<br> .PHONY: all<br> all: glch_read<br> srcfiles = ../../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 = $(srcfiles:.4gl=.ao)<br> glch_read : $(objfiles)<br> aubit 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> aubit fcompile $<<br> %.ao : %.4gl<br> aubit 4glc -c $?<br> %.iem : %.msg<br> aubit amkmessage $< $@<br> <br> #-----------------------------------------------------------------------<br> <br> <br> It compiles with 'make' and it does work.<br> <br> I'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've read the manual a few times but I haven't done much with Makefiles <br> before so maybe I'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="mailto:[email protected]" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> <a href="https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss" rel="noreferrer" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss</a><br> </blockquote> </div> </blockquote> </body> </html> --------------s4uf8CMMgrZ1jt41Ih4W40tY-- --===============1071811267563072501== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============1071811267563072501== 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 --===============1071811267563072501==--