Skip to content

Instantly share code, notes, and snippets.

@JJL772
Last active December 14, 2023 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JJL772/fcce369fa5b0e90369bcc95af3a733a6 to your computer and use it in GitHub Desktop.
Save JJL772/fcce369fa5b0e90369bcc95af3a733a6 to your computer and use it in GitHub Desktop.
Building EPICS Base + Extensions

Building EPICS Base

For all examples, we will be using /epics as the root directory for the EPICS install. Please substitute with your own directory.

Important References

Getting the files

cd /epics

  1. Clone EPICS base to your desired directory: git clone --recursive https://github.com/epics-base/epics-base base (NOTE: The --recursive flag is necessary here, otherwise you will need to run git submodule update --init --recursive later.)
  2. Now you should have myepics/base

Setting up the environment

EPICS requires several environment variables be set. In general, it is recommended to have a script that defines the environment and location for a particular EPICS install. Only a few of these environment variables are required.

See: https://docs.epics-controls.org/en/latest/getting-started/installation-linux.html

Put the following into a script, and source this script before working with EPICS.

# Set to the arch of the machine you will be compiling with.
export EPICS_HOST_ARCH="linux-x86_64"
export EPICS_BASE="/epics/base"
export EPICS_EXTENSIONS="/epics/extensions"
export PATH="$EPICS_BASE/bin/$EPICS_HOST_ARCH:$PWD/scripts:$PATH"
export PATH="$EPICS_EXTENSIONS/bin/$EPICS_HOST_ARCH:$PATH"

# Required for EDM
export EDMOBJECTS=$EPICS_EXTENSIONS/src/edm/setup
export EDMPVOBJECTS=$EPICS_EXTENSIONS/src/edm/setup
export EDMFILES=$EPICS_EXTENSIONS/src/edm/setup
export EDMHELPFILES=$EPICS_EXTENSIONS/src/edm/helpFiles
export EDMLIBS=$EPICS_EXTENSIONS/lib/$EPICS_HOST_ARCH

# Only required if you're using the CLANG compiler
#export CC=clang
#export CXX=clang++
#export CCC=clang++
#export CMPLR_CLASS=clang

Compile

With your environment setup, you should now be able to compile EPICS base.

cd base
make -j$(nproc)

If you've done everything correctly, caget caput pvget, etc. should exist on your path.

EPICS Extensions

Extensions are software packages such as EDM or MEDM that are not designed to be used within IOCs. Building these is a little bit different than modules.

Getting the files

cd /epics

First, we will need to grab the files for the EPICS extensions directory: git clone --recursive https://github.com/epics-extensions/extensions extensions

Now, we should have the directory myepics/extensions with some content.

cd /epics/extensions/src

In the src directory within extensions, we will place our EPICS extensions. This exact setup is unfortunately required due to how EDM and other extensions have their Makefiles setup.

EDM

The first major extension we will install is EDM, or "Extensible Display Manager". This is a Motif-based tool for viewing screens.

Installing Dependencies

