Project: Smalltalk YX
Code Location: git://git.berlios.de/syxmaster
Browse
/
Download File
makefile.vc
# Makefile for Visual Studio
# Written by Krzysztof Kowalczyk (http://blog.kowalczyk.info)
# This code is in public domain.
CC = cl.exe
LD = link.exe

VALID_TARGET=no
!if "$(TARGET)"=="rel"
OUTDIR=rel
#/Gy - separate functions for linker. Generates smaller code.
#/GL - enables link-time code generation. Requires /LTCG in linker.
#      generates smaller and faster code
CFLAGS = $(CFLAGS) /D "NDEBUG" /D "_SECURE_CSL=0" /MD /Ox /Os /Gy /GL
# /Gr - __fastcall calling convention. Generates smaller and faster code.
CFLAGS = $(CFLAGS) /Gr
# /Oy - omits frame pointers. Should generate smaller code but I'm not seeing that,
#       so I'm not enabling this function.
#CFLAGS = $(CFLAGS) /Oy
VALID_TARGET=yes
!endif

!if "$(TARGET)"=="dbg"
OUTDIR=dbg
CFLAGS = $(CFLAGS) /D "_DEBUG" /MDd /Od
VALID_TARGET=yes
!endif

!if "$(ANALYZE)"=="yes"
CFLAGS = $(CFLAGS) /analyze
!endif

O=$(OUTDIR)

CFLAGS = $(CFLAGS) /nologo /c
# standard windows defines
CFLAGS = $(CFLAGS) /D "WIN32" /D "WINDOWS" /D "_WIN32_WINNT=0x0500"
#CFLAGS = $(CFLAGS) /D "WIN32_LEAN_AND_MEAN"
#CFLAGS = $(CFLAGS) /D "UNICODE" /D "_UNICODE"
#CFLAGS = $(CFLAGS) /D "_SCL_SECURE_NO_DEPRECATE" /D "_CRT_SECURE_NO_DEPRECATE"
CFLAGS = $(CFLAGS) /D "_CRT_SECURE_NO_WARNINGS"
#CFLAGS = $(CFLAGS) /D "_DLL"

CFLAGS = $(CFLAGS) /wd4996

CFLAGS = $(CFLAGS) /W3
#CFLAGS = $(CFLAGS) /Wall
# /GR- : disable C++ RTTI
CFLAGS = $(CFLAGS) /GR-
CFLAGS = $(CFLAGS) /Zi
# /FAscu - generate assembly listings
CFLAGS = $(CFLAGS) /FAscu

CFLAGS = $(CFLAGS) /Imsvc /I.

LIBS = $(LIBS) kernel32.lib advapi32.lib wsock32.lib

LDFLAGS = $(LDFLAGS) /nologo /DEBUG

!if "$(TARGET)"=="rel"
# /opt:ref - removes unused functions
# /opt:icf - removes duplicate functions
# /ltcg - link-time code generation. Generates smaller and faster code. Requires /GL when compiling.
LDFLAGS = $(LDFLAGS) /opt:ref /opt:icf /opt:nowin98 /ltcg
!endif

OBJS=$(O)\syx-bytecode.obj $(O)\syx-error.obj $(O)\syx-init.obj $(O)\syx-interp.obj $(O)\syx-lexer.obj \
  $(O)\syx-memory.obj $(O)\syx-object.obj $(O)\syx-parser.obj $(O)\syx-plugins.obj $(O)\syx-primitives.obj \
  $(O)\syx-profile.obj $(O)\syx-scheduler.obj $(O)\syx-scheduler-win.obj $(O)\syx-signal.obj \
  $(O)\syx-utils.obj

SYX_EXE=$(O)\syx.exe
SYX_PDB=$(O)\syx.pdb
SYX_OBJS=$(OBJS) $(O)\main.obj

