How to do it w/ "make" ?

How to do it w/ "make" ?

Post by Joao Nat » Sun, 06 Oct 1996 04:00:00



Hi,

Let's see if anyone can help me w/ this one.

The environment: SCO Unix OpenSever 5
                             4GL RDS 4.11.xx
                   SE 5.03.xx

The Data:

In my company we've got the following directory tree on our production
box:

   .../sources/4gl (Where all the 4GL source code is)
   .../sources/forms (Where all per goes)
   .../sources/c (The C code is here)

Our programs (.4gi) are composed of several 4GL modules. For the sake
of understanding let me give you an example:

   p.4gi depends on: m1.4gl and m2.4gl

When we need to modify a program we copy the module in question, let's
say,  m1.4gl,  to our home directory do what ever we need to do and
then recompile the program, in our example: p.4gi.

In order to do this (we can't, don't and never will do the
modifications directly on .../sources/4gl/m1.4gl) we have a shell
script that reads a makefile located in .../sources/4gl, copies the
modules nedeed to regenerate p.4gi (except m1.4gl) and do it.

The Problem:

What we really want is to discard the shell script we're using and
pass on this work to "make". The main reason is that the script isn't
aware of the "make" rules, nor it sees if the target is updated,
causing among other things, to all modules being recompiled.

The conclusion;

I've been hacking with "make" for quite a while and don't seem to get
anywhere. So if any of you kind souls, know of a way to get arround,
have any ideas, opinions, whatever, pelase let me know.

TIA

JN

 
 
 

How to do it w/ "make" ?

Post by Carlos Costa e Silv » Mon, 07 Oct 1996 04:00:00


Here's a try at your problem:

First, some assumptions:

GO=directory of the 4go files
GL=directory of the 4gl files
GI=directory of the 4gi files
FRM=...
PER=...

During testing, compiled files stay in your HOME directory.

Your production makefile should look like this:

----------------------------
# look for target files in VPATH if not found in current
directory
VPATH==$(GL):$(GO):$(PER):$(FRM)

GO_FILES= m1.4go m2.4go m3.4go m4.4go ...
GI_FILE= $(GI)/p.4gi
FRM_FILES= s1.frm s2.frm ...

.SUFFIXES: .4gl .4go .per .frm

.4gl.4go:

.per.frm:


all: $(GI_FILE) $(FRM_FILES)

$(GI_FILE): $(GO_FILES)

m1.4go: m1.4gl a.4gl ...

m2.4go: m2.4gl
...

s1.frm:s1.per
...
----------------------------

you need to copy the makefile to your HOME directory and
make some changes:

change the fglpc and the form4gl lines to compile to the
current directory:


change the cat line so that cat first looks for 4go's in
the HOME directory:
  for i in $(GO_FILES)
  do
     if [ -f $i ]; then
          cat $i >> $(GI_FILE)
     else
          cat $(GO)/$i >> $(GI_FILE);
     fi;
   done

The test Makefile should look like this:
----------------------------
# look for target files in VPATH if not found in current
directory
VPATH==$(GL):$(GO):$(PER):$(FRM)

GO_FILES= m1.4go m2.4go m3.4go ...
GI_FILE= p.4gi
FRM_FILES= s1.per s2.per ...

.SUFFIXES: .4gl .4go .per .frm

.4gl.4go:

.per.frm:

all: $(GI_FILE) $(FRM_FILES)

# note that the cat statement is optimized (only one cat)
# $$ is translated to only one $ when it reaches sh
$(GI_FILE): $(GO_FILES)

        for i in $(GO_FILES); do \
           if [ -f $$i ]; then \
              wfiles="$$wfiles $$i"; \
           else \
              wfiles="$$wfiles $(GO)/$$i"; \
           fi; \
        done; \
        cat $$wfiles > $(GI_FILE)

m1.4go: m1.4gl a.4gl ...

m2.4go: m2.4gl
...

s1.frm: s1.per
...
----------------------------

If you need anything, please e-mail me as I seldom look
into this newsgroup.

Hope this helps.

--
Carlos Costa e Silva



...
:
:    .../sources/4gl (Where all the 4GL source code is)
:    .../sources/forms (Where all per goes)
:    .../sources/c (The C code is here)
:
:
:    p.4gi depends on: m1.4gl and m2.4gl
:
...
:In order to do this (we can't, don't and never will do the
:modifications directly on .../sources/4gl/m1.4gl) we have
a shell
:script that reads a makefile located in .../sources/4gl,
copies the
:modules nedeed to regenerate p.4gi (except m1.4gl) and do
it
...
:What we really want is to discard the shell script we're
using and
:pass on this work to "make"