Commit 7d302088 authored by rdubner's avatar rdubner

Modify Makefiles to handle DESTDIR and 'make uninstall'

parent 17fca396
CXXFLAGS = -std=c++11 -Wall
CXXFLAGS:=-std=c++11 -Wall
export CXXFLAGS
DESTDIR ?=/usr/local
# Don't try to build the optfde01 example until the cobcd script
# can be found in /usr/local/bin/
COBCDEXISTS=$(wildcard /usr/local/bin/cobcd)
COBCD=/usr/local/bin/cobcd
CWD=$(shell basename `pwd`)
COBCDEXISTS:=$(wildcard /usr/local/bin/cobcd)
COBCD:=/usr/local/bin/cobcd
CWD:=$(shell basename `pwd`)
.PHONY : all
.PHONY : all
all: cobcd cobcd.bat
## Make sure the VERSION text in cobcd.py is up-to-date
$(MAKE) -C python
......@@ -28,7 +30,7 @@ clean:
$(MAKE) -C cobcd-st clean
$(MAKE) -C cobcd-sfix clean
$(MAKE) -C optfde01 clean
cobcd : include/version.h
bin/version-replace.sh $@ $^
......@@ -37,29 +39,31 @@ cobcd.bat : include/version.h
.PHONY : install
install:
ifdef DESTDIR
mkdir -p $(DESTDIR)/bin/
install cobcd $(DESTDIR)/bin/
install cobcd.bat $(DESTDIR)/bin/
else
mkdir -p /usr/local/bin/
install cobcd /usr/local/bin/
install cobcd.bat /usr/local/bin/
endif
$(MAKE) -C cobcd-st install
$(MAKE) -C cobcd-sfix install
$(MAKE) -C python install
# $(MAKE) -C vsdistrib install
.PHONY : uninstall
uninstall:
rm -f $(DESTDIR)/bin/cobcd
rm -f $(DESTDIR)/bin/cobcd.bat
$(MAKE) -C cobcd-st uninstall
$(MAKE) -C cobcd-sfix uninstall
$(MAKE) -C python uninstall
# copy cbl-gdb to cblgdb-x.y, tarball the copy, and delete the copy
.PHONY : package
package : clean
./bin/package.sh
# Dubner likes to work in Windows, using Visual Studio. This can result in
# Windows-style CRLF line endings. He also likes to work with C++ code
# formatted with Whitesmith style brace formatting. This rule fixes the
# potential problems that might arise by running dos2unix on the various files,
# Windows-style CRLF line endings. He also likes to work with C++ code
# formatted with Whitesmith style brace formatting. This rule fixes the
# potential problems that might arise by running dos2unix on the various files,
# followed by `astyle --style=kr` for Kernighan & Ritchie brace formatting.
.PHONY : pregit
pregit:
......
......@@ -2,26 +2,49 @@
These are the source files for building the tools that make up the COBOLworx debugging extensions for GnuCOBOL.
You'll need to have GnuCOBOL Version 3.x-dev (or later) installed.
## Requirements
Building the source, and installing the binaries and scripts into /usr/local, operates as you'd generally expect:
You'll need to have GnuCOBOL Version 3.1 (or later) installed. 3.1 has features needed by these extensions.
These tools are known to compile with GCC-4.8.5 and later. They have been demonstrated to work on Centos7/RHEL7, Centos8/RHEL8, and Ubuntu18.4
Actual debugging requires that your version of GDB was compiled with Python2 or Python3 support. The default installations of GDB in the above-mentioned operating systems are known to have Python support.
## Building and Installation
Building the source, and installing the binaries and scripts operates as you'd generally expect:
make
sudo make install
By default, the executables are installed in /usr/local/bin. If you choose to install them elsewhere, you can do it like this:
sudo make DESTDIR=<prefix> install
will cause the executables to be installed in <prefix>/bin
The installation can be reversed with one or the other of
sudo make uninstall
sudo make DESTDIR=<prefix> uninstall
## How to use the debugging extensions
Using the debugging extensions is generally a case of using the cobcd script where you'd ordinarily use the cobc command to compile a COBOL program:
Where you would enter the command
cobc -x hello.cbl
cobc -x prog.cbl
you instead enter
cobcd -x hello.cbl
cobcd -x prog.cbl
After that, you can debug the resulting binary with
gdb ./hello
gdb ./prog
## Source code for the extensions
The source code for the extension is in:
......@@ -34,23 +57,23 @@ Utility scripts used during development and deployment are found in
bin/
optfde01 is a COBOL program that, while simple, is a little more interesting than "hello, world". (It reads three records from one file and writes them to another.) After you do a 'make install' you'll be able to enter this directory and run the Makefile. optfde01 also serves as an example of how to use Visual Studio Code to debug COBOL. The optfde01/.vscode/ subdirectory contains the launch.json and tasks.json files that you'll clone into your own projects. The program is found in the directory
## Sample code for debugging
The directory `optfde01/` contains a COBOL program that, while simple, is a little more interesting than "hello, world". (It reads three records from one file and writes them to another.) After you do a 'make install' you'll be able to enter this directory and run the Makefile. optfde01 also serves as an example of how to use Visual Studio Code to debug COBOL. The optfde01/.vscode/ subdirectory contains the launch.json and tasks.json files that you'll clone into your own projects. The program is found in the directory
optfde01/
## GIT repository structure
It should be emphasized that there are now two branches that are required to be present:
There are two branches that are required to be present:
origin/master is supposed to be stable and buildable at all times.
origin/relcan, for "release candidate", is used by the cbl-gdb-distribution repositories package-
building routines for creating packages. My procedure lately has been to fuss and fiddle
with relcan until the completed final packages work properly, and then merge relcan into
master. That merge gets tagged as a release version, and at that point ../include/version.h
is incremented.
origin/relcan, for "release candidate", is used by the cbl-gdb-distribution repositories package-building routines for creating packages. My procedure lately has been to fuss and fiddle with relcan until the completed final packages work properly, and then merge relcan into master. That merge gets tagged as a release version, and at that point ../include/version.h is incremented. The build process has scripts that propogate version.h through the various executables.
*Note: you may notice a branch named `bobdev`. It is what it sounds like: a place where I am doing development. It probably should come with a sign over the door: **Here there be dragons**.*
Feel free to contact me with any questions or problems.
2020-05-07
2020-07-07
Bob Dubner
COBOLworx
......
project=cobcd-sfix
CPP = g++
src = $(wildcard *.cpp)
obj = $(src:.cpp=.o)
dep = $(obj:.o=.d) # one dependency file for each source
DESTDIR ?=/usr/local
src := $(wildcard *.cpp)
obj := $(src:.cpp=.o)
dep := $(obj:.o=.d) # one dependency file for each source
$(project) : $(obj)
$(CPP) -o $@ $^
......@@ -30,10 +32,9 @@ pregit:
.PHONY : install
install :
ifdef DESTDIR
mkdir -p $(DESTDIR)/bin/
install $(project) $(DESTDIR)/bin/
else
install $(project) /usr/local/bin/
endif
\ No newline at end of file
.PHONY : uninstall
uninstall :
rm -f $(DESTDIR)/bin/$(project)
......@@ -69,8 +69,8 @@ GetInputFileMappings(const VSTRING &input_file, const string &primary_file)
retval[primary_file] = -1;
for(VSTRING::const_iterator it=input_file.begin();
it!=input_file.end();
it++) {
it!=input_file.end();
it++) {
string s = *it;
s = Trim(s);
if( s.find(".file ") != string::npos) {
......@@ -93,8 +93,8 @@ FindFunctionReferences(const VSTRING &input_file)
VINT retval;
int nline = 0;
for(VSTRING::const_iterator it=input_file.begin();
it!=input_file.end();
it++) {
it!=input_file.end();
it++) {
string s = *it;
if( s.find(".globl") != string::npos) {
VSTRING tokens = Split(s,"\t ");
......
......@@ -116,6 +116,6 @@ Replace(const string &s,const char was, const char is)
int
STOI(const string &s)
{
{
return atoi(s.c_str());
}
}
project=cobcd-st
CPP = g++
src = $(wildcard *.cpp)
obj = $(src:.cpp=.o)
dep = $(obj:.o=.d) # one dependency file for each source
DESTDIR ?=/usr/local
src := $(wildcard *.cpp)
obj := $(src:.cpp=.o)
dep := $(obj:.o=.d) # one dependency file for each source
$(project) : $(obj)
$(CPP) -o $@ $^
......@@ -35,10 +37,9 @@ pregit:
.PHONY : install
install :
ifdef DESTDIR
mkdir -p $(DESTDIR)/bin/
install $(project) $(DESTDIR)/bin/
else
install $(project) /usr/local/bin/
endif
\ No newline at end of file
.PHONY : uninstall
uninstall :
rm -f $(DESTDIR)/bin/$(project)
......@@ -233,7 +233,7 @@ OpenOrFail(std::ofstream &ofs,const std::string &fname,std::ios_base::openmode m
}
}
void
void
PARAMETERS::GetParameters(int argc, char *argv[])
{
if(argc < 2) {
......
......@@ -2,6 +2,8 @@
project=cobcd.py
DESTDIR ?=/usr/local
AUTO_LOAD_FOUND := $(shell grep -s -e "^[ \t]*set auto-load safe-path /" ~/.gdbinit | wc -l)
AUTO_SCRIPTS_FOUND := $(shell grep -s -e "^[ \t]*set auto-load python-scripts on" ~/.gdbinit | wc -l)
......@@ -23,15 +25,14 @@ pregit:
# By default, gdb doesn't put the current working directory onto the list
# of safe auto-load directories. There is a default safe directory, but that
# directory isn't on the search path. So, one way or the other, the user's
# .gdbinit file has to be modified. I have chosen to defeat the default
# .gdbinit file has to be modified. I personally have chosen to defeat the default
# security setting to allow auto-load from anywhere.
#
.PHONY : install
install :
ifdef DESTDIR
mkdir -p $(DESTDIR)/bin/
install $(project) $(DESTDIR)/bin/
else
install $(project) /usr/local/bin/
endif
.PHONY : uninstall
uninstall :
rm -f $(DESTDIR)/bin/$(project)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment