summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/fiddle/win32/libffi.mk.tmpl
blob: 2a16e8efec6ab8ca20c48aedc48f57cd30e248eb (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
91
92
93
94
95
96
# -*- makefile -*-
# ====================================================================
#
# libffi Windows Makefile
#
#
# ====================================================================
#
NAME    = ffi
TARGET  = @TARGET@
CC      = cl
!if "$(TARGET)" == "X86_WIN64"
AS      = ml64
!else
AS      = ml
!endif
AR      = link
DLEXT   = dll
OBJEXT  = obj
LIBEXT  = lib
TOPDIR  = @SRCDIR@
CPP     = $(CC) -EP
CFLAGS  = @CFLAGS@
ARFLAGS = -lib
ASFLAGS = -coff -W3 -Cx
INCLUDES= -I. -I./include -I./src/x86 \
          -I$(TOPDIR)/include -I$(TOPDIR)/include/src/x86

SRCDIR  = $(TOPDIR)/src
WORKDIR = ./.libs
BUILDDIR= ./src
LIBNAME = lib$(NAME)
STATICLIB= $(WORKDIR)/$(LIBNAME)_convenience.$(LIBEXT)

HEADERS = \
        ./fficonfig.h
FFI_HEADERS = \
        ./include/ffi.h \
        ./include/ffitarget.h

!if "$(TARGET)" == "X86_WIN32"
OSSRC   = win32
!else if "$(TARGET)" == "X86_WIN64"
OSSRC   = win64
!else
! error unknown target: $(TARGET)
!endif

OBJECTS = \
        $(BUILDDIR)/closures.$(OBJEXT) \
        $(BUILDDIR)/debug.$(OBJEXT) \
        $(BUILDDIR)/java_raw_api.$(OBJEXT) \
        $(BUILDDIR)/prep_cif.$(OBJEXT) \
        $(BUILDDIR)/raw_api.$(OBJEXT) \
        $(BUILDDIR)/types.$(OBJEXT) \
        $(BUILDDIR)/x86/ffi.$(OBJEXT) \
        $(BUILDDIR)/x86/$(OSSRC).$(OBJEXT)
ASMSRCS = \
        $(BUILDDIR)/x86/$(OSSRC).asm

.SUFFIXES : .S .asm

all: $(WORKDIR) $(STATICLIB)

{$(SRCDIR)}.c{$(BUILDDIR)}.$(OBJEXT):
        $(CC) -c $(CFLAGS) $(INCLUDES) -Fo$(@:\=/) -Fd$(WORKDIR)/$(NAME)-src $(<:\=/)

{$(SRCDIR)/x86}.c{$(BUILDDIR)/x86}.$(OBJEXT):
        $(CC) -c $(CFLAGS) $(INCLUDES) -Fo$(@:\=/) -Fd$(WORKDIR)/$(NAME)-src $(<:\=/)

{$(SRCDIR)/x86}.S{$(BUILDDIR)/x86}.asm:
        $(CPP) $(CFLAGS) $(INCLUDES) $(<:\=/) >$(@:\=/)

{$(BUILDDIR)/x86}.asm{$(BUILDDIR)/x86}.$(OBJEXT):
        cd $(@D) && $(AS) -c $(ASFLAGS) -Fo $(@F) $(<F)

$(BUILDDIR)/x86/$(OSSRC).asm: $(SRCDIR)/x86/$(OSSRC).S

$(OBJECTS): $(FFI_HEADERS) $(HEADERS)

$(WORKDIR):
        -@if not exist "$(WORKDIR:/=\)\$(NULL)" mkdir $(WORKDIR:/=\)

$(STATICLIB): $(WORKDIR) $(OBJECTS)
        $(AR) $(ARFLAGS) -out:$(STATICLIB) @<<
        $(OBJECTS)
<<

clean:
        -@del /Q $(OBJECTS:/=\) 2>NUL
        -@del /Q $(ASMSRCS:/=\) 2>NUL
        -@del /Q /S $(WORKDIR:/=\) 2>NUL

distclean: clean
        -@del /Q $(HEADERS:/=\) $(FFI_HEADERS:/=\) 2>NUL
        -@del /Q Makefile 2>NUL