Skip to content

Commit

Permalink
Add simple cross compile mechanism for flisp/libsupport (+ dependenci…
Browse files Browse the repository at this point in the history
…es) (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).
  • Loading branch information
Keno committed Jul 2, 2019
1 parent 62a9efd commit 1fc51b7
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 51 deletions.
32 changes: 22 additions & 10 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,19 @@ endif

# we include twice to pickup user definitions better
# include from JULIAHOME first so that BUILDROOT can override
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
MAYBE_HOST :=
ifneq ($(BUILDING_HOST_TOOLS),1)
MAKE_USER_FNAME = Make.user
else
MAYBE_HOST := /host
MAKE_USER_FNAME = Make.host.user
endif

ifeq (exists, $(shell [ -e $(JULIAHOME)/$(MAKE_USER_FNAME) ] && echo exists ))
include $(JULIAHOME)/$(MAKE_USER_FNAME)
endif
ifeq (exists, $(shell [ -e $(BUILDROOT)/Make.user ] && echo exists ))
include $(BUILDROOT)/Make.user
ifeq (exists, $(shell [ -e $(BUILDROOT)/$(MAKE_USER_FNAME) ] && echo exists ))
include $(BUILDROOT)/$(MAKE_USER_FNAME)
endif

# disable automatic Makefile rules
Expand Down Expand Up @@ -236,8 +244,12 @@ sysconfdir := $(prefix)/etc
endif

# Directories where things get built into
build_prefix := $(BUILDROOT)/usr
build_prefix := $(BUILDROOT)/usr$(MAYBE_HOST)
ifeq ($(BUILDING_HOST_TOOLS), 1)
build_staging := $(BUILDROOT)/usr-host-staging
else
build_staging := $(build_prefix)-staging
endif
build_bindir := $(build_prefix)/bin
build_depsbindir := $(build_prefix)/tools
build_libdir := $(build_prefix)/lib
Expand Down Expand Up @@ -571,11 +583,11 @@ else
LOCALBASE ?= /usr
endif

ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
ifeq (exists, $(shell [ -e $(JULIAHOME)/$(MAKE_USER_FNAME) ] && echo exists ))
include $(JULIAHOME)/$(MAKE_USER_FNAME)
endif
ifeq (exists, $(shell [ -e $(BUILDROOT)/Make.user ] && echo exists ))
include $(BUILDROOT)/Make.user
ifeq (exists, $(shell [ -e $(BUILDROOT)/$(MAKE_USER_FNAME) ] && echo exists ))
include $(BUILDROOT)/$(MAKE_USER_FNAME)
endif

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

ifeq ($(OS), Linux)
OSLIBS += -Wl,--no-as-needed -ldl -lrt -lpthread -Wl,--export-dynamic,--as-needed,--no-whole-archive $(LIBUNWIND)
OSLIBS += -Wl,--no-as-needed -ldl -lrt -lpthread -Wl,--export-dynamic,--as-needed,--no-whole-archive
# Detect if ifunc is supported
IFUNC_DETECT_SRC := 'void (*f0(void))(void) { return (void(*)(void))0L; }; void f(void) __attribute__((ifunc("f0")));'
ifeq (supported, $(shell echo $(IFUNC_DETECT_SRC) | $(CC) -Werror -x c - -S -o /dev/null > /dev/null 2>&1 && echo supported))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ all: debug release
# sort is used to remove potential duplicates
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))
ifneq ($(BUILDROOT),$(JULIAHOME))
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/clangsa ui doc deps stdlib test test/embedding test/llvmpasses)
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa ui doc deps stdlib test test/embedding test/llvmpasses)
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS)) $(BUILDROOT)/sysimage.mk
DIRS := $(DIRS) $(BUILDDIRS)
$(BUILDDIRMAKE): | $(BUILDDIRS)
Expand Down
2 changes: 2 additions & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ include $(SRCDIR)/tools/common.mk
include $(SRCDIR)/tools/git-external.mk
include $(SRCDIR)/tools/bb-install.mk

BUILDDIR := $(BUILDDIR)$(MAYBE_HOST)

# Special comments:
#
# all targets in here should follow the same structure,
Expand Down
17 changes: 9 additions & 8 deletions deps/libuv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ ifneq ($(VERBOSE), 0)
UV_MFLAGS += V=1
endif

LIBUV_BUILDDIR := $(BUILDDIR)/$(LIBUV_SRC_DIR)

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

$(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured
$(LIBUV_BUILDDIR)/build-compiled: $(LIBUV_BUILDDIR)/build-configured
$(MAKE) -C $(dir $<) $(UV_MFLAGS)
echo 1 > $@

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

clean-libuv:
-rm -rf $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled
-$(MAKE) -C $(BUILDDIR)/$(LIBUV_SRC_DIR) clean
-rm -rf $(LIBUV_BUILDDIR)/build-configured $(LIBUV_BUILDDIR)/build-compiled
-$(MAKE) -C $(LIBUV_BUILDDIR) clean


get-libuv: $(LIBUV_SRC_FILE)
extract-libuv: $(SRCCACHE)/$(LIBUV_SRC_DIR)/source-extracted
configure-libuv: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-configured
compile-libuv: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-compiled
configure-libuv: $(LIBUV_BUILDDIR)/build-configured
compile-libuv: $(LIBUV_BUILDDIR)/build-compiled
fastcheck-libuv: #none
check-libuv: $(BUILDDIR)/$(LIBUV_SRC_DIR)/build-checked
check-libuv: $(LIBUV_BUILDDIR)/build-checked

else # USE_BINARYBUILDER_LIBUV
LIBUV_BB_URL_BASE := https://github.com/JuliaPackaging/Yggdrasil/releases/download/LibUV-v2+$(LIBUV_VER)-julia+$(LIBUV_BB_REL)
Expand Down
11 changes: 6 additions & 5 deletions deps/utf8proc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ UTF8PROC_OBJ_LIB := $(build_libdir)/libutf8proc.a
UTF8PROC_OBJ_HEADER := $(build_includedir)/utf8proc.h
UTF8PROC_CFLAGS := -O2
UTF8PROC_MFLAGS := CC="$(CC)" CFLAGS="$(CFLAGS) $(UTF8PROC_CFLAGS)" PICFLAG="$(fPIC)" AR="$(AR)"
UTF8PROC_BUILDDIR := $(BUILDDIR)/$(UTF8PROC_SRC_DIR)

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

$(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-checked: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-compiled
$(UTF8PROC_BUILDDIR)/build-checked: $(UTF8PROC_BUILDDIR)/build-compiled
ifeq ($(OS),$(BUILD_OS))
$(MAKE) -C $(dir $@) $(UTF8PROC_MFLAGS) check
endif
Expand All @@ -32,9 +33,9 @@ clean-utf8proc:
-$(MAKE) -C $(BUILDDIR)/$(UTF8PROC_SRC_DIR) clean

get-utf8proc: $(UTF8PROC_SRC_FILE)
extract-utf8proc: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/source-extracted
extract-utf8proc: $(UTF8PROC_BUILDDIR)/source-extracted
configure-utf8proc: extract-utf8proc
compile-utf8proc: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-compiled
compile-utf8proc: $(UTF8PROC_BUILDDIR)/build-compiled
# utf8proc tests disabled since they require a download
fastcheck-utf8proc: #check-utf8proc
check-utf8proc: $(BUILDDIR)/$(UTF8PROC_SRC_DIR)/build-checked
check-utf8proc: $(UTF8PROC_BUILDDIR)/build-checked
2 changes: 2 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
/libjulia-release.so
/libjulia-release.dylib
/julia_version.h
/flisp/host
/support/host
17 changes: 13 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ FLAGS += -DLLVM_SHLIB
endif # USE_LLVM_SHLIB == 1
endif

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

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

FLISP_EXECUTABLE_debug := $(BUILDDIR)/flisp/flisp-debug$(EXE)
FLISP_EXECUTABLE_release := $(BUILDDIR)/flisp/flisp$(EXE)
ifeq ($(USE_CROSS_FLISP), 1)
FLISPDIR := $(BUILDDIR)/flisp/host
else
FLISPDIR := $(BUILDDIR)/flisp
endif
FLISP_EXECUTABLE_debug := $(FLISPDIR)/flisp-debug$(EXE)
FLISP_EXECUTABLE_release := $(FLISPDIR)/flisp$(EXE)
ifeq ($(OS),WINNT)
FLISP_EXECUTABLE := $(FLISP_EXECUTABLE_release)
else
Expand Down Expand Up @@ -232,10 +237,14 @@ $(BUILDDIR)/support/libsupport-debug.a: $(addprefix $(SRCDIR)/support/,*.h *.c *
$(MAKE) -C $(SRCDIR)/support debug BUILDDIR='$(abspath $(BUILDDIR)/support)'

$(FLISP_EXECUTABLE_release): $(BUILDDIR)/flisp/libflisp.a
$(MAKE) -C $(BUILDDIR)/flisp $(subst $(abspath $(BUILDDIR)/flisp)/,,$(abspath $(FLISP_EXECUTABLE_release)))

$(FLISP_EXECUTABLE_debug): $(BUILDDIR)/flisp/libflisp-debug.a
$(MAKE) -C $(BUILDDIR)/flisp $(subst $(abspath $(BUILDDIR)/flisp)/,,$(abspath $(FLISP_EXECUTABLE_debug)))

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

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

Expand Down
56 changes: 40 additions & 16 deletions src/flisp/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
JULIAHOME := $(abspath ../..)
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
JULIAHOME := $(abspath $(SRCDIR)/../..)
BUILDDIR := .
include $(JULIAHOME)/Make.inc

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

LLTDIR := ../support
LLTSRCDIR := $(SRCDIR)/$(LLTDIR)
NATIVE_BUILDDIR :=
ifeq ($(BUILDING_HOST_TOOLS), 1)
NATIVE_BUILDDIR := $(BUILDDIR)/..
LLT_BUILDDIR := $(BUILDDIR)/../$(LLTDIR)/host
else
NATIVE_BUILDDIR := $(BUILDDIR)
LLT_BUILDDIR := $(BUILDDIR)/$(LLTDIR)
endif

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

OBJS := $(SRCS:%.c=$(BUILDDIR)/%.o)
DOBJS := $(SRCS:%.c=$(BUILDDIR)/%.dbg.obj)
LLT_release := $(BUILDDIR)/$(LLTDIR)/libsupport.a
LLT_debug := $(BUILDDIR)/$(LLTDIR)/libsupport-debug.a
LLT_release := $(LLT_BUILDDIR)/libsupport.a
LLT_debug := $(LLT_BUILDDIR)/libsupport-debug.a
LIBFILES_release := $(LLT_release) $(LIBUV) $(LIBUTF8PROC)
LIBFILES_debug := $(LLT_debug) $(LIBUV) $(LIBUTF8PROC)
LIBS :=
ifneq ($(OS),WINNT)
LIBS += -lpthread
endif

FLAGS := -I$(LLTDIR) $(JCFLAGS) $(HFILEDIRS:%=-I%) \
FLAGS := -I$(LLTSRCDIR) $(JCFLAGS) $(HFILEDIRS:%=-I%) \
-I$(LIBUV_INC) -I$(UTF8PROC_INC) -I$(build_includedir) $(LIBDIRS:%=-L%) \
-DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS
ifneq ($(USEMSVC), 1)
Expand All @@ -52,20 +62,22 @@ debug: $(BUILDDIR)/$(EXENAME)-debug$(EXE)
$(BUILDDIR):
mkdir -p $(BUILDDIR)

$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR)
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(SHIPFLAGS) $(DISABLE_ASSERTIONS) -c $< -o $@)
$(BUILDDIR)/%.dbg.obj: %.c $(HEADERS) | $(BUILDDIR)
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(DEBUGFLAGS) -c $< -o $@)

