# --- Copyright University of Sussex 1998. All rights reserved. ----------
# File:				C.windows/extern/src/makefile
# Purpose:			Makefile for building Poplog libraries
# Author:			Robert John Duncan, Jun 14 1994 (see revisions)

!INCLUDE <win32.mak>

# Enable Unicode compilation by default (set to 0 for ANSI)
POPUNICODE=1

POPCORE = \
	ast.obj \
	c_callback.obj \
	c_sysinit.obj \
	console.obj \
	environment.obj \
	exception.obj \
	external.obj \
	file.obj \
	handle.obj \
	io.obj \
	memory.obj \
	misc.obj \
	pop_encoding.obj \
	pop_timer.obj \
	process.obj \
	start.obj \
	time.obj \
	util.obj

POPWIN = \
	base.obj \
	edit.obj \
	windows.obj

POPMAIN = \
	main.obj \
	winmain.obj

POPX = \
	x.obj \
	pop_poll.obj \
	XtPoplog.obj

POPCRT = \
	copysign.obj \
	rand48.obj

# Standard Poplog libraries
all :: popcore.lib popwin.lib popmain.lib

!IF $(POPUNICODE) == 1

# Compile for Unicode
cflags = $(cflags) -DUNICODE -D_UNICODE

!ENDIF

!IFDEF POPNUTC

# Assume compilation in the NuTCRACKER environment
cflags = $(cflags) -QIfdiv- -D__NUTC__ -D__WIN32__ -DWINTIF

# Compile for NutCracker DLL
cvarsdll = -D__NUTC_DLL__ $(cvarsdll)

# Additional libraries needed
all :: popx.lib popcrt.lib

!ENDIF

install : all
	copy *.lib ..\lib

# Archive libraries

popcore.lib : $(POPCORE)
	$(implib) -nologo -out:$@ $(**)

popwin.lib : $(POPWIN)
	$(implib) -nologo -out:$@ $(**)

popmain.lib : $(POPMAIN)
	$(implib) -nologo -out:$@ $(**)

popx.lib : $(POPX)
	$(implib) -nologo -out:$@ $(**)

popcrt.lib : $(POPCRT)
	$(implib) -nologo -out:$@ $(**)

# Test program for the library

test.exe : test.obj popmain.lib popcore.lib
	$(link) $(linkdebug) $(conlflags) -out:$@ $** \
		$(conlibsdll) user32.lib advapi32.lib

# Object files

ast.obj : ast.c popcore.h
console.obj : console.c popcore.h
environment.obj : environment.c popcore.h
exception.obj : exception.c popcore.h
external.obj : external.c popcore.h ..\lib\callback.h
file.obj : file.c popcore.h
handle.obj : handle.c popcore.h
io.obj : io.c popcore.h ..\unicode\encoding.h
memory.obj : memory.c popcore.h
misc.obj : misc.c popcore.h
process.obj : process.c popcore.h
start.obj : start.c popcore.h
test.obj : test.c popcore.h
time.obj : time.c popcore.h
util.obj : util.asm

base.obj : base.c popwin.h popcore.h
edit.obj : edit.c popwin.h popcore.h
windows.obj : windows.c popwin.h popcore.h

main.obj : main.c popcore.h
winmain.obj : winmain.c popcore.h

x.obj : x.c ..\lib\c_core.h popcore.h

c_callback.obj : ..\lib\c_callback.c ..\lib\callback.h
c_sysinit.obj : ..\lib\c_sysinit.c ..\lib\callback.h
pop_encoding.obj : ..\lib\pop_encoding.c ..\unicode\encoding.h ..\lib\c_core.h
pop_poll.obj : ..\lib\pop_poll.c ..\lib\c_core.h
pop_timer.obj : ..\lib\pop_timer.c ..\lib\c_core.h

XtPoplog.obj : ..\lib\XtPoplog.c ..\lib\c_core.h
	$(cc) -nologo $(cdebug) $(cflags) $(cvarsdll) -DWINTIF ..\lib\XtPoplog.c

.c.obj :
	$(cc) -nologo $(cdebug) $(cflags) $(cvarsdll) $<

{..\lib}.c{}.obj :
	$(cc) -nologo $(cdebug) $(cflags) $(cvarsdll) $<

.asm.obj :
	ml -nologo -c -coff $<

# Clean up

clean :
	-del *.obj *.lib *.exe


# --- Revision History ---------------------------------------------------
# --- Robert Duncan, Aug 11 1998
#		Changes for NuTCRACKER 4.0
# --- Robert Duncan, May  1 1997
#		Added pop_encoding. Added inference rule for .c files in ..\lib.
# --- Robert Duncan, Feb 13 1997
#		Enabled UNICODE compilation by default
# --- Robert Duncan, Jan 24 1997
#		Added POPUNICODE flag for UNICODE compilation
# --- Robert Duncan, Nov  1 1996
#		Moved pop_poll to popx.lib (NuTCRACKER only)
# --- Robert Duncan, Oct 28 1996
#		Added pop_poll
# --- Robert Duncan, Jun 20 1996
#		DLL entry point included in POPMAIN only when using NuTCRACKER
# --- Robert Duncan, May 29 1996
#		Added X & CRT rules for use when building in the NuTCRACKER
#		environment (indicated when $POPNUTC set)
# --- Robert Duncan, May 24 1996
#		Added handle and install rule
# --- Robert John Duncan, Feb 12 1996
#		Removed rules for making poplog's import/export libraries (now
#		done during linking in %popsys%\makefile)
# --- Robert John Duncan, Feb  7 1996
#		Added start
# --- Robert John Duncan, Jan  8 1996
#		Added c_sysinit and replaced device with io.
