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

Subject: Re: EPICS app, Db Makefile, rule for python-generated Db file
From: "Wells, Alex \(DLSLtd,RAL,LSCI\) via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, Andrea Celentano <andrea.celentano at ge.infn.it>
Date: Tue, 6 May 2025 08:07:35 +0000
Hi Andrea,

The Makefile modifications are reasonably straightforward. The way I normally do this is as follows:

  • Have the Database specified in the "DB" macro; i.e. "DB += myDb.db" (this probably already exists in your IOC's Db/Makefile file)
  • Have a file named "myDb.py". This is your epicsdbbuilder script.
    • Ensure this file outputs its results to "sys.argv[1]", for reasons explained below
  • Add this rule to the Makefile, below that line. Note the "python" line should be indented with a tab:
    %.db: ../%.py
        python $< $@

After this, running "make" should work as expected and you should see "myDb.db" appear in the built top level "db" folder.

To explain the Makefile magic:
  • %.db expands to the name of the database file the EPICS build system is currently trying to build
  • ../%.py will cause EPICS to target the Python file of the same name as the database file
  • python $< $@ will execute "python", passing "$<" (the file path to the Python script) and "$@", the full file path to the database being created. This is why you need to output the database contents to "sys.argv[1]".

Hope that helps!

Alex Wells

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Andrea Celentano via Tech-talk <tech-talk at aps.anl.gov>
Sent: Friday, May 2, 2025 10:54 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: EPICS app, Db Makefile, rule for python-generated Db file
 
Dear colleagues,
when developing the EPICS apps that I need, typically I use python scripts to generate Db files, using “epicsdbbuilder” tool (https://github.com/DiamondLightSource/epicsdbbuilder).

At this moment, my development flow is as follows. I create the python file to build the database file inside the “Db” folder, then I manually execute it, and then I run make.

Indeed, in the default Makefile obtained from “makeBaseApp.pl -t ioc”, I see that the last lines read:

#----------------------------------------

#  ADD RULES AFTER THIS LINE


This means that I can, in principle, add a rule so that the python script is executed automatically. However, I am not familiar enough with EPICS compilation system (and in general with Makefile) to write this rule. May I ask you for suggestions?

Thanks,
Bests,
Andrea Celentano

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom.

Replies:
Re: EPICS app, Db Makefile, rule for python-generated Db file Johnson, Andrew N. via Tech-talk
References:
EPICS app, Db Makefile, rule for python-generated Db file Andrea Celentano via Tech-talk

Navigate by Date:
Prev: IOC warning when connecting to 64 devices Abdalla Ahmad via Tech-talk
Next: Re: IOC warning when connecting to 64 devices Ralph Lange 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  2023  2024  <2025
Navigate by Thread:
Prev: EPICS app, Db Makefile, rule for python-generated Db file Andrea Celentano via Tech-talk
Next: Re: EPICS app, Db Makefile, rule for python-generated Db file Johnson, Andrew N. 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  2023  2024  <2025
ANJ, 06 May 2025 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·