$(BUILDDIR)/flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c
$(BUILDDIR)/flisp.dbg.obj: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c
$(BUILDDIR)/flmain.o: flmain.c flisp.h
$(BUILDDIR)/flmain.dbg.obj: flmain.c flisp.h
FLISP_SRCS := $(flisp.c cvalues.c types.c flisp.h print.c read.c equal.c:%=$(SRCDIR)/%)
FLMAIN_SRCS := $(flmain.c flisp.h:%=$(SRCDIR)/%)
$(BUILDDIR)/flisp.o: $(FLISP_SRCS)
$(BUILDDIR)/flisp.dbg.obj: $(FLISP_SRCS)
$(BUILDDIR)/flmain.o: $(FLMAIN_SRCS)
$(BUILDDIR)/flmain.dbg.obj: $(FLMAIN_SRCS)

$(LLT_release): $(LLTDIR)/*.h $(LLTDIR)/*.c
$(MAKE) -C $(LLTDIR) BUILDDIR='$(abspath $(BUILDDIR)/$(LLTDIR))'
$(LLT_debug): $(LLTDIR)/*.h $(LLTDIR)/*.c
$(MAKE) debug -C $(LLTDIR) BUILDDIR='$(abspath $(BUILDDIR)/$(LLTDIR))'
$(LLT_release): $(LLTSRCDIR)/*.h $(LLTSRCDIR)/*.c
$(MAKE) -C $(NATIVE_BUILDDIR)/$(LLTDIR) $(subst $(abspath $(NATIVE_BUILDDIR)/$(LLTDIR))/,,$(abspath $(LLT_release)))
$(LLT_debug): $(LLTSRCDIR)/*.h $(LLTSRCDIR)/*.c
$(MAKE) -C $(NATIVE_BUILDDIR)/$(LLTDIR) $(subst $(abspath $(NATIVE_BUILDDIR)/$(LLTDIR))/,,$(abspath $(LLT_debug)))

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

ifneq ($(BUILDDIR),.)
$(BUILDDIR)/flisp.boot: flisp.boot | $(BUILDDIR)
$(BUILDDIR)/host/Makefile:
mkdir -p $(BUILDDIR)/host
@# add Makefiles to the build directories for convenience (pointing back to the source location of each)
@echo '# -- This file is automatically generated in julia/src/flisp/Makefile -- #' > $@
@echo 'BUILDDIR=$(BUILDDIR)/host' >> $@
@echo 'BUILDING_HOST_TOOLS=1' >> $@
@echo 'include $(SRCDIR)/Makefile' >> $@

$(BUILDDIR)/host/$(EXENAME): $(BUILDDIR)/host/Makefile
make -C $(BUILDDIR)/host $(EXENAME)

ifneq ($(BUILDDIR)$(BUILDING_HOST_TOOLS),.)
$(BUILDDIR)/flisp.boot: $(SRCDIR)/flisp.boot | $(BUILDDIR)
cp $< $@
endif

Expand All @@ -103,5 +126,6 @@ clean:
rm -f $(BUILDDIR)/*.a
rm -f $(BUILDDIR)/$(EXENAME)$(EXE)
rm -f $(BUILDDIR)/$(EXENAME)-debug$(EXE)
rm -f $(BUILDDIR)/host/*

.PHONY: flisp-deps
30 changes: 23 additions & 7 deletions src/support/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
JULIAHOME := $(abspath ../..)
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
JULIAHOME := $(abspath $(SRCDIR)/../..)
BUILDDIR := .
include $(JULIAHOME)/Make.inc

Expand Down Expand Up @@ -40,24 +41,32 @@ default: release
$(BUILDDIR):
mkdir -p $(BUILDDIR)

$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR)
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(SHIPFLAGS) $(DISABLE_ASSERTIONS) -c $< -o $@)
$(BUILDDIR)/%.dbg.obj: %.c $(HEADERS) | $(BUILDDIR)
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS) -c $< -o $@)
ifneq ($(USEMSVC), 1)
$(BUILDDIR)/%.o: %.S | $(BUILDDIR)
$(BUILDDIR)/%.o: $(SRCDIR)/%.S | $(BUILDDIR)
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(SHIPFLAGS) -c $< -o $@)
$(BUILDDIR)/%.dbg.obj: %.S | $(BUILDDIR)
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.S | $(BUILDDIR)
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(DEBUGFLAGS) -c $< -o $@)
else
$(BUILDDIR)/%.o: %.S | $(BUILDDIR)
$(BUILDDIR)/%.o: $(SRCDIR)/%.S | $(BUILDDIR)
@$(call PRINT_CC, $(CPP) -P $(JCPPFLAGS) $(SHIPFLAGS) $<)
@$(call PRINT_CC, $(AS) $(JCPPFLAGS) $(SHIPFLAGS) -Fo $@ -c $*.i)
$(BUILDDIR)/%.dbg.obj: %.S | $(BUILDDIR)
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.S | $(BUILDDIR)
@$(call PRINT_CC, $(CPP) -P $(JCPPFLAGS) $(DEBUGFLAGS) $<)
@$(call PRINT_CC, $(AS) $(JCPPFLAGS) $(DEBUGFLAGS) -Fo $@ -c $*.i)
endif

$(BUILDDIR)/host/Makefile:
mkdir -p $(BUILDDIR)/host
@# add Makefiles to the build directories for convenience (pointing back to the source location of each)
@echo '# -- This file is automatically generated in julia/Makefile -- #' > $@
@echo 'BUILDDIR=$(BUILDDIR)/host' >> $@
@echo 'BUILDING_HOST_TOOLS=1' >> $@
@echo 'include $(SRCDIR)/Makefile' >> $@

release: $(BUILDDIR)/libsupport.a
debug: $(BUILDDIR)/libsupport-debug.a

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

$(BUILDDIR)/host/libsupport.a: $(BUILDDIR)/host/Makefile
$(MAKE) -C $(BUILDDIR)/host libsupport.a

$(BUILDDIR)/host/libsupport-debug.a: $(BUILDDIR)/host/Makefile
$(MAKE) -C $(BUILDDIR)/host libsupport-debug.a

clean:
rm -f $(BUILDDIR)/*.o
rm -f $(BUILDDIR)/*.dbg.obj
Expand All @@ -77,3 +92,4 @@ clean:
rm -f $(BUILDDIR)/core*
rm -f $(BUILDDIR)/libsupport.a
rm -f $(BUILDDIR)/libsupport-debug.a
rm -f $(BUILDDIR)/host/*

0 comments on commit 1fc51b7

Please sign in to comment.