TESTCOLDPARSER_EXE=$(O)\testcoldparser.exe
TESTCOLDPARSER_PDB=$(O)\testcoldparser.pdb
TESTCOLDPARSER_OBJS=$(OBJS) $(O)\testcoldparser.obj

TESTIMAGE_EXE=$(O)\testimage.exe
TESTIMAGE_PDB=$(O)\testimage.pdb
TESTIMAGE_OBJS=$(OBJS) $(O)\testimage.obj

TESTINSTANCES_EXE=$(O)\testinstances.exe
TESTINSTANCES_PDB=$(O)\testinstances.pdb
TESTINSTANCES_OBJS=$(OBJS) $(O)\testinstances.obj

TESTINTERP_EXE=$(O)\testinterp.exe
TESTINTERP_PDB=$(O)\testinterp.pdb
TESTINTERP_OBJS=$(OBJS) $(O)\testinterp.obj

TESTLEXER_EXE=$(O)\testlexer.exe
TESTLEXER_PDB=$(O)\testlexer.pdb
TESTLEXER_OBJS=$(OBJS) $(O)\testlexer.obj

TESTPARSER_EXE=$(O)\testparser.exe
TESTPARSER_PDB=$(O)\testparser.pdb
TESTPARSER_OBJS=$(OBJS) $(O)\testparser.obj

TESTSCHEDULER_EXE=$(O)\testscheduler.exe
TESTSCHEDULER_PDB=$(O)\testscheduler.pdb
TESTSCHEDULER_OBJS=$(OBJS) $(O)\testscheduler.obj

!if "$(VALID_TARGET)"=="yes"
all: $(OUTDIR) $(SYX_EXE) $(TESTCOLDPARSER_EXE) $(TESTIMAGE_EXE) $(TESTINSTANCES_EXE) \
  $(TESTINTERP_EXE) $(TESTLEXER_EXE) $(TESTPARSER_EXE) $(TESTSCHEDULER_EXE)

$(OUTDIR): force
	@if not exist $(OUTDIR) mkdir $(OUTDIR)
clean: force
	-rmdir /S /Q $(OUTDIR)
rebuild: clean all
runtests: all
  $(O)\testlexer.exe
  $(O)\testimage.exe
  $(O)\testcoldparser.exe
  $(O)\testinstances.exe
  $(O)\testparser.exe
  $(O)\testinterp.exe
  $(O)\testscheduler.exe

!else
all clean: force
	@echo TARGET must be set to dbg or rel
!endif

$(SYX_EXE): $(SYX_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(SYX_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTCOLDPARSER_EXE): $(TESTCOLDPARSER_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTCOLDPARSER_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTIMAGE_EXE): $(TESTIMAGE_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTIMAGE_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTINSTANCES_EXE): $(TESTINSTANCES_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTINSTANCES_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTINTERP_EXE): $(TESTINTERP_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTINTERP_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTLEXER_EXE): $(TESTLEXER_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTLEXER_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTPARSER_EXE): $(TESTPARSER_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTPARSER_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

$(TESTSCHEDULER_EXE): $(TESTSCHEDULER_OBJS)
	$(LD) $(LDFLAGS) /OUT:$@ \
	/PDB:$(TESTSCHEDULER_PDB) \
	$** $(LIBS) \
	/SUBSYSTEM:CONSOLE /MACHINE:X86

{syx\}.c{$(OUTDIR)}.obj::
	$(CC) $(CFLAGS) -Fo$(OUTDIR)\ /Fd$(OUTDIR)\vc80.pdb /Fa$(OUTDIR)\ $<

{src\}.c{$(OUTDIR)}.obj::
	$(CC) $(CFLAGS) -Fo$(OUTDIR)\ /Fd$(OUTDIR)\vc80.pdb /Fa$(OUTDIR)\ $<

{tests\}.c{$(OUTDIR)}.obj::
	$(CC) $(CFLAGS) -Fo$(OUTDIR)\ /Fd$(OUTDIR)\vc80.pdb /Fa$(OUTDIR)\ $<

force: ;