EPICS Home

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  2025  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  2025 
<== Date ==> <== Thread ==>

Subject: Re: makefile compilation question
From: NICOLE Remi via Tech-talk <tech-talk at aps.anl.gov>
To: "mrlong336 at gmail.com" <mrlong336 at gmail.com>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Tue, 23 May 2023 07:15:56 +0000
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.
> > 

Replies:
Re: makefile compilation question timesir via Tech-talk
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

Navigate by Date:
Prev: RE: warning: multiple interrupt callbacks between processing when running testAsynPortDriverApp Wang, Lin via Tech-talk
Next: Re: When I use an IOC in a container, streamDevice occasionally reports that protocol has been aborted, which causes the records in the IOC to become inaccessible from the host computer. Zimoch Dirk 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  2025 
Navigate by Thread:
Prev: Re: makefile compilation question timesir via Tech-talk
Next: Re: makefile compilation question timesir 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  2025