#########################################################################
#                                                                       #
#                            Objective Caml                             #
#                                                                       #
#            Xavier Leroy, projet Cristal, INRIA Rocquencourt           #
#                                                                       #
#   Copyright 1999 Institut National de Recherche en Informatique et    #
#   en Automatique.  All rights reserved.  This file is distributed     #
#   under the terms of the GNU Library General Public License, with     #
#   the special exception on linking described in file ../LICENSE.      #
#                                                                       #
#########################################################################

# $Id: Makefile.nt 10325 2010-04-28 12:00:27Z xleroy $

include ../config/Makefile

CC=$(NATIVECC)
CFLAGS=-I../byterun -DNATIVE_CODE -DTARGET_$(ARCH) -DSYS_$(SYSTEM) $(NATIVECCCOMPOPTS)

COBJS=startup.$(O) main.$(O) fail.$(O) roots.$(O) signals.$(O) signals_asm.$(O) \
  misc.$(O) freelist.$(O) major_gc.$(O) minor_gc.$(O) memory.$(O) alloc.$(O) \
  compare.$(O) ints.$(O) floats.$(O) str.$(O) array.$(O) io.$(O) extern.$(O) \
  intern.$(O) hash.$(O) sys.$(O) parsing.$(O) gc_ctrl.$(O) terminfo.$(O) \
  md5.$(O) obj.$(O) lexing.$(O) win32.$(O) printexc.$(O) callback.$(O) \
  weak.$(O) compact.$(O) finalise.$(O) custom.$(O) globroots.$(O) \
  backtrace.$(O) natdynlink.$(O) debugger.$(O)

LINKEDFILES=misc.c freelist.c major_gc.c minor_gc.c memory.c alloc.c array.c \
  compare.c ints.c floats.c str.c io.c extern.c intern.c hash.c sys.c \
  parsing.c gc_ctrl.c terminfo.c md5.c obj.c lexing.c printexc.c callback.c \
  weak.c compact.c meta.c finalise.c custom.c main.c globroots.c \
  dynlink.c signals.c debugger.c

ifeq ($(TOOLCHAIN),mingw)
ASMOBJS=$(ARCH).o
else
ASMOBJS=$(ARCH)nt.obj
endif

OBJS=$(COBJS) $(ASMOBJS)

all: libasmrun.$(A)

libasmrun.$(A): $(OBJS)
	$(call MKLIB,libasmrun.$(A), $(OBJS))

i386nt.obj: i386nt.asm
	$(ASM)i386nt.obj i386nt.asm

amd64nt.obj: amd64nt.asm
	$(ASM)amd64nt.obj amd64nt.asm

i386.o: i386.S
	$(CC) -c -DSYS_$(SYSTEM) i386.S

install:
	cp libasmrun.$(A) $(LIBDIR)

$(LINKEDFILES): %.c: ../byterun/%.c
	cp ../byterun/$*.c $*.c

# Need special compilation rule so as not to do -I../byterun
win32.$(O): ../byterun/win32.c
	$(CC) -c $(NATIVECCCOMPOPTS) -DNATIVE_CODE $(IFLEXDIR) ../byterun/win32.c

.SUFFIXES: .c .$(O)

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

clean::
	rm -f $(LINKEDFILES)

clean::
	rm -f *.$(O) *.$(A) *~

.depend.nt: .depend
	sed -e 's/\.o/.$(O)/g' .depend > .depend.nt

include .depend.nt
