# -*- Mode: Makefile -*-

# Makefile options needed for Microsoft C compiler, 'cl'

OUTPUT_OPTION = -Fo$@

AR = lib
ARFLAGS = -MACHINE:i386 -nologo -verbose
(%): %;  $(AR) $(ARFLAGS) /out:$@ $@ $<

RANLIB = true

CFLAGS   = -Zi -nologo -G5 -W3 -GR -GX
CXXFLAGS = -Zi -nologo -G5 -W3 -GR -GX
# LDFLAGS  =     -Zi

ifeq "$(OPTIMIZE)" "yes"
CFLAGS = -O3 $(CFLAGS)
CXXFLAGS = -O3 $(CXXFLAGS)
endif

LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
%: %.c;  $(LINK.c) $^ $(LOADLIBES) -link $(LDLIBS) -out:$@.exe

LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)
%: %.o;  $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)

LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
%: %.cc; $(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)

COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
%.o: %.c; $(COMPILE.c) $< $(OUTPUT_OPTION)

COMPILE.cc = $(CXX) -TP $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
%.o: %.cc; $(COMPILE.cc) $< $(OUTPUT_OPTION)
%.o: %.cpp; $(COMPILE.cc) $< $(OUTPUT_OPTION)

