-
Notifications
You must be signed in to change notification settings - Fork 16
/
smalltalk.make
68 lines (53 loc) · 2.99 KB
/
smalltalk.make
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
# Makefile for statically compiling pragmatic smalltalk modules. Needs to be
# included after the project specific makefile statements but before the include
# directive that includes the project type specific makefile from gnustep-make.
#
# Created: April 2012
#
# Written by Niels Grewe <niels.grewe@halbordnung.de>
# Modify by Mathieu Suen <mathieu@nebu.li>
# Place smalltalk files into the GNUSTEP_OBJ_INSTANCE_DIR, eventhough
# gnustep-make hides the variable from us.
ifeq ($(strip $(GNUSTEP_OBJ_INSTANCE_DIR)),)
GNUSTEP_OBJ_INSTANCE_DIR=$(GNUSTEP_BUILD_DIR)/$(GNUSTEP_INSTANCE).obj
endif
SMALLTALK_BITCODES = $(patsubst %.st,%.st.bc,$($(GNUSTEP_INSTANCE)_SMALLTALK_FILES))
SMALLTALK_BITCODE_FILES = $(addprefix $(GNUSTEP_OBJ_INSTANCE_DIR)/,$(SMALLTALK_BITCODES))
SMALLTALK_BUNDLE_LIB = $(patsubst %.bundle,obj/%.bundle/Resources/,$($(GNUSTEP_INSTANCE)_SMALLTALK_BUNDLES))
SMALLTALK_BUNDLE_LIB_DIR = $(addprefix $(GNUSTEP_BUILD_DIR)/,$(SMALLTALK_BUNDLE_LIB))
SMALLTALK_BUNDLE_LIB_FILES = $(addsuffix out.so,$(SMALLTALK_BUNDLE_LIB_DIR))
# The bitcode location for MsgSendSmallInt can be overridden, e.g. if
# LanguageKit was installed into a different installation domain.
LK_SMALL_INT_BITCODE?= $(firstword $(wildcard $(foreach framework_dir,${GNUSTEP_FRAMEWORK_DIRS},$(framework_dir)/LanguageKitCodeGen.framework/Versions/Current/Resources/MsgSendSmallInt.bc)))
$(GNUSTEP_OBJ_INSTANCE_DIR)/%.st.bc : %.st
@echo "Compiling Pragmatic Smalltalk file $< to LLVM bitcode ..."
@edlc -c -f $< -o $@
$(GNUSTEP_BUILD_DIR)/obj/%.bundle/Resources/out.so : %.bundle
@echo "Compiling smalltalk bundle $< to shared library ..."
@edlc -c -b $< -o $@
$(SMALLTALK_BUNDLE_LIB_FILES) :: $(SMALLTALK_BUNDLE_ST_FILES) | $(SMALLTALK_BUNDLE_LIB_DIR)
$(SMALLTALK_BUNDLE_LIB_DIR) :
@mkdir -p $@
ifneq ($(strip $(SMALLTALK_BITCODE_FILES)),)
# TODO: Decide whether we want relocatable code by looking at whether we are
# building a framework or an executable
$(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.bc : $(SMALLTALK_BITCODE_FILES)
@echo "Linking LLVM bitcodes from Pragmatic Smalltalk files ..."
@llvm-link -o $@ $(SMALLTALK_BITCODE_FILES) $(LK_SMALL_INT_BITCODE)
# TODO: Load opts for the GNUstep runtime
$(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.opt.bc : $(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.bc
@echo "Optimizing LLVM bitcode ..."
@opt -O3 $< -o $@
$(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.opt.s : $(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.opt.bc
@echo "Compiling LLVM bitcode ..."
@llc -relocation-model=pic -o $@ $<
$(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.opt.o : $(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.opt.s
@echo "Assembling LLVM bitcode ..."
@clang -c -O3 -o $@ $<
# Adding smalltalk.opt.o to _OBJ_FILES connects the above targets to the build.
$(GNUSTEP_INSTANCE)_OBJ_FILES+=$(GNUSTEP_OBJ_INSTANCE_DIR)/smalltalk.opt.o
# Statically compiled Smalltalk code needs the LK runtime and the Smalltalk
# support libraries.
$(GNUSTEP_INSTANCE)_LDFLAGS+=-lLanguageKitRuntime -lSmalltalkSupport
endif
$(GNUSTEP_INSTANCE)_OBJ_FILES+=$(SMALLTALK_BUNDLE_LIB_FILES)