14 April 94 Version 1.20 of pccts At the moment this help file is available via anonymous FTP at Node: marvin.ecn.purdue.edu File: pub/pccts/1.20/NOTES.OS2 Mail corrections or additions to Steve Robenalt =============================================================================== Notes on building PCCTS under OS/2 2.X with the C Set compilers. The supplied makefiles can be used to build PCCTS under OS/2 with minimal trouble. First you need to edit the makefiles such that the Unix specific defaults are commented out, then uncomment the lines which are specific to OS/2 and C Set/2 compilers as originally set up by Ed Harfmann. Note also that you need to use the target list which reflects the appropriate naming conventions. Some of the lines now need to be changed to reflect differences in conventions between the operating systems: 1) change forward slashes in directories to backslashes, 2) change command line parameters from -option to /option (note that this applies to C Set, not ANTLR and DLG options), and 3) change rm to del for clean and scrub targets. To build ANTLR for the first time: note: I tried various combinations of "touch"ing files to try to prevent nmake from using ANTLR to rebuild itself, and was unsuccessful. In the section labelled "Target list of PC machines", comment out the scan.c and antlr.c dependencies. This prevents nmake from trying to invoke ANTLR to build itself. After you have built ANTLR successfully for the first time, you can uncomment these lines and it will build itself normally. (If you had a working 1.10 installation before, you can also use the older binaries when building the new ones.) An example of the resulting makefile, with all the extra baggage for Unix, DOS, and OS/2 1.X is shown here: ----- cut here ----- # # Makefile for ANTLR 1.20 # # SOFTWARE RIGHTS # # We reserve no LEGAL rights to the Purdue Compiler Construction Tool # Set (PCCTS) -- PCCTS is in the public domain. An individual or # company may do whatever they wish with source code distributed with # PCCTS or the code generated by PCCTS, including the incorporation of # PCCTS, or its output, into commerical software. # # We encourage users to develop software with PCCTS. However, we do ask # that credit is given to us for developing PCCTS. By "credit", # we mean that if you incorporate our source code into one of your # programs (commercial product, research project, or otherwise) that you # acknowledge this fact somewhere in the documentation, research report, # etc... If you like PCCTS and have developed a nice tool with the # output, please mention that you developed it using PCCTS. In # addition, we ask that this header remain intact in our source code. # As long as these guidelines are kept, we expect to continue enhancing # this system and expect to make other tools available as they are # completed. # # ANTLR 1.20 # Terence Parr # Purdue University # With AHPCRC, University of Minnesota # 1989-1994 # # Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by # Ed Harfmann # Micro Data Base Systems # Lafayette, Indiana # - With updates by Steve Robenalt 4/94 # SET=..\support\set PCCTS_H=..\h # # C-Set/2 for OS/2 # CC=icc CFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN OUT_OBJ = /Fo LIBS= ANTLR=..\bin\antlr DLG=..\bin\dlg OBJ_EXT = obj antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \ fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \ misc.obj set.obj pred.obj dialog.obj link386 @<< $** /NOI $@ /STACK:32768 $(LIBS: = +^ ) $(DEF_FILE) $(LFLAGS) ; << copy *.exe ..\bin # # *********** Target list of PC machines *********** # # Don't worry about the ambiguity messages coming from antlr # for making antlr.c etc... [should be 10 of them, I think] # #antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g # $(ANTLR) antlr.g antlr.$(OBJ_EXT): antlr.c mode.h tokens.h scan.$(OBJ_EXT): scan.c mode.h tokens.h #scan.c mode.h: parser.dlg # $(DLG) -C2 parser.dlg scan.c set.$(OBJ_EXT): $(SET)\set.c $(CC) $(CFLAGS) /C $(OUT_OBJ)set.$(OBJ_EXT) $(SET)\set.c # # what files does PCCTS generate (both ANTLR and DLG) # PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \ hash.c lex.c main.c misc.c $(SET)\set.c pred.c dialog.c # # ****** These next targets are common to UNIX and PC world ******** # #clean up all the intermediate files clean: del *.$(OBJ_EXT) #remove everything in clean plus the PCCTS files generated scrub: del $(PCCTS_GEN) *.$(OBJ_EXT) ----- cut here ----- To build DLG for the first time: Follow the same steps as were used to build ANTLR, changing the slashes and commands, targets, and extensions for OS/2. Comment out the dependencies for dlg_p.c and dlg_a.c to prevent nmake from trying to invoke ANTLR and DLG to build DLG (unless you have 1.10 binaries). An example of the resulting makefile, with all the extra baggage for Unix, DOS, and OS/2 1.X is shown here: ----- cut here ----- # # Makefile for DLG 1.20 # Terence Parr # Purdue University # 1989-1993 # # Ported to IBM C-Set/2 and Microsoft 6.0 by # Ed Harfmann # Micro Data Base Systems # Lafayette, Indiana # - With updates by Steve Robenalt 4/94 # SET=..\support\set PCCTS_H=..\h # # C-Set/2 for OS/2 # CC=icc CFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3 OUT_OBJ = /Fo LIBS= ANTLR=..\bin\antlr DLG=..\bin\dlg OBJ_EXT=obj dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \ output.obj relabel.obj automata.obj link386 @<< $** /NOI $@ /STACK:32768 $(LIBS: = +^ ) $(DEF_FILE) $(LFLAGS) ; << copy *.exe ..\bin SRC = dlg_p.c dlg_a.c main.c err.c $(SET)\set.c support.c output.c \ relabel.c automata.c #dlg_p.c parser.dlg err.c tokens.h : dlg_p.g # $(ANTLR) dlg_p.g #dlg_a.c mode.h : parser.dlg # $(DLG) -C2 parser.dlg dlg_a.c dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h $(CC) $(CFLAGS) /c dlg_p.c dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h $(CC) $(CFLAGS) /c dlg_a.c main.$(OBJ_EXT) : main.c dlg.h $(CC) $(CFLAGS) /c main.c set.$(OBJ_EXT) : $(SET)\set.c $(CC) /c $(CFLAGS) $(SET)\set.c lint: lint *.c #clean up all the intermediate files clean: del *.$(OBJ_EXT) ----- cut here ----- Once you have built ANTLR and DLG successfully, you will also want to build the genmk utility, located at ~\pccts\support\genmk. The makefile in this directory is relatively simple to modify, so I won't repeat it here. At this point, you can test the executables by building one of the sample programs, such as the Pascal or C example under ~pccts\lang. The prototype makefile which is in these directories will work fine as a base, with OS/2 specific modifications as noted above. Note that the /Sa flag defines the ANSI C mode of the compiler which is not the default. The default mode does not define __STDC__ and will lead to lots of errors. A sample pascal makefile is shown below: ----- cut here ----- GRM =pascal.g LEX_FILE =pscan.dlg GSRC=pascal.c err.c pscan.c ttree.c adebug.c GOBJ=pascal.obj err.obj pscan.obj ttree.obj adebug.obj PCCTS_GEN= pascal.c err.c $(LEX_FILE) pscan.c mode.h tokens.h SRC =$(GSRC) pmain.c sym.c OBJ =$(GOBJ) pmain.obj sym.obj INCL = ..\..\h SYM = ..\..\support\sym ANTLR = ..\..\bin\antlr DLG = ..\..\bin\dlg CFLAGS=/I. /I$(INCL) /Sa AFLAGS= -fl $(LEX_FILE) -gh pascal.exe : $(OBJ) $(CC) $(CFLAGS) /Fopascal.exe $(OBJ) pascal.c $(LEX_FILE) : $(GRM) $(ANTLR) $(AFLAGS) $(GRM) mode.h pscan.c : $(LEX_FILE) $(DLG) -C2 $(LEX_FILE) pscan.c pmain.obj : pmain.c pascal.h pascal.obj : pascal.c mode.h tokens.h sym.obj : $(SYM)\sym.c icc /c /Fo sym.obj $(CFLAGS) $(SYM)\sym.c err.obj : err.c clean: del $(PCCTS_GEN) *.obj ----- cut here ----- The C example can be built in much the same way. If you have problems compiling anything, I would appreciate hearing about it. I was able to get everything built and working without changing any of the supplied or generated C code, so if you find that you need to make changes to any code, I've probably written something up incorrectly. Please post comments to the mailing list for PCCTS at: pccts-users@ahpcrc.umn.edu since I am most likely to see them there. - Steve Robenalt