#########################################################################
#                                                                       #
#                            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,v 1.32 2004/05/30 08:17:06 xleroy Exp $

include ../../config/Makefile

# Compilation options
CC=$(BYTECC)
CFLAGS=-I../../byterun -I../unix
CAMLC=../../boot/ocamlrun ../../ocamlc -I ../../stdlib
CAMLOPT=../../boot/ocamlrun ../../ocamlopt -I ../../stdlib
COMPFLAGS=-warn-error A

# Files in this directory
WIN_FILES = accept.c bind.c channels.c close.c \
  close_on.c connect.c createprocess.c dup.c dup2.c errmsg.c \
  getpeername.c getpid.c getsockname.c gettimeofday.c \
  link.c listen.c lockf.c lseek.c nonblock.c \
  mkdir.c open.c pipe.c read.c rename.c \
  select.c sendrecv.c \
  shutdown.c sleep.c socket.c sockopt.c startup.c stat.c \
  system.c unixsupport.c windir.c winwait.c write.c

# Files from the ../unix directory
UNIX_FILES = access.c addrofstr.c chdir.c chmod.c cst2constr.c \
  cstringv.c envir.c execv.c execve.c execvp.c \
  exit.c getcwd.c gethost.c gethostname.c getproto.c \
  getserv.c gmtime.c putenv.c rmdir.c \
  socketaddr.c strofaddr.c time.c unlink.c utimes.c

ALL_FILES=$(WIN_FILES) $(UNIX_FILES)

DOBJS=$(ALL_FILES:.c=.$(DO))
SOBJS=$(ALL_FILES:.c=.$(SO))

LIBS=$(call SYSLIB,wsock32)

CAML_OBJS=unix.cmo unixLabels.cmo
CAMLOPT_OBJS=$(CAML_OBJS:.cmo=.cmx)

UNIX_CAML_FILES = unix.mli unixLabels.mli unixLabels.ml

all: dllunix.dll libunix.$(A) unix.cma

allopt: libunix.$(A) unix.cmxa

dllunix.dll: $(DOBJS)
	$(call MKDLL,dllunix.dll,tmp.$(A),$(DOBJS) ../../byterun/ocamlrun.$(A) $(LIBS))
	rm tmp.*

libunix.$(A): $(SOBJS)
	$(call MKLIB,libunix.$(A),$(SOBJS))

$(DOBJS) $(SOBJS): unixsupport.h

unix.cma: $(CAML_OBJS)
	$(CAMLC) -a -linkall -o unix.cma $(CAML_OBJS) \
          -dllib -lunix -cclib -lunix -cclib $(LIBS)

unix.cmxa: $(CAMLOPT_OBJS)
	$(CAMLOPT) -a -linkall -o unix.cmxa $(CAMLOPT_OBJS) \
          -cclib -lunix -cclib $(LIBS)

partialclean:
	rm -f *.cm*

clean: partialclean
	rm -f *.$(A) *.dll *.$(O)
	rm -f $(UNIX_FILES) $(UNIX_CAML_FILES)

install:
	cp dllunix.dll $(STUBLIBDIR)/dllunix.dll
	cp libunix.$(A) $(LIBDIR)/libunix.$(A)
	cp $(CAML_OBJS:.cmo=.cmi) unix.cma $(CAML_OBJS:.cmo=.mli) $(LIBDIR)

installopt:
	cp unix.cmxa $(CAML_OBJS:.cmo=.cmx) unix.$(A) $(LIBDIR)

unixLabels.cmo: unixLabels.ml
	$(CAMLC) -c $(COMPFLAGS) -nolabels unixLabels.ml

unixLabels.cmx: unixLabels.ml
	$(CAMLOPT) -c $(COMPFLAGS) -nolabels unixLabels.ml

$(UNIX_FILES) $(UNIX_CAML_FILES): %: ../unix/%
	cp ../unix/$* $*

.SUFFIXES: .ml .mli .cmo .cmi .cmx .$(DO) .$(SO)

.mli.cmi:
	$(CAMLC) -c $(COMPFLAGS) $<

.ml.cmo:
	$(CAMLC) -c $(COMPFLAGS) $<

.ml.cmx:
	$(CAMLOPT) -c $(COMPFLAGS) $<

.c.$(DO):
	$(BYTECC) $(DLLCCCOMPOPTS) $(CFLAGS) -c $<
	mv $*.$(O) $*.$(DO)

.c.$(SO):
	$(BYTECC) $(BYTECCCOMPOPTS) $(CFLAGS) -c $<
	mv $*.$(O) $*.$(SO)

depend:

include .depend


syntax highlighted by Code2HTML, v. 0.9.1