EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: Re: makefile compilation question
From: timesir via Tech-talk <tech-talk at aps.anl.gov>
To: NICOLE Remi <remi.nicole at cea.fr>, tech-talk at aps.anl.gov
Date: Wed, 24 May 2023 04:07:32 +0800
Dear:
     Thanks for your reply. Can you teach me more about epicsbase/configure/RULES_BUILD? In particular, I still can't understand how the code is compiled out and how the include, library is compiled together with the application code.

NICOLE Remi <remi.nicole at cea.fr> 于2023年5月23日周二 15:16写道:
This rule is a "static pattern rule"[1], it allows specifying multiple
targets, while also pattern matching with "%".

[1]:
https://www.gnu.org/software/make/manual/html_node/Static-Usage.html

Suppose we have 'DIRS = dir1'. Expanded, this rule looks like this:

    # Targets
    linux-x86_64 \
      inc build install ... \
      inc.linux-x86_64 build.linux-x86_64 install.linux-x86_64 \
        # Pattern match with "%" \
        :%: \
          # Dependencies \
          dir1.%


- 'linux-x86_64' comes from ARCH
- 'inc build install ...' comes from ACTIONS
- 'inc.linux-x86_64 build.linux-x86_64 install.linux-x86_64' comes from
actionArchTargets

If we run 'make install', this will match this rule, since install is
in it. Then make will pattern match the target 'install' with '%',
which matches everything.

make then looks up dependencies for the target 'install', which is
'dir1.%', which gets replaced with 'dir1.install'.

Afterwards, we go into the other rule I mentionned, which gets expanded
to something like this:

    # Targets
    dir1 \
      dir1.inc dir1.build dir1.install ... \
      dir1.linux-x86_64 \
      dir1.inc.linux-x86_64 dir1.build.linux-x86_64 ...: \
        # Recipe
        #            ,--- Fetches the dir part of the target
        #          vvvvvvvvvv
        $(MAKE) -C $(dirPart) $(actionArchPart)
        #                     ^^^^^^^^^^^^^^^^^
        #                            |
        # Fetches the action part of the target


--
Rémi NICOLE <remi.nicole at cea.fr>
CEA/DRF/IRFU/DIS/LDISC

On Tue, 2023-05-23 at 01:37 +0800, timesir wrote:
> hello,
>     I still don't understand it very well, please explain it in
> detail. Especially 
>
> beforeActions = $(addprefix before-,$(ACTIONS))
> $(beforeActions):
> $(ARCHS) $(ACTIONS) $(actionArchTargets) :%: \
>     $(foreach dir, $(DIRS), $(dir)$(DIVIDER)%)
>
> NICOLE Remi via Tech-talk <tech-talk at aps.anl.gov> 于2023年5月22日周一
> 19:23写道:
> > Hey there!
> >
> > From my understanding:
> >
> > In epics-base/configure/RULES_DIR, you will find:
> >
> >     $(DIRS) $(dirActionTargets) $(dirArchTargets)
> > $(dirActionArchTargets):
> >         $(MAKE) -C $(dirPart) $(actionArchPart)
> >
> > which makes it so that 'make myApp.install' will run 'make -C myApp
> > install'.
> >
> > and
> >
> >     $(ARCHS) $(ACTIONS) $(actionArchTargets) :%: \
> >         $(foreach dir, $(DIRS), $(dir)$(DIVIDER)%)
> >
> > will make it so that 'install' depends on every '$(dir).install'
> >
> > Then, in epics-base/configure/RULES, it includes RULES_ARCH, which
> > conceptually "splits" the build for every wanted architecture,
> > which
> > then re-includes RULES but the second time, it goes into
> > RULES_BUILD,
> > which defines rules for building libraries, executables, and so on
> > for
> > the specified architecture (T_A).
> >
> > Hope it helps.
> >

References:
makefile compilation question timesir via Tech-talk
Re: makefile compilation question NICOLE Remi via Tech-talk
Re: makefile compilation question timesir via Tech-talk
Re: makefile compilation question NICOLE Remi via Tech-talk

Navigate by Date:
Prev: motor R7-3 released Kevin Peterson via Tech-talk
Next: How to prevent deadlock for ca_clear_channel() Wang, Lin via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
Navigate by Thread:
Prev: Re: makefile compilation question NICOLE Remi via Tech-talk
Next: no bin file lynn via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
ANJ, 24 May 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·