[comp.binaries.ibm.pc.d] makefile for PC Flex port

seg@smsdpg.uu.net (Scott Garfinkle) (02/19/89)

I had intended to include this with the recently-posted flex patches.  It
should help.  Also, the following is a usage note to add to the readme file.

		flex looks for (in order) the environment variable FLEXPATH and INIT
		for places to find the skeleton files, if they're not in the
		current directory.  You'll still need to put the include files
		(flexskel.h, fastskel.h, and fskelcom.h) either in the current directory
		or in one of the directory specified in your INCLUDE env. variable.
--------------------
# this makefile is for Don Kneller's Opus Make.  Some changes will,
# undoubtedly, be necessary to use with Gnu or other makes.
MODEL		= L
OPTIMIZE	= -Ox
SKEL1		= -DDEFAULT_SKEL=\"skel.flx\"
SKEL2		= -DFAST_SKEL=\"fastskel.flx\"
SKEL3		= -DFLEXFILE=\"lexyy.c\"
CFLAGS		= $(SKEL1) $(SKEL2) $(SKEL3) -DMSC5 -A$(MODEL) $(OPTIMIZE)
DEST		= .
EXTHDRS		=
FFLAGS		=
HDRS		= flexdef.h fskelcom.h fskeldef.h
LDFLAGS		= /NOI /NOE /FAR /PAC /E /ST:4000
LDMAP		= $(@R)
LIBS		=
LINKER		= link
MAKEFILE	= Makefile
OBJS		= ccl.obj dfa.obj ecs.obj main.obj misc.obj nfa.obj \
		  parse.obj sym.obj tblcmp.obj yylex.obj scan.obj
PRINT		= print
SETARGV		= c:\lib\setargv
SRCS		= ccl.c dfa.c ecs.c main.c misc.c nfa.c parse.y sym.c \
		  tblcmp.c yylex.c scan.l
.SUFFIXES: .sys .com .exe .lib .obj .c .cxx .asm .y .l
LEX	= flex
YACC= bison -y
YACCOUT=y_tab.c
# 	Y -> C, for YACC
.y.c:
	$(YACC) $(YFLAGS) $<
	!if -e $(YACCOUT,B).h	# if -d flag was given....
		!if -e $*.h
			@del $*.h
		!endif
		ren $(YACCOUT,B).h $*.h
	!endif
	!if -e $@
		@del $@
	!endif
	ren $(YACCOUT) $@

# 	Y -> OBJ, for YACC
.y.obj:
	.y.c
	.c.obj
	@del $*.c

#	L -> OBJ, for FLEX
.l.obj:
	.l.c
	.c.obj

#	L -> C, for FLEX
.l.c:
	$(LEX) $(LEXFLAGS) $<
	!if -e $@
		@del $@
	!endif
	ren lexyy.c $@

flex.exe:     $(OBJS) $(LIBS)
		@echo Loading... $@
		@$(LINKER) $(OBJS) $(SETARGV), $@, $(LDMAP), $(LIBS) $(LDFLAGS);
		@echo done

first_flex:
	cp scan-c.dst scan.c
	make $(MFLAGS) flex.exe

clean:;		@rm -f $(OBJS)

depend:; 	@mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)

index:;		@ctags -wx $(HDRS) $(SRCS)

install:	$(PROGRAM)
		@echo Installing $(PROGRAM) in $(DEST)
		@if not $(DEST)x==.x copy $(PROGRAM) $(DEST)

print:;		@$(PRINT) $(HDRS) $(SRCS)

program:        $(PROGRAM)

tags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)

update:		$(DEST)/$(PROGRAM)

$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
		@make -f $(MAKEFILE) DEST=$(DEST) install

# if the following fails because you don't already *have* flex,
# do "make first_flex"
scan.c: scan.l
	flex scan.l
	-@del scan.c
	@ren lexyy.c scan.c

parse.h parse.c : parse.y
	yacc -d parse.y
	@ren ytab.c parse.c
	@ren ytab.h parse.h

### OPUS MKMF:  Do not remove this line!  Automatic dependencies follow.

ccl.obj: flexdef.h

dfa.obj: flexdef.h

ecs.obj: flexdef.h

main.obj: flexdef.h

misc.obj: flexdef.h

nfa.obj: flexdef.h

parse.obj: flexdef.h

sym.obj: flexdef.h

tblcmp.obj: flexdef.h

yylex.obj: flexdef.h