summaryrefslogtreecommitdiff
path: root/otherlibs/unix/Makefile
blob: 8fb3fef8b0fccb8d6fcc025f8a2461b679dab1df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*            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 Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************

# Makefile for the Unix interface library

ROOTDIR = ../..
# Note: at the moment, we need to include the configuration makefile directly
# even before we can include Makefile.otherlibs.common
# because the UNIX_OR_WIN32 variable must be defined even before
# we can include Makefile.otherlibs.common
# This will be fixed later
include $(ROOTDIR)/Makefile.config_if_required

LIBNAME=unix

EXTRACAMLFLAGS=-nolabels

# This flag is used to disable compatibility definitions in header files to
# ensure that they're not accidentally used in the library itself.
OC_CPPFLAGS += -DCAML_BUILDING_UNIX

unixLabels.cmi: \
  EXTRACAMLFLAGS += -pp "$(AWK) -f $(ROOTDIR)/stdlib/expand_module_aliases.awk"

ifeq "$(UNIX_OR_WIN32)" "win32"
WIN32_LIBS=$(call SYSLIB,ws2_32) $(call SYSLIB,advapi32)
LINKOPTS=$(addprefix -cclib ,$(WIN32_LIBS))
LDOPTS=$(addprefix -ldopt ,$(WIN32_LIBS))
else # Unix
# dllunix.so particularly requires libm for modf symbols
LDOPTS=$(NATIVECCLIBS)
endif

# C source files common to both Unix and Windows
COMMON_C_SOURCES = $(addsuffix .c, \
  access addrofstr chdir chmod cst2constr cstringv execv execve execvp fsync \
  mkdir exit getaddrinfo getcwd gethost gethostname getnameinfo getproto \
  getserv gmtime mmap_ba putenv rmdir socketaddr strofaddr time unlink)

# OS-specific C source files
OS_C_SOURCES = $(addsuffix _$(UNIX_OR_WIN32).c, \
  accept bind channels close connect dup envir errmsg getpeername getpid \
  getsockname gettimeofday isatty link listen lockf lseek mmap open pipe \
  read readlink realpath rename select sendrecv shutdown sleep socket \
  socketpair sockopt stat symlink times truncate unixsupport utimes write)

# OS-specific modules that have no counterpart on the other OS
ifeq "$(UNIX_OR_WIN32)" "win32"
OS_C_SOURCES += $(addsuffix .c, \
  close_on createprocess nonblock startup system windbug windir winlist \
  winwait winworker)
else
OS_C_SOURCES += $(addsuffix .c, \
  alarm chown chroot closedir dup2 fchmod fchown fcntl fork ftruncate \
  getegid geteuid getgid getgr getgroups getlogin getppid getpw getuid \
  initgroups itimer kill mkfifo nice opendir readdir rewinddir setgid \
  setgroups setsid setuid signals spawn termios umask wait)
endif

C_SOURCES = $(COMMON_C_SOURCES) $(OS_C_SOURCES)

CAMLOBJS=unix.cmo unixLabels.cmo

HEADERS=unixsupport.h socketaddr.h

include ../Makefile.otherlibs.common

unix.ml: unix_$(UNIX_OR_WIN32).ml
	cp $< $@

distclean::
	rm -f unix.ml

.PHONY: depend
depend: unix.ml
	$(OCAMLDEP_CMD) *.mli *.ml > .depend

include .depend