#
# Application Makefile   
#

ifndef DEBUG
DEBUG = -g
endif

ifndef OPTIM
OPTIM = -O
endif

PLATFORM=gcc_ntox86
PHABOPTS= 

#
CFLAGS  = -V$(PLATFORM) -w5 $(OPTIM) $(DEBUG) $(PHABOPTS) -I.
CXXFLAGS = $(CFLAGS)

LDFLAGS = -V$(PLATFORM) -Bstatic $(DEBUG) -l Aplib -l phrtlib -l phexlib -l phcontrib -l photon   -l phrender_s $(PHABOPTS)
LDFLAGS = -V$(PLATFORM) $(DEBUG) -l Aplib -l phrtlib -l phexlib -l phcontrib -l photon                 $(PHABOPTS)

SDFLAGS = -V$(PLATFORM)          $(DEBUG) -l Aplib -l phrtlib -l phexlib -l phcontrib -l photon_s -l phrender_s $(PHABOPTS)
SDFLAGS = -V$(PLATFORM)          $(DEBUG) -l Aplib -l phrtlib -l phexlib -Bstatic -l phcontrib -Bdynamic -l photon_s               $(PHABOPTS)

VPATH = ../.

include	../abOfiles
include ../indOfiles

include	../abSfiles
include ../indSfiles

include	../abHfiles
include ../indHfiles

include	../abWfiles

ifdef STUFF
	MYOBJ += $(STUFF).o
	MYSRC += ../$(STUFF).c
endif

#
# Application Program
#

shr:	$(ABOBJ) $(MYOBJ)
		$(LD) $(ABOBJ) $(MYOBJ) $(SDFLAGS) -M -o pterm
		usemsg pterm ../Usemsg
		phabbind pterm $(ABMOD)

app:	$(ABOBJ) $(MYOBJ)
		$(LD) $(ABOBJ) $(MYOBJ) $(LDFLAGS) -M -o pterm
		usemsg pterm ../Usemsg
		phabbind pterm $(ABMOD)

clean:
		rm -f *.o *.err *.map pterm

install:
		@if [ -f pterm.res ]; \
			then cp -vnf pterm.res /nto/photon/x86/bin/pterm.res; \
			else rm -fv /nto/photon/x86/bin/pterm.res; \
			fi
		@cp -Ovnf pterm /nto/photon/x86/bin/pterm

#
# Headers
#

$(ABOBJ) $(MYOBJ):	$(MYHDR)

#
# Prototype Generation
#

proto:
		approto -p $(ABSRC) $(MYSRC) > proto.h

%.o: %.c
	($(CC) -c $(CFLAGS) $< > $*.err 2>&1; X=$$?; cat $*.err; exit $$X)

