Commit 160cd100 authored by Bob Dubner's avatar Bob Dubner
Browse files

Intermediate development on the way to version 0.5 with 'make install'

parent 42c18ac5
CXXFLAGS = -std=c++11
export CXXFLAGS
all:
$(MAKE) -C cobst
$(MAKE) -C obmod
$(MAKE) -C samples
.PHONY : clean
clean:
$(MAKE) -C cobst clean
$(MAKE) -C obmod clean
$(MAKE) -C samples clean
# 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 that by running dos2unix
# on the various files, followed by `astyle --style=kr` for Kernighan & Ritchie
# brace formatting.
.PHONY : pregit
pregit:
$(MAKE) -C cobst pregit
$(MAKE) -C obmod pregit
CXXFLAGS = -std=c++11
export CXXFLAGS
all:
$(MAKE) -C cobst
$(MAKE) -C obmod
$(MAKE) -C samples
.PHONY : clean
clean:
$(MAKE) -C cobst clean
$(MAKE) -C obmod clean
$(MAKE) -C samples clean
.PHONY : install
install:
$(MAKE) -C cobst install
$(MAKE) -C obmod install
$(MAKE) -C python install
# 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,
# followed by `astyle --style=kr` for Kernighan & Ritchie brace formatting.
.PHONY : pregit
pregit:
$(MAKE) -C cobst pregit
$(MAKE) -C obmod pregit
$(MAKE) -C python pregit
......@@ -3,12 +3,12 @@ CPP = g++
src = $(wildcard *.cpp)
obj = $(src:.cpp=.o)
dep = $(obj:.o=.d) # one dependency file for each source
dep = $(obj:.o=.d) # one dependency file for each source
$(project) : $(obj)
$(CPP) -o $@ $^
-include $(dep) # include all dep files in the makefile
-include $(dep) # include all dep files in the makefile
# rule to generate a dep file by using the C preprocessor
# (see man cpp for details on the -MM and -MT options)
......@@ -27,3 +27,8 @@ pregit:
dos2unix .gitignore
astyle -n --style=kr *.h
astyle -n --style=kr *.cpp
.PHONY : install
install :
install $(project) /usr/local/bin/
\ No newline at end of file
......@@ -171,7 +171,7 @@ static void Usage()
cerr << "Generates FileName.tab containing the symbol table data\n";
cerr << "-q suppresses the one-line version announcement\n";
cerr << "-v generates the one-line version announcement and exits\n";
}
}
void OpenOrFail(std::ifstream &ifs,const std::string &fname,std::ios_base::openmode mode/* = std::ifstream::in*/)
{
......@@ -210,8 +210,8 @@ PARAMETERS GetParameters(int argc, char *argv[])
case 'q':
retval.quiet = true;
case 'v':
cerr << "cobst: Cobol Symbol Table generator version: "
<< VERSION << endl;
cerr << "cobst: Cobol Symbol Table generator version: "
<< VERSION << endl;
exit(0);
case '?':
fprintf (stderr, "Unknown option '-%c'.\n", optopt);
......
......@@ -27,3 +27,8 @@ pregit:
dos2unix .gitignore
astyle -n --style=kr *.h
astyle -n --style=kr *.cpp
.PHONY : install
install :
install $(project) /usr/local/bin/
\ No newline at end of file
GDB_DATA_DIRECTORY := $(shell echo 'show data-directory'|gdb -q |tr -cd [:print:]|sed -e 's/.*\"\(.*\)\".*/\1/')
.PHONY: all
all :
@echo There is actually nothing to do for Python code.
.PHONY: pregit
pregit:
dos2unix cprint.py
dos2unix Makefile
dos2unix .gitignore
# cprint.py needs to go into the gdb's data-directory, which can be
# seen with (gdb) show data-directory
.PHONY : install
install :
echo Install not implemented
# @mkdir -p $(GDB_DATA_DIRECTORY)/auto-load/
# install cprint.py $(GDB_DATA_DIRECTORY)/auto-load/
sample_dirs = $(sort $(dir $(wildcard */)))
sample_dirs_clean = $(addsuffix .clean, $(sample_dirs))
sample_dirs_ref = $(addsuffix .ref,$(sample_dirs))
sample_dirs_check = $(addsuffix .check,$(sample_dirs))
.PHONY: samples $(sample_dirs)
samples: $(sample_dirs)
$(sample_dirs):
$(MAKE) -C $@
.PHONY: clean
clean: $(sample_dirs_clean)
$(sample_dirs_clean):
$(MAKE) -C $(subst .clean,,$@) clean
.PHONY: ref
ref: $(sample_dirs_ref)
$(sample_dirs_ref):
$(MAKE) -C $(subst .ref,,$@) ref
.PHONY: check
check: $(sample_dirs_check)
$(sample_dirs_check):
$(MAKE) -C $(subst .check,,$@) check
sample_dirs = $(sort $(dir $(wildcard */)))
sample_dirs_clean = $(addsuffix .clean, $(sample_dirs))
sample_dirs_ref = $(addsuffix .ref,$(sample_dirs))
sample_dirs_check = $(addsuffix .check,$(sample_dirs))
.PHONY: samples $(sample_dirs)
samples: $(sample_dirs)
$(sample_dirs):
$(MAKE) -C $@
.PHONY: clean
clean: $(sample_dirs_clean)
$(sample_dirs_clean):
$(MAKE) -C $(subst .clean,,$@) clean
.PHONY: ref
ref: $(sample_dirs_ref)
$(sample_dirs_ref):
$(MAKE) -C $(subst .ref,,$@) ref
.PHONY: check
check: $(sample_dirs_check)
$(sample_dirs_check):
$(MAKE) -C $(subst .check,,$@) check
# This is common Makefile code for all the samples/ builds.
#
# 1) It uses GnuCOBOL cobc to generate debug-enabled .o, .lst,
# .cbl.lst, .c, and .i files.
#
# 2) It then runs cobst, which reads some of those files, to generate
# the symbol table .tab file
#
# 3) It then runs obmod, which reads the .tab and the .o file, and
# generates .cbl.o. That file has the original back-to-the-c
# debugging information stripped out and replaced with the
# back-to-the-cbl debugging information
#
# 4) From .o and .cbl.o it creates the project and project.x
# executables, which may or may not be useful, depending on whether or
# not the original .cbl module was designed to create a standalone
# executable
# disable built-in rules:
.SUFFIXES:
COBC = cobc
COBST = ../../cobst/cobst
OBMOD = ../../obmod/obmod
all: $(project).x $(project) $(project).s
# These rules create the two executables:
# $(project).x, created from project.o, will have debugging
# information pointing to the intermediate .c code
$(project).x : $(project).o
$(COBC) -x -o $(project).x $(project).o
# $(project), created from project.cbl.o, will have debugging
# information pointing to the original .cbl code
$(project) : $(project).cbl.o
$(COBC) -x -o $(project) $(project).cbl.o
# This rule uses cobst to replace the debugging information in
# project.o with data found in project.tab. The result is project.cbl.o
$(project).cbl.o : $(project).o $(project).tab $(OBMOD)
$(OBMOD) -i $(project).o -t $(project).tab -o $(project).cbl.o
# This rule uses cobst to create project.tab. cobst uses files
# generated by cobc to do that. There are a number of files needed
# for that, but since they all change together, we can use just
# project.lst as an indicator for all of them:
$(project).tab : $(project).lst $(COBST)
$(COBST) $(project).cbl
# This rule starts the whole chain by compiling the COBOL source code
# with the debugging options turned on, which generates the
# intermediate files needed to proceed with the cobst/obmod steps.
#
# Note that the environment variable free needs to be set to either ""
# or "-free" depending on the input format of the .cbl source code The
# first invocation creates the intermediate .s assembly language file;
# the second is the headliner.
$(project).o $(project).lst : $(project).cbl Makefile ../Makefile.inc
COB_CFLAGS="-Wa,-L,-anchls=$(project).lst" cobc -c -x -d -g $(free) \
-T$(project).cbl.lst --tlines=0 --tsymbols $(project).cbl
# cobc -S causes the processing to stop after gcc creates the .s assembly
# language file. As of this writing, I have found no use for it.
$(project).s : $(project).cbl Makefile ../Makefile.inc
COB_CFLAGS="-Wa,-L,-anchls=$(project).lst" cobc -S -x -d -g $(free) \
$(project).cbl
# This cleans up the various project files, along with any additional
# $(CLEAN) files specified by the parent Makefile It also clobbers any
# .txt files that might be lying around; I often create .txt files
# from dwarfdump and hexdump.
.PHONY : clean
suffixes = .c .s *.h .i .lst .cbl.lst .full.tab .tab .o .cbl.o .x
clean:
rm -f $(addprefix $(project),$(suffixes)) $(project) *.txt $(CLEAN)
# For regression testing of cobst, this rule establishes a known .ref
# version of .tab
.PHONY : ref
ref:
cp -f $(project).tab $(project).ref
# As part of regression testing, this rule checks a
# previously.established .ref against the current .tab
.PHONY : check
check:
@cmp -s $(project).tab $(project).ref; \
RETVAL=$$?; \
if [ $$RETVAL -eq 0 ]; then \
echo "checking: $(project).tab $(project).ref are the same"; \
else \
echo "checking: $(project).tab $(project).ref are different"; \
exit 64; \
fi
# This is common Makefile code for all the samples/ builds.
#
# 1) It uses GnuCOBOL cobc to generate debug-enabled .o, .lst,
# .cbl.lst, .c, and .i files.
#
# 2) It then runs cobst, which reads some of those files, to generate
# the symbol table .tab file
#
# 3) It then runs obmod, which reads the .tab and the .o file, and
# generates .cbl.o. That file has the original back-to-the-c
# debugging information stripped out and replaced with the
# back-to-the-cbl debugging information
#
# 4) From .o and .cbl.o it creates the project and project.x
# executables, which may or may not be useful, depending on whether or
# not the original .cbl module was designed to create a standalone
# executable
# Note that the environment variable 'free' needs to be set to either ""
# or "-free" depending on the input format of the .cbl source code
# disable built-in rules:
.SUFFIXES:
COBC = cobc
# These paths are established for local debugging. Most likely the cobst and
# obmod executables will find their way into /usr/local/bin/ for production
# purposes. You Have Been Warned.
COBST = ../../cobst/cobst
OBMOD = ../../obmod/obmod
all: $(project).x $(project) $(project).s
# This rule creates a cbl-gdb modified executable. The debugging information
# in the modified executable will point to the project.cbl source code.
#
# Note that it is this srule/script that will have to be copied elsewhere to
# compile .cbl sources for gdb debugging
$(project) : $(project).cbl
@# cobc creates the initial relocatable .o ELF file
COB_CFLAGS="-Wa,-L,-anchls=$(project).lst" cobc -c -x -d -g $(free) \
-T$(project).cbl.lst --tlines=0 --tsymbols $(project).cbl
@# cobst creates the project.tab file from the cobc output files that are
@# used by obmod and
$(COBST) $(project).cbl
@# obmod creates a modified relocatable .o ELF file from project.tab and
@# the .o file created by cobc
$(OBMOD) -i $(project).o -t $(project).tab -o $(project).cbl.o
@# This second invocation of cobc creates the modified ELF executable from
@# the modified .o ELF relocatable
$(COBC) -x -o $(project) $(project).cbl.o
# This rule creates project.x, which is an unmodified ELF executable created
# with all the same switches as the modified one. The debugging information
# will thus point to the intermediate .c code
# information pointing to the intermediate .c code
$(project).x : $(project).cbl
COB_CFLAGS="-Wa,-L,-anchls=$(project).lst" cobc -c -x -d -g $(free) \
-T$(project).cbl.lst --tlines=0 --tsymbols $(project).cbl
$(COBC) -x -o $(project).x $(project).o
# cobc -S causes the processing to stop after gcc creates the .s assembly
# language file. As of this writing, I have found no use for it.
$(project).s : $(project).cbl
COB_CFLAGS="-Wa,-L,-anchls=$(project).lst" cobc -S -x -d -g $(free) \
$(project).cbl
# This cleans up the various project files, along with any additional
# $(CLEAN) files specified by the parent Makefile It also clobbers any
# .txt files that might be lying around; I often create .txt files
# from dwarfdump and hexdump.
.PHONY : clean
suffixes = .c .s *.h .i .lst .cbl.lst .full.tab .tab .o .cbl.o .x
clean:
rm -f $(addprefix $(project),$(suffixes)) $(project) *.txt $(CLEAN)
# For regression testing of cobst, this rule establishes a known .ref
# version of .tab
.PHONY : ref
ref:
cp -f $(project).tab $(project).ref
# As part of regression testing, this rule checks a
# previously.established .ref against the current .tab
.PHONY : check
check:
@cmp -s $(project).tab $(project).ref; \
RETVAL=$$?; \
if [ $$RETVAL -eq 0 ]; then \
echo "checking: $(project).tab $(project).ref are the same"; \
else \
echo "checking: $(project).tab $(project).ref are different"; \
exit 64; \
fi
project = optfde01
#free = --free
free =
include ../Makefile.inc
project = optfde01
#free = --free
free =
include ../Makefile.inc
1234560601194501L0100000000
1234560601194501L011234567800000123
1234560601194501L021234567900000123
......@@ -2,20 +2,31 @@
*> OEIT is Order Entry Input Transaction
*> For each order there is one "header line"
01 oeit.
05 oeit-custnum pic 9(6).
05 oeit-orddate pic 9(8). *> Incoming is MMDDYYYY -> YYYYMMDD.
05 oeit-custnum pic 9(6).
05 oeit-orddate pic 9(8).
05 oeit-ordnum pic 99.
05 oeit-rectype pic x.
05 oeit-lineno pic 99.
05 oeit-hbody.
10 oeith-ponum pic x(8).
10 oeith-filler pic x(8).
05 oeit-ponum pic x(8).
05 oeit-filler pic x(8).
*> For each order there is one to 20 "detail lines" (Products
*> ordered and the quantities requested.
05 oeit-lbody redefines oeit-hbody.
10 oeitl-prodnum pic 9(8).
10 oeitl-qty pic 9(8).
01 oeitl.
05 oeitl-custnum pic 9(6).
05 oeitl-orddate pic 9(8).
05 oeitl-ordnum pic 99.
05 oeitl-rectype pic x.
05 oeitl-lineno pic 99.
05 oeitl-prodnum pic 9(8).
05 oeitl-qty pic 9(8).
*> The program recognizes the record types based on the
*> contents of oeit-rectype. "H" is a header, "L" is a
*> detail line.
01 ordmast.
05 oeit-custnum pic 9(6).
05 oeit-orddate pic 9(8).
05 oeit-ordnum pic 99.
05 oeit-ponum pic x(8).
01 ordline.
05 oeitl-lineno pic 99.
05 oeitl-prodnum pic 9(8).
05 oeitl-qty pic 9(8).
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