Skip to content

Instantly share code, notes, and snippets.

@kng
Last active August 18, 2022 16:41
Show Gist options
  • Save kng/67f9793532a6e873c50a9dab427b3727 to your computer and use it in GitHub Desktop.
Save kng/67f9793532a6e873c50a9dab427b3727 to your computer and use it in GitHub Desktop.
raspberry pi pgplot build
wget ftp://ftp.astro.caltech.edu/pub/pgplot/pgplot5.2.tar.gz
tar zxvf pgplot5.2.tar.gz
cd pgplot
mkdir build
cd build
# fetch drivers.diff
# fetch makefile.diff
cp ../drivers.list .
patch -l drivers.list drivers.diff
../makemake .. linux f77_gcc
patch -l makefile makefile.diff
make all cpg
sudo make install
sudo ldconfig
--- ../drivers.list 2000-05-04 06:02:15.000000000 +0100
+++ drivers.list 2022-08-09 12:48:08.207524157 +0100
@@ -37,7 +37,7 @@
! NEDRIV 0 /NEXT Computers running NeXTstep operating system
NUDRIV 0 /NULL Null device (no output) Std F77
! PGDRIV 0 /PGMF PGPLOT metafile (new format, experimental) Std F77
-! PNDRIV 1 /PNG Portable Network Graphics file C
+ PNDRIV 1 /PNG Portable Network Graphics file C
! PNDRIV 2 /TPNG Portable Network Graphics file - transparent background C
! PPDRIV 1 /PPM Portable Pixel Map file, landscape
! PPDRIV 2 /VPPM Portable PIxel Map file, portrait
@@ -68,8 +68,8 @@
! WDDRIV 2 /VWD X Window dump file, portrait
! WSDRIV 0 /WS VAX workstations running VWS software VMS
! X2DRIV 0 /XDISP PGDISP or FIGDISP server for X workstations C
-! XWDRIV 1 /XWINDOW Workstations running X Window System C
-! XWDRIV 2 /XSERVE Persistent window on X Window System C
+ XWDRIV 1 /XWINDOW Workstations running X Window System C
+ XWDRIV 2 /XSERVE Persistent window on X Window System C
! ZEDRIV 0 /ZETA Zeta 8 Digital Plotter
!
! The following drivers can only be used in PGPLOT installations on MS-DOS
--- makefile.orig 2022-08-18 18:26:37.255152775 +0200
+++ makefile 2022-08-18 18:34:42.650791839 +0200
@@ -19,11 +19,12 @@
XMDIR=../drivers/xmotif
XADIR=../drivers/xathena
TKDIR=../drivers/xtk
+DESTDIR=/usr/local
#
# Fortran compiler and compilation flags
#
FCOMPL=f77
-FFLAGC=-u
+FFLAGC=-fPIC
FFLAGD=
#
# C compiler and compilation flags
@@ -34,7 +35,7 @@
TK_INCL=-I/usr/include
RV_INCL=
CCOMPL=gcc
-CFLAGC=-DPG_PPU -O2 -I.
+CFLAGC=-DPG_PPU -O2 -I. -fPIC
CFLAGD=-O2
MCOMPL=
MFLAGC=
@@ -52,13 +53,14 @@
#
# Loader command for PGPLOT library
#
-PGPLOT_LIB=-L`pwd` -lpgplot -lpng -lz
-CPGPLOT_LIB=-L`pwd` -lcpgplot -lpgplot -lpng -lz
+PGPLOT_LIB=-L`pwd` -lpgplot -lpng14 -lz -L/usr/local/lib/
+CPGPLOT_LIB=-L`pwd` -lcpgplot -lpgplot -lpng14 -lz -L/usr/local/lib/
#
# Shared library creation.
#
SHARED_LIB=
SHARED_LD=
+LD=ld
#
# The libraries that the shared PGPLOT library depends upon.
# This is for systems that allow one to specify what libraries
@@ -67,7 +69,7 @@
# the library don't have to list a slew of other implementation-specific
# libraries when they link their executables.
#
-SHARED_LIB_LIBS=
+SHARED_LIB_LIBS= -Wl,-Bstatic -L/usr/X11R6/lib -lX11 -L/usr/local/lib/ -lpng14 -lz -lg2c -Wl,-Bdynamic
#
# Ranlib command if required
#
@@ -689,6 +691,8 @@
$(PG_NON_STANDARD) $(GR_ROUTINES) $(DISPATCH_ROUTINE) \
$(DRIVERS) $(SYSTEM_ROUTINES) | sort | uniq`
$(RANLIB) libpgplot.a
+ $(LD) -shared -o libpgplot.so --whole-archive libpgplot.a
+
#-----------------------------------------------------------------------
@@ -841,7 +845,19 @@
#-----------------------------------------------------------------------
# Target "install" is required for Figaro.
#-----------------------------------------------------------------------
-install:
+install: libcpgplot.a libcpgplot.so libpgplot.a libpgplot.so cpgplot.h pgxwin_server grfont.dat rgb.txt
+ install -d $(DESTDIR)/lib/
+ install -m 755 libcpgplot.a $(DESTDIR)/lib/
+ install -m 755 libcpgplot.so $(DESTDIR)/lib/
+ install -m 755 libpgplot.a $(DESTDIR)/lib/
+ install -m 755 libpgplot.so $(DESTDIR)/lib/
+ install -d $(DESTDIR)/include/
+ install -m 644 cpgplot.h $(DESTDIR)/include/
+ install -d $(DESTDIR)/pgplot/
+ install -m 755 pgxwin_server $(DESTDIR)/pgplot/
+ install -m 644 grfont.dat $(DESTDIR)/pgplot/
+ install -m 644 rgb.txt $(DESTDIR)/pgplot/
+
#-----------------------------------------------------------------------
# Target "clean" is used to remove all the intermediate files.
@@ -871,7 +887,7 @@
grivas.o : $(DRVDIR)/gadef.h
grtv00.o : $(DRVDIR)/imdef.h
pgxwin.o : $(DRVDIR)/pgxwin.h
-pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h
+#pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h
x2driv.o figdisp_comm.o: $(DRVDIR)/commands.h
@@ -894,6 +910,7 @@
rm -f cpg*.c
ar ru libcpgplot.a cpg*.o
$(RANLIB) libcpgplot.a
+ $(LD) -shared -o libcpgplot.so --whole-archive libcpgplot.a
rm -f cpg*.o
cpgdemo: cpgplot.h $(SRC)/cpg/cpgdemo.c libcpgplot.a
--- makefile 2022-08-17 19:35:32.470745987 +0100
+++ makefile.new 2022-08-17 19:35:19.650755359 +0100
@@ -19,11 +19,12 @@
XMDIR=../drivers/xmotif
XADIR=../drivers/xathena
TKDIR=../drivers/xtk
+DESTDIR=/usr/local
#
# Fortran compiler and compilation flags
#
FCOMPL=f77
-FFLAGC=-u
+FFLAGC=
FFLAGD=
#
# C compiler and compilation flags
@@ -52,13 +53,14 @@
#
# Loader command for PGPLOT library
#
-PGPLOT_LIB=-L`pwd` -lpgplot -lpng -lz
-CPGPLOT_LIB=-L`pwd` -lcpgplot -lpgplot -lpng -lz
+PGPLOT_LIB=-L`pwd` -lpgplot -lpng14 -lz -L/usr/local/lib/
+CPGPLOT_LIB=-L`pwd` -lcpgplot -lpgplot -lpng14 -lz -L/usr/local/lib/
#
# Shared library creation.
#
SHARED_LIB=
SHARED_LD=
+LD=ld
#
# The libraries that the shared PGPLOT library depends upon.
# This is for systems that allow one to specify what libraries
@@ -67,7 +69,7 @@
# the library don't have to list a slew of other implementation-specific
# libraries when they link their executables.
#
-SHARED_LIB_LIBS=
+SHARED_LIB_LIBS= -Wl,-Bstatic -L/usr/X11R6/lib -lX11 -L/usr/local/lib/ -lpng14 -lz -lg2c -Wl,-Bdynamic
#
# Ranlib command if required
#
@@ -689,6 +691,8 @@
$(PG_NON_STANDARD) $(GR_ROUTINES) $(DISPATCH_ROUTINE) \
$(DRIVERS) $(SYSTEM_ROUTINES) | sort | uniq`
$(RANLIB) libpgplot.a
+ $(LD) -shared -o libpgplot.so --whole-archive libpgplot.a
+
#-----------------------------------------------------------------------
@@ -841,7 +845,19 @@
#-----------------------------------------------------------------------
# Target "install" is required for Figaro.
#-----------------------------------------------------------------------
-install:
+install: libcpgplot.a libcpgplot.so libpgplot.a libpgplot.so cpgplot.h pgxwin_server grfont.dat rgb.txt
+ install -d $(DESTDIR)/lib/
+ install -m 755 libcpgplot.a $(DESTDIR)/lib/
+ install -m 755 libcpgplot.so $(DESTDIR)/lib/
+ install -m 755 libpgplot.a $(DESTDIR)/lib/
+ install -m 755 libpgplot.so $(DESTDIR)/lib/
+ install -d $(DESTDIR)/include/
+ install -m 644 cpgplot.h $(DESTDIR)/include/
+ install -d $(DESTDIR)/pgplot/
+ install -m 755 pgxwin_server $(DESTDIR)/pgplot/
+ install -m 644 grfont.dat $(DESTDIR)/pgplot/
+ install -m 644 rgb.txt $(DESTDIR)/pgplot/
+
#-----------------------------------------------------------------------
# Target "clean" is used to remove all the intermediate files.
@@ -871,7 +887,7 @@
grivas.o : $(DRVDIR)/gadef.h
grtv00.o : $(DRVDIR)/imdef.h
pgxwin.o : $(DRVDIR)/pgxwin.h
-pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h
+#pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h
x2driv.o figdisp_comm.o: $(DRVDIR)/commands.h
@@ -894,6 +910,7 @@
rm -f cpg*.c
ar ru libcpgplot.a cpg*.o
$(RANLIB) libcpgplot.a
+ $(LD) -shared -o libcpgplot.so --whole-archive libcpgplot.a
rm -f cpg*.o
cpgdemo: cpgplot.h $(SRC)/cpg/cpgdemo.c libcpgplot.a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment