Skip to content

Commit 1fc51b7

Browse files
authored
Add simple cross compile mechanism for flisp/libsupport (+ dependencies) (JuliaLang#30526)
This makes some incremental progress towards JuliaLang#30338 in the build system. In particular, it allows compiling a separate boostrap version of flisp and its dependencies for an architecture different from the target. The immediate use case here is to build libjulia for wasm. Of course, there's still the enormous problem of building the system image itself, but luckily wasm is largely memory-layout-identical to linux32, so doing that limited bootstrap is fairly easy after this change (though the subject of a different PR). The mechanism here is to use the out-of-tree build support to create separate host/ subdirectories for the build directories of interest. These have a special make variable set that tell it to include a different Make.user (or in the absence thereof use the host defaults).
1 parent 62a9efd commit 1fc51b7

File tree

9 files changed

+118
-51
lines changed

9 files changed

+118
-51
lines changed

Make.inc

+22-10
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,19 @@ endif
126126

127127
# we include twice to pickup user definitions better
128128
# include from JULIAHOME first so that BUILDROOT can override
129-
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
130-
include $(JULIAHOME)/Make.user
129+
MAYBE_HOST :=
130+
ifneq ($(BUILDING_HOST_TOOLS),1)
131+
MAKE_USER_FNAME = Make.user
132+
else
133+
MAYBE_HOST := /host
134+
MAKE_USER_FNAME = Make.host.user
135+
endif
136+
137+
ifeq (exists, $(shell [ -e $(JULIAHOME)/$(MAKE_USER_FNAME) ] && echo exists ))
138+
include $(JULIAHOME)/$(MAKE_USER_FNAME)
131139
endif
132-
ifeq (exists, $(shell [ -e $(BUILDROOT)/Make.user ] && echo exists ))
133-
include $(BUILDROOT)/Make.user
140+
ifeq (exists, $(shell [ -e $(BUILDROOT)/$(MAKE_USER_FNAME) ] && echo exists ))
141+
include $(BUILDROOT)/$(MAKE_USER_FNAME)
134142
endif
135143

136144
# disable automatic Makefile rules
@@ -236,8 +244,12 @@ sysconfdir := $(prefix)/etc
236244
endif
237245

238246
# Directories where things get built into
239-
build_prefix := $(BUILDROOT)/usr
247+
build_prefix := $(BUILDROOT)/usr$(MAYBE_HOST)
248+
ifeq ($(BUILDING_HOST_TOOLS), 1)
249+
build_staging := $(BUILDROOT)/usr-host-staging
250+
else
240251
build_staging := $(build_prefix)-staging
252+
endif
241253
build_bindir := $(build_prefix)/bin
242254
build_depsbindir := $(build_prefix)/tools
243255
build_libdir := $(build_prefix)/lib
@@ -571,11 +583,11 @@ else
571583
LOCALBASE ?= /usr
572584
endif
573585

574-
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
575-
include $(JULIAHOME)/Make.user
586+
ifeq (exists, $(shell [ -e $(JULIAHOME)/$(MAKE_USER_FNAME) ] && echo exists ))
587+
include $(JULIAHOME)/$(MAKE_USER_FNAME)
576588
endif
577-
ifeq (exists, $(shell [ -e $(BUILDROOT)/Make.user ] && echo exists ))
578-
include $(BUILDROOT)/Make.user
589+
ifeq (exists, $(shell [ -e $(BUILDROOT)/$(MAKE_USER_FNAME) ] && echo exists ))
590+
include $(BUILDROOT)/$(MAKE_USER_FNAME)
579591
endif
580592

581593
# A bit of a kludge to work around libraries linking to FreeBSD's outdated system libgcc_s
@@ -1064,7 +1076,7 @@ else ifneq ($(USEMSVC), 1)
10641076
endif
10651077

10661078
ifeq ($(OS), Linux)
1067-
OSLIBS += -Wl,--no-as-needed -ldl -lrt -lpthread -Wl,--export-dynamic,--as-needed,--no-whole-archive $(LIBUNWIND)
1079+
OSLIBS += -Wl,--no-as-needed -ldl -lrt -lpthread -Wl,--export-dynamic,--as-needed,--no-whole-archive
10681080
# Detect if ifunc is supported
10691081
IFUNC_DETECT_SRC := 'void (*f0(void))(void) { return (void(*)(void))0L; }; void f(void) __attribute__((ifunc("f0")));'
10701082
ifeq (supported, $(shell echo $(IFUNC_DETECT_SRC) | $(CC) -Werror -x c - -S -o /dev/null > /dev/null 2>&1 && echo supported))

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ all: debug release
99
# sort is used to remove potential duplicates
1010
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/stdlib $(build_man1dir))
1111
ifneq ($(BUILDROOT),$(JULIAHOME))
12-
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/clangsa ui doc deps stdlib test test/embedding test/llvmpasses)
12+
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa ui doc deps stdlib test test/embedding test/llvmpasses)
1313
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS)) $(BUILDROOT)/sysimage.mk
1414
DIRS := $(DIRS) $(BUILDDIRS)
1515
$(BUILDDIRMAKE): | $(BUILDDIRS)

deps/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ include $(SRCDIR)/tools/common.mk
1414
include $(SRCDIR)/tools/git-external.mk
1515
include $(SRCDIR)/tools/bb-install.mk
1616

17+
BUILDDIR := $(BUILDDIR)$(MAYBE_HOST)
18+
1719
# Special comments:
1820
#
1921
# all targets in here should follow the same structure,

deps/libuv.mk

+9-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ ifneq ($(VERBOSE), 0)
2525
UV_MFLAGS += V=1
2626
endif
2727

28+
LIBUV_BUILDDIR := $(BUILDDIR)/$(LIBUV_SRC_DIR)
2829

29-
$(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured: $(SRCCACHE)/$(LIBUV_SRC_DIR)/source-extracted
30+
$(LIBUV_BUILDDIR)/build-configured: $(SRCCACHE)/$(LIBUV_SRC_DIR)/source-extracted
3031
touch -c $(SRCCACHE)/$(LIBUV_SRC_DIR)/aclocal.m4 # touch a few files to prevent autogen from getting called
3132
touch -c $(SRCCACHE)/$(LIBUV_SRC_DIR)/Makefile.in
3233
touch -c $(SRCCACHE)/$(LIBUV_SRC_DIR)/configure
@@ -35,11 +36,11 @@ $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured: $(SRCCACHE)/$(LIBUV_SRC_DIR)/sour
3536
$(dir $<)/configure --with-pic $(CONFIGURE_COMMON) $(UV_FLAGS)
3637
echo 1 > $@
3738

38-
$(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured
39+
$(LIBUV_BUILDDIR)/build-compiled: $(LIBUV_BUILDDIR)/build-configured
3940
$(MAKE) -C $(dir $<) $(UV_MFLAGS)
4041
echo 1 > $@
4142

42-
$(BUILDDIR)/$(LIBUV_SRC_DIR)/build-checked: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled
43+
$(LIBUV_BUILDDIR)/build-checked: $(LIBUV_BUILDDIR)/build-compiled
4344
ifeq ($(OS),$(BUILD_OS))
4445
-$(MAKE) -C $(dir $@) check
4546
endif
@@ -51,16 +52,16 @@ $(eval $(call staged-install, \
5152
$$(INSTALL_NAME_CMD)libuv.$$(SHLIB_EXT) $$(build_shlibdir)/libuv.$$(SHLIB_EXT)))
5253

5354
clean-libuv:
54-
-rm -rf $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled
55-
-$(MAKE) -C $(BUILDDIR)/$(LIBUV_SRC_DIR) clean
55+
-rm -rf $(LIBUV_BUILDDIR)/build-configured $(LIBUV_BUILDDIR)/build-compiled
56+
-$(MAKE) -C $(LIBUV_BUILDDIR) clean
5657

5758

5859
get-libuv: $(LIBUV_SRC_FILE)
5960
extract-libuv: $(SRCCACHE)/$(LIBUV_SRC_DIR)/source-extracted
60-
configure-libuv: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured
61-
compile-libuv: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled
61+
configure-libuv: $(LIBUV_BUILDDIR)/build-configured
62+
compile-libuv: $(LIBUV_BUILDDIR)/build-compiled
6263
fastcheck-libuv: #none
63-
check-libuv: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-checked
64+
check-libuv: $(LIBUV_BUILDDIR)/build-checked
6465

6566
else # USE_BINARYBUILDER_LIBUV
6667
LIBUV_BB_URL_BASE := https://github.com/JuliaPackaging/Yggdrasil/releases/download/LibUV-v2+$(LIBUV_VER)-julia+$(LIBUV_BB_REL)

deps/utf8proc.mk

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ UTF8PROC_OBJ_LIB := $(build_libdir)/libutf8proc.a
77
UTF8PROC_OBJ_HEADER := $(build_includedir)/utf8proc.h
88
UTF8PROC_CFLAGS := -O2
99
UTF8PROC_MFLAGS := CC="$(CC)" CFLAGS="$(CFLAGS) $(UTF8PROC_CFLAGS)" PICFLAG="$(fPIC)" AR="$(AR)"
10+
UTF8PROC_BUILDDIR := $(BUILDDIR)/$(UTF8PROC_SRC_DIR)
1011

11-
$(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-compiled: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/source-extracted
12+
$(UTF8PROC_BUILDDIR)/build-compiled: $(UTF8PROC_BUILDDIR)/source-extracted
1213
$(MAKE) -C $(dir $<) $(UTF8PROC_MFLAGS) libutf8proc.a
1314
echo 1 > $@
1415

15-
$(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-checked: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-compiled
16+
$(UTF8PROC_BUILDDIR)/build-checked: $(UTF8PROC_BUILDDIR)/build-compiled
1617
ifeq ($(OS),$(BUILD_OS))
1718
$(MAKE) -C $(dir $@) $(UTF8PROC_MFLAGS) check
1819
endif
@@ -32,9 +33,9 @@ clean-utf8proc:
3233
-$(MAKE) -C $(BUILDDIR)/$(UTF8PROC_SRC_DIR) clean
3334

3435
get-utf8proc: $(UTF8PROC_SRC_FILE)
35-
extract-utf8proc: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/source-extracted
36+
extract-utf8proc: $(UTF8PROC_BUILDDIR)/source-extracted
3637
configure-utf8proc: extract-utf8proc
37-
compile-utf8proc: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-compiled
38+
compile-utf8proc: $(UTF8PROC_BUILDDIR)/build-compiled
3839
# utf8proc tests disabled since they require a download
3940
fastcheck-utf8proc: #check-utf8proc
40-
check-utf8proc: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-checked
41+
check-utf8proc: $(UTF8PROC_BUILDDIR)/build-checked

src/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
/libjulia-release.so
1919
/libjulia-release.dylib
2020
/julia_version.h
21+
/flisp/host
22+
/support/host

src/Makefile

+13-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ FLAGS += -DLLVM_SHLIB
108108
endif # USE_LLVM_SHLIB == 1
109109
endif
110110

111-
COMMON_LIBS := -L$(build_shlibdir) -L$(build_libdir) $(LIBUV) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LLVMLINK) $(OSLIBS)
111+
COMMON_LIBS := -L$(build_shlibdir) -L$(build_libdir) $(LIBUV) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LLVMLINK) $(OSLIBS) $(LIBUNWIND)
112112
DEBUG_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport-debug.a $(COMMON_LIBS)
113113
RELEASE_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport.a $(COMMON_LIBS)
114114

@@ -121,8 +121,13 @@ SHIPFLAGS += $(FLAGS)
121121
SHIPFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys.$(SHLIB_EXT)\""
122122
DEBUGFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys-debug.$(SHLIB_EXT)\""
123123

124-
FLISP_EXECUTABLE_debug := $(BUILDDIR)/flisp/flisp-debug$(EXE)
125-
FLISP_EXECUTABLE_release := $(BUILDDIR)/flisp/flisp$(EXE)
124+
ifeq ($(USE_CROSS_FLISP), 1)
125+
FLISPDIR := $(BUILDDIR)/flisp/host
126+
else
127+
FLISPDIR := $(BUILDDIR)/flisp
128+
endif
129+
FLISP_EXECUTABLE_debug := $(FLISPDIR)/flisp-debug$(EXE)
130+
FLISP_EXECUTABLE_release := $(FLISPDIR)/flisp$(EXE)
126131
ifeq ($(OS),WINNT)
127132
FLISP_EXECUTABLE := $(FLISP_EXECUTABLE_release)
128133
else
@@ -232,10 +237,14 @@ $(BUILDDIR)/support/libsupport-debug.a: $(addprefix $(SRCDIR)/support/,*.h *.c *
232237
$(MAKE) -C $(SRCDIR)/support debug BUILDDIR='$(abspath $(BUILDDIR)/support)'
233238

234239
$(FLISP_EXECUTABLE_release): $(BUILDDIR)/flisp/libflisp.a
240+
$(MAKE) -C $(BUILDDIR)/flisp $(subst $(abspath $(BUILDDIR)/flisp)/,,$(abspath $(FLISP_EXECUTABLE_release)))
241+
242+
$(FLISP_EXECUTABLE_debug): $(BUILDDIR)/flisp/libflisp-debug.a
243+
$(MAKE) -C $(BUILDDIR)/flisp $(subst $(abspath $(BUILDDIR)/flisp)/,,$(abspath $(FLISP_EXECUTABLE_debug)))
244+
235245
$(BUILDDIR)/flisp/libflisp.a: $(addprefix $(SRCDIR)/flisp/,*.h *.c) $(BUILDDIR)/support/libsupport.a
236246
$(MAKE) -C $(SRCDIR)/flisp BUILDDIR='$(abspath $(BUILDDIR)/flisp)'
237247

238-
$(FLISP_EXECUTABLE_debug): $(BUILDDIR)/flisp/libflisp-debug.a
239248
$(BUILDDIR)/flisp/libflisp-debug.a: $(addprefix $(SRCDIR)/,flisp/*.h flisp/*.c) $(BUILDDIR)/support/libsupport-debug.a
240249
$(MAKE) -C $(SRCDIR)/flisp debug BUILDDIR='$(abspath $(BUILDDIR)/flisp)'
241250

src/flisp/Makefile

+40-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
JULIAHOME := $(abspath ../..)
1+
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
2+
JULIAHOME := $(abspath $(SRCDIR)/../..)
23
BUILDDIR := .
34
include $(JULIAHOME)/Make.inc
45

@@ -15,21 +16,30 @@ SRCS := flisp.c builtins.c string.c equalhash.c table.c iostream.c \
1516
julia_extensions.c
1617

1718
LLTDIR := ../support
19+
LLTSRCDIR := $(SRCDIR)/$(LLTDIR)
20+
NATIVE_BUILDDIR :=
21+
ifeq ($(BUILDING_HOST_TOOLS), 1)
22+
NATIVE_BUILDDIR := $(BUILDDIR)/..
23+
LLT_BUILDDIR := $(BUILDDIR)/../$(LLTDIR)/host
24+
else
25+
NATIVE_BUILDDIR := $(BUILDDIR)
26+
LLT_BUILDDIR := $(BUILDDIR)/$(LLTDIR)
27+
endif
1828

1929
HEADERS := $(wildcard *.h) $(LIBUV_INC)/uv.h $(wildcard $(LLTDIR)/*.h)
2030

2131
OBJS := $(SRCS:%.c=$(BUILDDIR)/%.o)
2232
DOBJS := $(SRCS:%.c=$(BUILDDIR)/%.dbg.obj)
23-
LLT_release := $(BUILDDIR)/$(LLTDIR)/libsupport.a
24-
LLT_debug := $(BUILDDIR)/$(LLTDIR)/libsupport-debug.a
33+
LLT_release := $(LLT_BUILDDIR)/libsupport.a
34+
LLT_debug := $(LLT_BUILDDIR)/libsupport-debug.a
2535
LIBFILES_release := $(LLT_release) $(LIBUV) $(LIBUTF8PROC)
2636
LIBFILES_debug := $(LLT_debug) $(LIBUV) $(LIBUTF8PROC)
2737
LIBS :=
2838
ifneq ($(OS),WINNT)
2939
LIBS += -lpthread
3040
endif
3141

32-
FLAGS := -I$(LLTDIR) $(JCFLAGS) $(HFILEDIRS:%=-I%) \
42+
FLAGS := -I$(LLTSRCDIR) $(JCFLAGS) $(HFILEDIRS:%=-I%) \
3343
-I$(LIBUV_INC) -I$(UTF8PROC_INC) -I$(build_includedir) $(LIBDIRS:%=-L%) \
3444
-DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS
3545
ifneq ($(USEMSVC), 1)
@@ -52,20 +62,22 @@ debug: $(BUILDDIR)/$(EXENAME)-debug$(EXE)
5262
$(BUILDDIR):
5363
mkdir -p $(BUILDDIR)
5464

55-
$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR)
65+
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
5666
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(SHIPFLAGS) $(DISABLE_ASSERTIONS) -c $< -o $@)
57-
$(BUILDDIR)/%.dbg.obj: %.c $(HEADERS) | $(BUILDDIR)
67+
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
5868
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(DEBUGFLAGS) -c $< -o $@)
5969

60-
$(BUILDDIR)/flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c
61-
$(BUILDDIR)/flisp.dbg.obj: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c
62-
$(BUILDDIR)/flmain.o: flmain.c flisp.h
63-
$(BUILDDIR)/flmain.dbg.obj: flmain.c flisp.h
70+
FLISP_SRCS := $(flisp.c cvalues.c types.c flisp.h print.c read.c equal.c:%=$(SRCDIR)/%)
71+
FLMAIN_SRCS := $(flmain.c flisp.h:%=$(SRCDIR)/%)
72+
$(BUILDDIR)/flisp.o: $(FLISP_SRCS)
73+
$(BUILDDIR)/flisp.dbg.obj: $(FLISP_SRCS)
74+
$(BUILDDIR)/flmain.o: $(FLMAIN_SRCS)
75+
$(BUILDDIR)/flmain.dbg.obj: $(FLMAIN_SRCS)
6476

65-
$(LLT_release): $(LLTDIR)/*.h $(LLTDIR)/*.c
66-
$(MAKE) -C $(LLTDIR) BUILDDIR='$(abspath $(BUILDDIR)/$(LLTDIR))'
67-
$(LLT_debug): $(LLTDIR)/*.h $(LLTDIR)/*.c
68-
$(MAKE) debug -C $(LLTDIR) BUILDDIR='$(abspath $(BUILDDIR)/$(LLTDIR))'
77+
$(LLT_release): $(LLTSRCDIR)/*.h $(LLTSRCDIR)/*.c
78+
$(MAKE) -C $(NATIVE_BUILDDIR)/$(LLTDIR) $(subst $(abspath $(NATIVE_BUILDDIR)/$(LLTDIR))/,,$(abspath $(LLT_release)))
79+
$(LLT_debug): $(LLTSRCDIR)/*.h $(LLTSRCDIR)/*.c
80+
$(MAKE) -C $(NATIVE_BUILDDIR)/$(LLTDIR) $(subst $(abspath $(NATIVE_BUILDDIR)/$(LLTDIR))/,,$(abspath $(LLT_debug)))
6981

7082
$(BUILDDIR)/$(LIBTARGET)-debug.a: $(DOBJS) | $(BUILDDIR)
7183
rm -rf $@
@@ -87,8 +99,19 @@ $(BUILDDIR)/$(EXENAME)-debug$(EXE): $(DOBJS) $(LIBFILES_debug) $(BUILDDIR)/$(LIB
8799
$(BUILDDIR)/$(EXENAME)$(EXE): $(OBJS) $(LIBFILES_release) $(BUILDDIR)/$(LIBTARGET).a $(BUILDDIR)/flmain.o | $(BUILDDIR)/flisp.boot
88100
@$(call PRINT_LINK, $(CCLD) $(SHIPFLAGS) $(JLDFLAGS) $(OBJS) $(BUILDDIR)/flmain.o -o $@ $(BUILDDIR)/$(LIBTARGET).a $(LIBFILES_release) $(LIBS) $(OSLIBS))
89101

90-
ifneq ($(BUILDDIR),.)
91-
$(BUILDDIR)/flisp.boot: flisp.boot | $(BUILDDIR)
102+
$(BUILDDIR)/host/Makefile:
103+
mkdir -p $(BUILDDIR)/host
104+
@# add Makefiles to the build directories for convenience (pointing back to the source location of each)
105+
@echo '# -- This file is automatically generated in julia/src/flisp/Makefile -- #' > $@
106+
@echo 'BUILDDIR=$(BUILDDIR)/host' >> $@
107+
@echo 'BUILDING_HOST_TOOLS=1' >> $@
108+
@echo 'include $(SRCDIR)/Makefile' >> $@
109+
110+
$(BUILDDIR)/host/$(EXENAME): $(BUILDDIR)/host/Makefile
111+
make -C $(BUILDDIR)/host $(EXENAME)
112+
113+
ifneq ($(BUILDDIR)$(BUILDING_HOST_TOOLS),.)
114+
$(BUILDDIR)/flisp.boot: $(SRCDIR)/flisp.boot | $(BUILDDIR)
92115
cp $< $@
93116
endif
94117

@@ -103,5 +126,6 @@ clean:
103126
rm -f $(BUILDDIR)/*.a
104127
rm -f $(BUILDDIR)/$(EXENAME)$(EXE)
105128
rm -f $(BUILDDIR)/$(EXENAME)-debug$(EXE)
129+
rm -f $(BUILDDIR)/host/*
106130

107131
.PHONY: flisp-deps

src/support/Makefile

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
JULIAHOME := $(abspath ../..)
1+
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
2+
JULIAHOME := $(abspath $(SRCDIR)/../..)
23
BUILDDIR := .
34
include $(JULIAHOME)/Make.inc
45

@@ -40,24 +41,32 @@ default: release
4041
$(BUILDDIR):
4142
mkdir -p $(BUILDDIR)
4243

43-
$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR)
44+
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
4445
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(SHIPFLAGS) $(DISABLE_ASSERTIONS) -c $< -o $@)
45-
$(BUILDDIR)/%.dbg.obj: %.c $(HEADERS) | $(BUILDDIR)
46+
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
4647
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS) -c $< -o $@)
4748
ifneq ($(USEMSVC), 1)
48-
$(BUILDDIR)/%.o: %.S | $(BUILDDIR)
49+
$(BUILDDIR)/%.o: $(SRCDIR)/%.S | $(BUILDDIR)
4950
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(SHIPFLAGS) -c $< -o $@)
50-
$(BUILDDIR)/%.dbg.obj: %.S | $(BUILDDIR)
51+
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.S | $(BUILDDIR)
5152
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(DEBUGFLAGS) -c $< -o $@)
5253
else
53-
$(BUILDDIR)/%.o: %.S | $(BUILDDIR)
54+
$(BUILDDIR)/%.o: $(SRCDIR)/%.S | $(BUILDDIR)
5455
@$(call PRINT_CC, $(CPP) -P $(JCPPFLAGS) $(SHIPFLAGS) $<)
5556
@$(call PRINT_CC, $(AS) $(JCPPFLAGS) $(SHIPFLAGS) -Fo $@ -c $*.i)
56-
$(BUILDDIR)/%.dbg.obj: %.S | $(BUILDDIR)
57+
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.S | $(BUILDDIR)
5758
@$(call PRINT_CC, $(CPP) -P $(JCPPFLAGS) $(DEBUGFLAGS) $<)
5859
@$(call PRINT_CC, $(AS) $(JCPPFLAGS) $(DEBUGFLAGS) -Fo $@ -c $*.i)
5960
endif
6061

62+
$(BUILDDIR)/host/Makefile:
63+
mkdir -p $(BUILDDIR)/host
64+
@# add Makefiles to the build directories for convenience (pointing back to the source location of each)
65+
@echo '# -- This file is automatically generated in julia/Makefile -- #' > $@
66+
@echo 'BUILDDIR=$(BUILDDIR)/host' >> $@
67+
@echo 'BUILDING_HOST_TOOLS=1' >> $@
68+
@echo 'include $(SRCDIR)/Makefile' >> $@
69+
6170
release: $(BUILDDIR)/libsupport.a
6271
debug: $(BUILDDIR)/libsupport-debug.a
6372

@@ -69,6 +78,12 @@ $(BUILDDIR)/libsupport-debug.a: $(DOBJS) | $(BUILDDIR)
6978
rm -rf $@
7079
@$(call PRINT_LINK, $(AR) -rcs $@ $^)
7180

81+
$(BUILDDIR)/host/libsupport.a: $(BUILDDIR)/host/Makefile
82+
$(MAKE) -C $(BUILDDIR)/host libsupport.a
83+
84+
$(BUILDDIR)/host/libsupport-debug.a: $(BUILDDIR)/host/Makefile
85+
$(MAKE) -C $(BUILDDIR)/host libsupport-debug.a
86+
7287
clean:
7388
rm -f $(BUILDDIR)/*.o
7489
rm -f $(BUILDDIR)/*.dbg.obj
@@ -77,3 +92,4 @@ clean:
7792
rm -f $(BUILDDIR)/core*
7893
rm -f $(BUILDDIR)/libsupport.a
7994
rm -f $(BUILDDIR)/libsupport-debug.a
95+
rm -f $(BUILDDIR)/host/*

0 commit comments

Comments
 (0)