(NOTE: I'm testing all of this on Debian 13, but I am cross-referencing packages with Ubuntu 22.04)

Install the following via APT:

  • libpng-dev
  • libmotif-dev
  • libxm4
  • zlib1g-dev
  • libgif-dev
  • libx11-dev
  • libxtst-dev
  • libxmu-dev

Getting the files

cd /epics/extensions/src

The files may be obtained from this Github repository: https://github.com/gnartohl/edm

git clone https://github.com/gnartohl/edm

Building

If you're on Ubuntu or Debian, you will need to point the extensions makefiles at the correct library location. In /epics/extensions/configure/os/CONFIG_SITE.linux-x86_64.linux-x86_64, add the following lines to the end of the file:

X11_LIB=/usr/lib/x86_64-linux-gnu
MOTIF_LIB=/usr/lib/x86_64-linux-gnu

Modify /epics/extensions/src/Makefile to include the following patch:

diff --git a/extensions/src/Makefile b/extensions/src/Makefile
index 70b248c..d0673b6 100644
--- a/extensions/src/Makefile
+++ b/extensions/src/Makefile
@@ -45,6 +45,7 @@ JPROBE = jprobe
 KM = km
 NOBCONFIG = knobconfig
 MEDM = medm
+EDM = edm
 MOTIFBUTTON = motifButton
 EXTENSION_MSI = msi
 NAMECAPTURE = namecapture
@@ -96,6 +97,7 @@ DIRS += $(JDCT)
 DIRS += $(JPROBE)
 DIRS += $(KM)
 DIRS += $(MEDM)
+DIRS += $(EDM)
 DIRS += $(MOTIFBUTTON)
 DIRS += $(EXTENSION_MSI)
 DIRS += $(NAMECAPTURE)

This is required for EDM to compile, if you so choose to install it.

Then, compilation is as simple as:

cd /epics/extensions
make -j$(nproc)

Running

EDM will search for screens in directories listed in $EDMDATAFILES and $EPICS_DISPLAY_PATH.

Depending on your system, the default EDM font configuation may not work. It certainly didn't work on my Debian 13 system due to missing fonts that also couldn't be found in the package manager.

To fix this, you will need to modify edm/setup/fonts.list to point to courier or some other installed font family. In reality, courier doesn't actually need to be installed, EDM will fall back to some other built-in font. Nonetheless, it still requires the fonts.list be filled out.

diff --git a/setup/fonts.list b/setup/fonts.list
index b125a50..e77426d 100644
--- a/setup/fonts.list
+++ b/setup/fonts.list
@@ -2,83 +2,18 @@
 courier-bold-r-12.0
 helvetica-bold-r-12.0
 
-substitutions {
-
--misc-liberation sans-bold-r-normal--0-80-75-75-p-0-*-*=-adobe-helvetica-bold-r-normal--*-80-75-75-p-*-*-*
--misc-liberation sans-bold-i-normal--0-80-75-75-p-0-*-*=-adobe-helvetica-bold-o-normal--*-80-75-75-p-*-*-*
--misc-liberation sans-medium-r-normal--0-80-75-75-p-0-*-*=-adobe-helvetica-medium-r-normal--*-80-75-75-p-*-*-*
--misc-liberation sans-medium-i-normal--0-80-75-75-p-0-*-*=-adobe-helvetica-medium-o-normal--*-80-75-75-p-*-*-*
-
--misc-liberation sans-bold-r-normal--0-100-75-75-p-0-*-*=-adobe-helvetica-bold-r-normal--*-100-75-75-p-*-*-*
--misc-liberation sans-bold-i-normal--0-100-75-75-p-0-*-*=-adobe-helvetica-bold-o-normal--*-100-75-75-p-*-*-*
--misc-liberation sans-medium-r-normal--0-100-75-75-p-0-*-*=-adobe-helvetica-medium-r-normal--*-100-75-75-p-*-*-*
--misc-liberation sans-medium-i-normal--0-100-75-75-p-0-*-*=-adobe-helvetica-medium-o-normal--*-100-75-75-p-*-*-*
-
--misc-liberation sans-bold-r-normal--0-120-75-75-p-0-*-*=-adobe-helvetica-bold-r-normal--*-120-75-75-p-*-*-*
--misc-liberation sans-bold-i-normal--0-120-75-75-p-0-*-*=-adobe-helvetica-bold-o-normal--*-120-75-75-p-*-*-*
--misc-liberation sans-medium-r-normal--0-120-75-75-p-0-*-*=-adobe-helvetica-medium-r-normal--*-120-75-75-p-*-*-*
--misc-liberation sans-medium-i-normal--0-120-75-75-p-0-*-*=-adobe-helvetica-medium-o-normal--*-120-75-75-p-*-*-*
-
--misc-liberation sans-bold-r-normal--0-140-75-75-p-0-*-*=-adobe-helvetica-bold-r-normal--*-140-75-75-p-*-*-*
--misc-liberation sans-bold-i-normal--0-140-75-75-p-0-*-*=-adobe-helvetica-bold-o-normal--*-140-75-75-p-*-*-*
--misc-liberation sans-medium-r-normal--0-140-75-75-p-0-*-*=-adobe-helvetica-medium-r-normal--*-140-75-75-p-*-*-*
--misc-liberation sans-medium-i-normal--0-140-75-75-p-0-*-*=-adobe-helvetica-medium-o-normal--*-140-75-75-p-*-*-*
-
--misc-liberation sans-bold-r-normal--0-180-75-75-p-0-*-*=-adobe-helvetica-bold-r-normal--*-180-75-75-p-*-*-*
--misc-liberation sans-bold-i-normal--0-180-75-75-p-0-*-*=-adobe-helvetica-bold-o-normal--*-180-75-75-p-*-*-*
--misc-liberation sans-medium-r-normal--0-180-75-75-p-0-*-*=-adobe-helvetica-medium-r-normal--*-180-75-75-p-*-*-*
--misc-liberation sans-medium-i-normal--0-180-75-75-p-0-*-*=-adobe-helvetica-medium-o-normal--*-180-75-75-p-*-*-*
-
--misc-liberation sans-bold-r-normal--0-240-75-75-p-0-*-*=-adobe-helvetica-bold-r-normal--*-240-75-75-p-*-*-*
--misc-liberation sans-bold-i-normal--0-240-75-75-p-0-*-*=-adobe-helvetica-bold-o-normal--*-240-75-75-p-*-*-*
--misc-liberation sans-medium-r-normal--0-240-75-75-p-0-*-*=-adobe-helvetica-medium-r-normal--*-240-75-75-p-*-*-*
--misc-liberation sans-medium-i-normal--0-240-75-75-p-0-*-*=-adobe-helvetica-medium-o-normal--*-240-75-75-p-*-*-*
-
-
--misc-liberation mono-bold-r-normal--0-80-75-75-m-0-*-*=-adobe-courier-bold-r-normal--*-80-75-75-m-*-*-*
--misc-liberation mono-bold-i-normal--0-80-75-75-m-0-*-*=-adobe-courier-bold-o-normal--*-80-75-75-m-*-*-*
--misc-liberation mono-medium-r-normal--0-80-75-75-m-0-*-*=-adobe-courier-medium-r-normal--*-80-75-75-m-*-*-*
--misc-liberation mono-medium-i-normal--0-80-75-75-m-0-*-*=-adobe-courier-medium-o-normal--*-80-75-75-m-*-*-*
-
--misc-liberation mono-bold-r-normal--0-100-75-75-m-0-*-*=-adobe-courier-bold-r-normal--*-100-75-75-m-*-*-*
--misc-liberation mono-bold-i-normal--0-100-75-75-m-0-*-*=-adobe-courier-bold-o-normal--*-100-75-75-m-*-*-*
--misc-liberation mono-medium-r-normal--0-100-75-75-m-0-*-*=-adobe-courier-medium-r-normal--*-100-75-75-m-*-*-*
--misc-liberation mono-medium-i-normal--0-100-75-75-m-0-*-*=-adobe-courier-medium-o-normal--*-100-75-75-m-*-*-*
-
--misc-liberation mono-bold-r-normal--0-120-75-75-m-0-*-*=-adobe-courier-bold-r-normal--*-120-75-75-m-*-*-*
--misc-liberation mono-bold-i-normal--0-120-75-75-m-0-*-*=-adobe-courier-bold-o-normal--*-120-75-75-m-*-*-*
--misc-liberation mono-medium-r-normal--0-120-75-75-m-0-*-*=-adobe-courier-medium-r-normal--*-120-75-75-m-*-*-*
--misc-liberation mono-medium-i-normal--0-120-75-75-m-0-*-*=-adobe-courier-medium-o-normal--*-120-75-75-m-*-*-*
-
--misc-liberation mono-bold-r-normal--0-140-75-75-m-0-*-*=-adobe-courier-bold-r-normal--*-140-75-75-m-*-*-*
--misc-liberation mono-bold-i-normal--0-140-75-75-m-0-*-*=-adobe-courier-bold-o-normal--*-140-75-75-m-*-*-*
--misc-liberation mono-medium-r-normal--0-140-75-75-m-0-*-*=-adobe-courier-medium-r-normal--*-140-75-75-m-*-*-*
--misc-liberation mono-medium-i-normal--0-140-75-75-m-0-*-*=-adobe-courier-medium-o-normal--*-140-75-75-m-*-*-*
-
--misc-liberation mono-bold-r-normal--0-180-75-75-m-0-*-*=-adobe-courier-bold-r-normal--*-180-75-75-m-*-*-*
--misc-liberation mono-bold-i-normal--0-180-75-75-m-0-*-*=-adobe-courier-bold-o-normal--*-180-75-75-m-*-*-*
--misc-liberation mono-medium-r-normal--0-180-75-75-m-0-*-*=-adobe-courier-medium-r-normal--*-180-75-75-m-*-*-*
--misc-liberation mono-medium-i-normal--0-180-75-75-m-0-*-*=-adobe-courier-medium-o-normal--*-180-75-75-m-*-*-*
-
--misc-liberation mono-bold-r-normal--0-240-75-75-m-0-*-*=-adobe-courier-bold-r-normal--*-240-75-75-m-*-*-*
--misc-liberation mono-bold-i-normal--0-240-75-75-m-0-*-*=-adobe-courier-bold-o-normal--*-240-75-75-m-*-*-*
--misc-liberation mono-medium-r-normal--0-240-75-75-m-0-*-*=-adobe-courier-medium-r-normal--*-240-75-75-m-*-*-*
--misc-liberation mono-medium-i-normal--0-240-75-75-m-0-*-*=-adobe-courier-medium-o-normal--*-240-75-75-m-*-*-*
-
-}
-
 # note that a tab separates the font spec and the word "exact"
-courier=-misc-liberation mono-(medium,bold)-(r,i)-normal--0-(80=90,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-m-0-*-*      exact
+#courier=-misc-liberation mono-(medium,bold)-(r,i)-normal--0-(80=90,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-m-0-*-*     exact
 
-helvetica=-misc-liberation sans-(medium,bold)-(r,i)-normal--0-(80,100,120,140,160=150,180,200,240,280,320,360,420,480,600,720)-75-75-p-0-*-*   exact
+#helvetica=-misc-liberation sans-(medium,bold)-(r,i)-normal--0-(80,100,120,140,160=150,180,200,240,280,320,360,420,480,600,720)-75-75-p-0-*-*  exact
 
 # note that lists of candidate fonts may be specified as follows:
 
-#courier={
-#-misc-liberation mono-(medium,bold)-(r,i)-normal--0-(80=90,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-m-0-*-*     exact
-#-adobe-courier-(medium,bold)-(r,o)-normal--0-(80,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-*-0-*-1
-#-monotype-arial-(medium,bold)-(r,i)-normal--*-(80,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-p-*-*-*
-#}
+courier={
+-misc-liberation mono-(medium,bold)-(r,i)-normal--0-(80=90,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-m-0-*-*      exact
+-adobe-courier-(medium,bold)-(r,o)-normal--0-(80,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-*-0-*-1
+-monotype-arial-(medium,bold)-(r,i)-normal--*-(80,100,120,140,160,180,200,240,280,320,360,420,480,600,720)-75-75-p-*-*-*
+}
 
 #helvetica={
 #-misc-liberation sans-(medium,bold)-(r,i)-normal--0-(80,100,120,140,160=150,180,200,240,280,320,360,420,480,600,720)-75-75-p-0-*-*    exact

Once you have this done, and your environment setup (as per Setting up the environment, you can run edm with edm.

EPICS Modules

Modules are libraries based on EPICS base that are designed to be used by IOC applications. They may include support for different types of hardware, general utilities for the IOC engineers, new record types and plenty more.

The general convention for modules is that they will live in the modules directory under a particular EPICS installation.

Unlike extensions, the build configuration for these is generally done using RELEASE.local files, which override content specified within their configure/RELEASE file. configure/RELEASE tells the module where its dependencies live, and it supplies additional configuration flags to the module for build.

In this guide, we will go over building the asyn module. Asyn is one of the most commonly used EPICS modules, as it forms the basis for threaded asynchronous device support modules.

Creating the directories

cd /epics
mkdir modules

Installing Dependencies (for asyn)

  • libtirpc-dev

Getting the files (for asyn)

git clone https://github.com/epics-modules/asyn

Configuring the build

cd /epics/modules/asyn

The first step to building any module is to configure the build using a RELEASE.local file. These are ignored by .gitignore, and generally should not be committed to the repository.

Create configure/RELEASE.local

Now, open configure/RELEASE to see what it contains. For asyn, it looks like this:


```make
#RELEASE Location of external products

SUPPORT=/corvette/home/epics/devel

# IPAC is only necessary if support for Greensprings IP488 is required
# IPAC release V2-7 or later is required.
# It can be obtained here: https://github.com/epics-modules/ipac
IPAC=$(SUPPORT)/ipac-2-15

# SEQ is required for testIPServer
# It can be obtained here: https://www-csr.bessy.de/control/SoftDist/sequencer/Manual.html
SNCSEQ=$(SUPPORT)/seq-2-2-5

# For sCalcout support in asynOctet - applications include asynCalc.dbd
# It can be obtained here: https://github.com/epics-modules/calc
CALC=$(SUPPORT)/calc-3-7-3

# If CALC was built with SSCAN support then SSCAN must be defined for testEpicsApp
# It can be obtained here: https://github.com/epics-modules/sscan
SSCAN=$(SUPPORT)/sscan-2-11-3

#  EPICS_BASE 3.14.6 or later is required
#  It can be obtained here: https://github.com/epics-base/epics-base
EPICS_BASE=/corvette/usr/local/epics-devel/base-7.0.5

-include $(TOP)/../RELEASE.local
-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local
-include $(TOP)/configure/RELEASE.local

As you can see, the default RELEASE file provided by asyn is very much site-specific to the author's workstation. We'll need to change that.

For this example, we will not be enabling IPAC support, testIPServer or sCalcout support in asynOctet.

Additionally, on modern Linux systems (i.e. Debian 13, Ubuntu 22.04), the RPC library is no longer provided by glibc and is instead in a separate package called tirpc. asyn has a flag we can enable in RELEASE.local to enable that, if we're building on a modern system.

Thus, our RELEASE.local will look like this:

IPAC=
SNCSEQ=
SSCAN=
CALC=

# Enable libtirpc. Required for modern linux
TIRPC=YES

SUPPORT=/epics/modules
EPICS_BASE=/epics/base

# If you build and install calc, specify it like this:
CALC=$(SUPPORT)/calc

Building

Build, and you're done!

make

Module Build Instructions

This document covers build instructions for some of the core EPICS modules.

calc

cd /epics/modules

git clone https://github.com/epics-modules/calc
cd calc

configure/RELEASE.local:

SUPPORT=/epics/modules
EPICS_BASE=/epics/base

SSCAN=

modbus

cd /epics/modules

git clone https://github.com/epics-modules/modbus.git
cd modbus

configure/RELEASE.local:

SUPPORT=/epics/modules
EPICS_BASE=/epics/base

ASYN=$(SUPPORT)/asyn

autosave

cd /epics/modules

git clone https://github.com/epics-modules/autosave.git
cd autosave

configure/RELEASE.local:

SUPPORT=/epics/modules
EPICS_BASE=/epics/base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment