# NOTE: This file is updated automatically by the `updmake' perl script,
# which processes the Makefile in the main directory and re-pastes this header
# on the top.
#
# Makefile for c2man                                           23 Aug 1993
#
# - for GNU gcc (emx 0.8g kit) under OS/2 2.x or DOS (32-bit)
# - for Microsoft C 6.00 under OS/2 or DOS (16-bit)

# To use, enter "{d,n}make -f Makefile.pc" (this makefile depends on its
# name being "Makefile.pc").
#
# tested with dmake 3.8 and GNU make 3.68 under OS/2

default:
	@echo "Enter $(MAKE) -f Makefile.pc target                     "
	@echo " where 'target' is chosen from                          " 
	@echo "   msc      OS/2 and DOS exe [Microsoft C 6.00a]        "
	@echo "   emx      OS/2 and DOS 32-bit exe [EMX/gcc]           "

emx:  
	$(MAKE) -f Makefile.pc all \
	CC="gcc -O -s" O=".o" \
	CFLAGS="-DOS2 -DMSDOS" \
	OBJS2="popen.o" \
	LDFLAGS="" \
	LIBS="c2man-32.def" \

msc: 
	$(MAKE) -f Makefile.pc all \
	CC="cl -nologo -AS" O=".obj" \
	CFLAGS="-D__STDC__ -DOS2" \
	OBJS2="getopt.obj popen.obj" \
	LDFLAGS="-Lp -F 2000" \
	LIBS="setargv.obj c2man.def -link /NOE" \
	BIND="bind c2man.exe /n DOSMAKEPIPE DOSCWAIT"

YACC=bison -y
LEX=flex
SED=sed
RM=rm
MV=mv
ECHO=echo
MKDEP=mkdep

# where we get installed
bin=/bin

mansrc=/etc/man/manl
manext=l

# As Larry said, "Grrrr"
SHELL=/bin/sh

# To change anything below here, you should really fix updmake to do it.
# DO NOT EDIT ANYTHING BELOW HERE, OR IT WILL BE LOST NEXT TIME updmake IS RUN.

OSOURCES =	config.h c2man.h semantic.h symbol.h strconcat.h \
		strappend.h manpage.h enum.h output.h lex.l grammar.y
DCSOURCES =	c2man.c semantic.c string.c symbol.c strconcat.c \
		strappend.c manpage.c enum.c nroff.c texinfo.c latex.c html.c \
		autodoc.c
SOURCES =	$(OSOURCES) $(DCSOURCES)
CSOURCES =	$(DCSOURCES) y.tab.c
OBJECTS =	c2man$O semantic$O string$O symbol$O y.tab$O strconcat$O \
		strappend$O manpage$O enum$O nroff$O texinfo$O latex$O html$O \
		autodoc$O
GENERATED =	c2man example.inc ctype_ex.inc y.tab.c lex.yy.c y.output \
		fixexamp.sed flatten.sed


all: c2man.exe c2man.1

install:
	$(CP) c2man $(bin)
	$(CP) c2man.1 $(mansrc)/c2man.$(manext)
	-mkdir $(privlib)
	-mkdir $(privlib)/eg
	$(CP) eg/*.[chly] $(privlib)/eg

uninstall:
	$(RM) -f $(bin)/c2man $(mansrc)/c2man.$(manext)
	$(RM) -f $(privlib)/eg/*
	rmdir $(privlib)/eg
	rmdir $(privlib)

c2man.exe: $(OBJECTS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
	$(BIND)

c2man.1: c2man.man c2man.exe example.inc ctype_ex.inc flatten.sed
	$(SED) -f flatten.sed < c2man.man > c2man.1

.c$O:
	$(CC) $(CFLAGS) $(WARNFLAGS) -c $<

y.tab.c: grammar.y
	@$(ECHO) Expect 61 shift/reduce conflicts.
	$(YACC) grammar.y

# don't compile y.tab.c with all warnings; yacc/bison are not up to it.
y.tab$O: y.tab.c lex.yy.c
	$(CC) $(CFLAGS) -c y.tab.c

lex.yy.c: lex.l
	$(LEX) -t -n lex.l > $@
	cp $@ lex_yy.c

example.inc: c2man.exe example.h fixexamp.sed
	./c2man -o- example.h | $(SED) -f fixexamp.sed >example.inc

ctype_ex.inc: c2man.exe ctype_ex.h fixexamp.sed
	./c2man -o- -g ctype_ex.h | $(SED) -f fixexamp.sed >ctype_ex.inc

fixexamp.sed: fixexamp.in
	$(SED) -e '/^#/d' fixexamp.in > fixexamp.sed

flatten.sed: flatten.SH config.sh
	sh flatten.SH

Makefile: Makefile.SH config.sh
	sh Makefile.SH

config.h: config_h.SH config.sh
	sh config_h.SH

TAGS: $(SOURCES)
	etags -t $(SOURCES)

clean:
	$(RM) -f *$O *.s *.bak *~ *.log $(GENERATED) core

distclean realclean: clean
	$(RM) -f Makefile config.sh mkdep c2man.kit?

lint:
	lint -b $(CFLAGS) $(CSOURCES)

print:
	cpr $(SOURCES) | lpr -J'c2man'

test: c2man.exe
	@echo "Running c2man over the examples..." 1>&2
	@for file in eg/*.[chly]; do ./c2man -v -o- $$file; done
	@echo "Running c2man over its own source code..." 1>&2
	@for file in $(DCSOURCES); do ./c2man -v -o- $$file; done
	@echo "Hmmm, test seemed to go OK." 1>&2

depend:
	$(SED) -e '1,/^# DO NOT/!d' < Makefile > Makefile.new
	$(MKDEP) $(DCSOURCES) >> Makefile.new
	- test ! -f y.tab.c -o ! -f lex.yy.c || $(MKDEP) y.tab.c >> Makefile.new
	$(MV) -f Makefile.new Makefile

# y.tab.c dependancies updated manually since it won't exist yet when make
# depend is first run.
y.tab$O: c2man.h config.h confmagic.h enum.h manpage.h semantic.h strappend.h\
	strconcat.h symbol.h


# DO NOT DELETE THIS LINE! make depend DEPENDS ON IT!
c2man$O: c2man.c c2man.h config.h confmagic.h enum.h manpage.h output.h\
	patchlevel.h strappend.h strconcat.h symbol.h

semantic$O: c2man.h config.h confmagic.h enum.h manpage.h output.h semantic.c\
	semantic.h strconcat.h symbol.h

string$O: c2man.h config.h confmagic.h string.c symbol.h

symbol$O: c2man.h config.h confmagic.h symbol.c symbol.h

strconcat$O: c2man.h config.h confmagic.h strconcat.c strconcat.h symbol.h

strappend$O: c2man.h config.h confmagic.h strappend.c strappend.h symbol.h

manpage$O: c2man.h config.h confmagic.h manpage.c manpage.h output.h\
	semantic.h strappend.h strconcat.h symbol.h

enum$O: c2man.h config.h confmagic.h enum.c enum.h manpage.h strconcat.h\
	symbol.h

nroff$O: c2man.h config.h confmagic.h manpage.h nroff.c output.h semantic.h\
	symbol.h

texinfo$O: c2man.h config.h confmagic.h manpage.h output.h symbol.h texinfo.c

latex$O: c2man.h config.h confmagic.h latex.c manpage.h output.h symbol.h

html$O: c2man.h config.h confmagic.h html.c manpage.h output.h symbol.h

autodoc$O: autodoc.c c2man.h config.h confmagic.h manpage.h output.h symbol.h



syntax highlighted by Code2HTML, v. 0.9.1