-
Notifications
You must be signed in to change notification settings - Fork 315
/
MakePkg
106 lines (86 loc) · 2.49 KB
/
MakePkg
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
97
98
99
100
101
102
103
104
105
#-*- Makefile -*-
RLIB=../../../library
DPKG=$(RLIB)/$(PKG)
SPKG=.
ifeq ($(strip $(DLLNM)),)
DLLNAME=$(PKG)
else
DLLNAME=$(DLLNM)
endif
#this can be overwriten by the caller
SRC = src
#source directory
SSPKG=$(SPKG)/$(SRC)
LSOURCES=$(wildcard $(SSPKG)/*.c $(SSPKG)/*.f)
ifeq ($(strip $(LSOURCES)),)
LOBJS=
DYNLIB=
else
LOBJS=$(foreach i, $(LSOURCES), $(basename $i).o)
DYNLIB=$(DPKG)/libs/$(DLLNAME).dll
endif
# data
DSOURCES=$(filter-out $(SPKG)/data/CVS, $(wildcard $(SPKG)/data/*))
ifeq ($(strip $(DSOURCES)),)
DATA=
else
DATA=$(DPKG)/data
endif
# R
PKGRFILES0=$(wildcard $(SPKG)/R/*.[RSqrs])
RWIN32=$(wildcard $(SPKG)/R/windows/*.[Rr])
ifeq ($(strip RWIN32),)
PKGRFILES=$(PKGRFILES0)
else
R1 = $(foreach i,$(RWIN32), $(addprefix $(SPKG)/R/, $(notdir $i)))
R2 = $(R1) $(SPKG)/R/system.unix.R $(SPKG)/R/system.mac.R
PKGRFILES=$(filter-out $(R2), $(PKGRFILES0)) $(RWIN32)
endif
# Others
OFILES0=$(wildcard $(SPKG)/*)
OFILES1= DESCRIPTION INDEX TITLE
OFILES-NO= R r chm data man src src-c Makefile.in inst check orig \
DESCRIPTION DESCRIPTION.in INDEX TITLE index title \
configure configure.in
OFILES3=$(foreach i, $(OFILES1), $(SPKG)/$i)
OFILES2=$(foreach i, $(OFILES-NO), $(SPKG)/$i)
OFILES=$(filter-out $(OFILES2),$(OFILES0))
INSTFILES=$(wildcard $(SPKG)/inst/*)
all: $(DPKG)/zzzz $(DPKG)/R/$(PKG) $(DATA) $(DYNLIB)
include $(RHOME)/src//gnuwin32/MkRules
clean:
$(RM) $(SSPKG)/$(DLLNAME).dll $(LOBJS) $(SSPKG)/$(DLLNAME).a $(SSPKG)/$(DLLNAME).def
$(RM) -rf $(SPKG)/chm -rf $(SPKG)/check
SEDP='/^[ ]*$$/d;s/$(DLLNAME).so/$(DLLNAME).dll/'
$(DPKG)/R/$(PKG): $(PKGRFILES)
ifneq ($(strip $(PKGRFILES)),)
$(MKDIR) -p $(DPKG)/R
$(CAT) $(PKGRFILES) | sed $(SEDP) > $@
else
@$(ECHO) " no R files in this package"
endif
$(SPKG)/TITLE:
if [ ! -f $(SPKG)/TITLE -a -f $(SPKG)/DESCRIPTION ] ; then \
$(AWK) -f $(RHOME)/src/gnuwin32/maketitle $(SPKG)/DESCRIPTION > $@; \
fi
# This fails if DESCRIPTION.. doesn't exist.
# $(DPKG)/zzzz: $(OFILES3) $(OFILES)
# On the other hand, ...zzzz is never created so
$(DPKG)/zzzz: $(SPKG)/TITLE
@$(ECHO) "---------- Making package $(PKG) ------------"
$(MKDIR) -p $(DPKG)
ifeq ($(strip $(INSTFILES)),)
-$(CP) -r $(OFILES3) $(OFILES) $(DPKG)/
else
-$(CP) -r $(OFILES3) inst/* $(DPKG)/
endif
$(DATA): $(DSOURCES)
$(MKDIR) -p $(DATA)
$(CP) $^ $@
$(DYNLIB): $(SSPKG)/$(DLLNAME).dll
$(MKDIR) -p $(DPKG)/libs
$(CP) $^ $@
$(SSPKG)/$(DLLNAME).dll: FORCE
$(MAKE) -C $(SSPKG) RHOME=$(RHOME) \
-f $(RHOME)/src/gnuwin32/MakeDll DLLNAME=$(DLLNAME)
FORCE: