summaryrefslogtreecommitdiff
path: root/Makefile
blob: b45d69ed8084ac4c94575fae12dc6f5a745a0c83 (plain) (blame)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
############################################################-*-Makefile-*-####
# Makefile for the Scala Compiler
##############################################################################
# $Id$

##############################################################################
# Include private stuff

-include Makefile.private

##############################################################################
# Variables

ROOT			 = .

# project
PROJECT_NAME		 = scala
PROJECT_ROOT		 = $(ROOT)
PROJECT_SOURCES		+= $(RUNTIME_SOURCES)
PROJECT_SOURCES		+= $(COMPILER_SOURCES)
PROJECT_SOURCES		+= $(INTERPRETER_SOURCES)
PROJECT_OUTPUTDIR	 = $(PROJECT_ROOT)/classes
PROJECT_CLASSPATH	 = $(PROJECT_OUTPUTDIR)
PROJECT_LISTDIR		 = $(PROJECT_ROOT)/config/list
PROJECT_SOURCEDIR	 = $(PROJECT_ROOT)/sources

# scala scripts wrapper
SCRIPTS_PREFIX		 = $(PROJECT_ROOT)/bin
SCRIPTS_WRAPPER_NAME	 = .scala_wrapper
SCRIPTS_WRAPPER_LINKS	+= $(SCRIPTS_WRAPPER_ALIASES:%=$(SCRIPTS_PREFIX)/%)
SCRIPTS_WRAPPER_ALIASES	+= socos
SCRIPTS_WRAPPER_ALIASES	+= socos-debug
SCRIPTS_WRAPPER_ALIASES	+= siris
SCRIPTS_WRAPPER_ALIASES	+= siris-debug
SCRIPTS_WRAPPER_ALIASES	+= surus
SCRIPTS_WRAPPER_ALIASES	+= surus-debug

# automatic generation of Function<n>.java and Tuple<n>.scala files
TEMPLATE_EXPANDER	 = ./bin/expand-template

FUNCTION_PREFIX		 = $(RUNTIME_ROOT)
FUNCTION_FILES		+= $(filter $(FUNCTION_PREFIX)/Function%.java,$(RUNTIME_SOURCES))
FUNCTION_TEMPLATE	 = $(FUNCTION_PREFIX)/Function.tmpl
FUNCTION_RULES		 = $(FUNCTION_PREFIX)/Function.scm

TUPLE_PREFIX		 = $(LIBRARY_ROOT)
TUPLE_FILES		+= $(filter $(TUPLE_PREFIX)/Tuple%.scala,$(LIBRARY_FILES))
TUPLE_TEMPLATE		 = $(TUPLE_PREFIX)/Tuple.tmpl
TUPLE_RULES		 = $(TUPLE_PREFIX)/Tuple.scm

# scala runtime
RUNTIME_ROOT		 = $(PROJECT_SOURCEDIR)/scala
RUNTIME_LIST		 = $(call READLIST,$(PROJECT_LISTDIR)/runtime.lst)
RUNTIME_SOURCES		+= $(RUNTIME_LIST:%=$(RUNTIME_ROOT)/%)
RUNTIME_JC_FILES	+= $(RUNTIME_SOURCES)

# scala compiler
COMPILER_ROOT		 = $(PROJECT_SOURCEDIR)/scalac
COMPILER_LIST		 = $(call READLIST,$(PROJECT_LISTDIR)/compiler.lst)
COMPILER_SOURCES	+= $(COMPILER_LIST:%=$(COMPILER_ROOT)/%)
COMPILER_JC_FILES	 = $(COMPILER_SOURCES)
COMPILER_JC_CLASSPATH	 = $(PROJECT_CLASSPATH):$(BCEL_JARFILE):$(MSIL_JARFILE)

# scala interpreter
INTERPRETER_ROOT	 = $(PROJECT_SOURCEDIR)/scalai
INTERPRETER_LIST	 = $(call READLIST,$(PROJECT_LISTDIR)/interpreter.lst)
INTERPRETER_SOURCES	+= $(INTERPRETER_LIST:%=$(INTERPRETER_ROOT)/%)
INTERPRETER_JC_FILES	 = $(INTERPRETER_SOURCES)

# scala library

LIBRARY_ROOT		 = $(RUNTIME_ROOT)
LIBRARY_LIST		 = $(call READLIST,$(PROJECT_LISTDIR)/library.lst)
LIBRARY_FILES		+= $(LIBRARY_LIST:%=$(LIBRARY_ROOT)/%)

# java compilation

JC_COMPILER		 = PICO
JC_OUTPUTDIR		 = $(PROJECT_OUTPUTDIR)
JC_CLASSPATH		 = $(PROJECT_CLASSPATH)

##############################################################################
# Variables - libraries

# BCEL (see http://jakarta.apache.org/bcel/)

BCEL_HOME		?= /home/linuxsoft/apps/BCEL-5
BCEL_JARFILE		?= $(BCEL_HOME)/bcel.jar
BCEL_LICENSE		 = $(BCEL_HOME)/LICENSE

# needed for the .NET backend

MSIL_HOME		?= /home/linuxsoft/apps/java2net
MSIL_JARFILE		?= $(MSIL_HOME)/msil.jar

##############################################################################
# Variables - tools

ECHO			?= echo
CAT			?= cat
JAR			?= jar
GREP			?= grep
FIND			?= find
WC			?= wc
SED			?= sed
M4			?= m4
RM			?= rm -f
CP			?= cp
LN			?= ln
MKDIR			?= mkdir
TOUCH			?= touch
CHMOD			?= chmod
DIRNAME			?= dirname
BASENAME		?= basename
DATE			?= date
NICE			?= nice
ZIP			?= zip
UNIX2DOS		?= unix2dos

PICO			?= pico
PICO_FLAGS		+= -make -source 1.4

##############################################################################
# Functions

RUN			 = echo $(1); $(1) || exit $$?
READLIST		 = $(shell cat $(1) | grep -v "^\#")

make			+= $(MAKE) MAKELEVEL=$(MAKELEVEL) --no-print-directory

##############################################################################
# Commands

all		: scripts
all		: runtime
all		: compiler
all		: interpreter
all		: library

force		:
	$(RM) .latest-interpreter
	$(RM) .latest-compiler
	$(RM) .latest-runtime
	@$(make) all

clean		:
	$(RM) .latest-interpreter
	$(RM) .latest-compiler
	$(RM) .latest-runtime
	$(RM) -r $(PROJECT_OUTPUTDIR)/*

distclean	: clean
	$(RM) .latest-*
	$(RM) $(TUPLE_FILES)
	$(RM) $(FUNCTION_FILES)
	$(RM) $(SCRIPTS_WRAPPER_LINKS)
	$(RM) -r $(PROJECT_OUTPUTDIR)

scripts		: $(SCRIPTS_WRAPPER_LINKS)
runtime		: .latest-runtime
compiler	: .latest-compiler
interpreter	: .latest-interpreter
library		: .latest-library

.PHONY		: all
.PHONY		: force
.PHONY		: clean
.PHONY		: distclean
.PHONY		: scripts
.PHONY		: runtime
.PHONY		: compiler
.PHONY		: interpreter
.PHONY		: library

##############################################################################
# Targets

.latest-runtime		: $(RUNTIME_JC_FILES)
	@$(MAKE) jc target=RUNTIME RUNTIME_JC_FILES='$?'
	touch $@

.latest-compiler	: $(COMPILER_JC_FILES)
	@$(make) jc target=COMPILER COMPILER_JC_FILES='$?'
	touch $@

.latest-interpreter	: $(INTERPRETER_JC_FILES)
	@$(make) jc target=INTERPRETER INTERPRETER_JC_FILES='$?'
	touch $@

.latest-library		: $(LIBRARY_FILES)
	touch $@

##############################################################################
# Rules

$(SCRIPTS_WRAPPER_LINKS):
	$(LN) -s $(SCRIPTS_WRAPPER_NAME) $@;

$(FUNCTION_FILES): $(FUNCTION_TEMPLATE) $(FUNCTION_RULES)
	$(TEMPLATE_EXPANDER) $(FUNCTION_RULES) $(FUNCTION_TEMPLATE) $@

$(TUPLE_FILES): $(TUPLE_TEMPLATE) $(TUPLE_RULES)
	$(TEMPLATE_EXPANDER) $(TUPLE_RULES) $(TUPLE_TEMPLATE) $@

##############################################################################

include $(ROOT)/support/make/jc.mk
include $(ROOT)/support/make/exec.mk
include $(ROOT)/support/make/grep.mk
include $(ROOT)/support/make/wc.mk

##############################################################################