/
MakeDll
96 lines (80 loc) · 2.3 KB
/
MakeDll
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 -*-
all: makeMakedeps $(DLLNAME).dll
.PHONY : all makeMakedeps
# set this in Makevars.win to supply your own resource file
RCNAME=${DLLNAME}_res
# set this (e.g. in SHLIB) to suppress adding version info to the DLL
RCOBJ=$(RCNAME).o
# Don't use SOURCES as this get passed on for libR.
CFSOURCES=$(wildcard -f *.c *.f *.f90 *.f95)
CSOURCES=$(wildcard -f *.c)
CXXSOURCES=$(wildcard -f *.cc *.cpp *.C)
FSOURCES=$(wildcard -f *.f)
FCSOURCES=$(wildcard -f *.f90 *.f95)
OBJSA=$(foreach i,$(CSOURCES) $(FSOURCES) $(CXXSOURCES),$(basename $i).o)
include $(RHOME)/src/gnuwin32/MkRules
ifneq ($(strip $(FCSOURCES)),)
# don't assume F95 can be cross-compiled in the same way
DLL=$(F95)
else
ifneq ($(strip $(CXXSOURCES)),)
DLL_LDMAIN=g++
endif
ifneq ($(strip $(FSOURCES)),)
EXTRA_LIBS=$(FLIBS)
endif
endif
ifdef DEBUG
DLLFLAGS=
DEBUGFLAG=-g -Wall
else
DLLFLAGS=-s
DEBUGFLAG=-Wall
endif
CPPFLAGS=$(PKG_CPPFLAGS) -I$(RHOME)/include
CFLAGS=$(CPPFLAGS) $(DEBUGFLAG) -O3 $(PKG_CFLAGS)
CXXFLAGS=$(CPPFLAGS) $(DEBUGFLAG) -O3 $(PKG_CXXFLAGS)
FFLAGS=-O3 $(DEBUGFLAG) $(PKG_FFLAGS)
DLLLIBS=-L$(RHOME)/bin $(PKG_LIBS) $(EXTRA_LIBS) -lR
RESFLAGS=--include-dir $(RHOME)/include
# Note: DLLLIBS has already set -L$(RHOME)/bin
BLAS_LIBS=-lRblas
ifeq ($(strip $(USE_ACML_LAPACK)),YES)
LAPACK_LIBS=-L"$(ACML_PATH)" -lacml -lg2c
else
LAPACK_LIBS=-lRlapack
endif
# for use by Makevars.win
R_HOME=$(RHOME)
AA=$(wildcard Makefile)
ifeq ($(AA),Makefile)
include Makefile
else
OBJS=$(filter-out $(OBJS-NO),$(OBJSA))
endif
AA=$(wildcard Makevars.win)
ifeq ($(AA),Makevars.win)
include Makevars.win
else
-include Makevars
endif
$(DLLNAME)_res.rc:
@PERL5LIB=$(RHOME)/share/perl perl $(RHOME)/src/gnuwin32/makeDllRes.pl $(DLLNAME) > $@
$(DLLNAME)_res.o: $(DLLNAME)_res.rc $(RHOME)/include/Rversion.h
ifeq ($(wildcard $(DLLNAME)-win.def),$(DLLNAME)-win.def)
$(DLLNAME).dll : $(DLLNAME)-win.def $(OBJS) $(RCOBJ)
$(DLL) -shared $(DLLFLAGS) $($*-DLLFLAGS) -o $@ $^ $($*-DLLLIBS) $(DLLLIBS)
else
$(DLLNAME).dll : $(OBJS) $(RCOBJ)
endif
# Dependencies
CXXSOURCES1=$(wildcard -f *.cc)
CXXSOURCES2=$(wildcard -f *.cpp)
CXXSOURCES3=$(wildcard -f *.C)
DEPS=$(CSOURCES:.c=.d) $(CXXSOURCES1:.cc=.d) $(CXXSOURCES2:.cpp=.d) $(CXXSOURCES3:.C=.d)
makeMakedeps: $(DEPS)
@$(RM) Makedeps
ifneq ($(strip $(DEPS)),)
@cat $(DEPS) >> Makedeps
endif
-include Makedeps