From 4cf0634b80d5bc82c21833283d2477c750bfd572 Mon Sep 17 00:00:00 2001 From: dzaima Date: Tue, 21 Nov 2023 00:18:10 +0200 Subject: [PATCH] rearrange makefiles, remove replxx support from build/makefile --- build/makefile | 71 +++++++++---------------------------- makefile | 95 ++++++++++++++++++++++++++------------------------ 2 files changed, 66 insertions(+), 100 deletions(-) diff --git a/build/makefile b/build/makefile index 20c04a40..3f5e4e70 100644 --- a/build/makefile +++ b/build/makefile @@ -1,10 +1,24 @@ SHELL = /usr/bin/env bash MAKEFLAGS+= --no-print-directory --no-builtin-rules --no-builtin-variables MAKEHERE = "$(MAKE) -f build/makefile" +# note: do not manually define any i_… arguments, or incremental compiling may not work properly! + + + +# simple non-incremental builds +single-o3: + $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -O3 -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) +single-o3g: + $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -O3 -g -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) +single-debug: + $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -DDEBUG -g -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) +single-c: + $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) + + # dependency files -include $(bd)/*.d - # compiler setup i_CC := cc i_PIE := @@ -55,10 +69,6 @@ ifeq ($(origin LD_LIBS),command line) i_LIBS_LD := $(LD_LIBS) custom = 1 endif -ifeq ($(i_REPLXX_1),1) - i_PIE += -fPIE - i_CC_PIE := -fPIE -endif ifeq ($(origin PIE),command line) override i_PIE := $(PIE) custom = 1 @@ -79,11 +89,6 @@ endif ifeq ($(origin LDFLAGS),command line) custom = 1 endif -ifeq ($(i_REPLXX_1),1) - i_f+= -DREPLXX_STATIC=1 - custom = 1 - REPLXX_DIR = $(shell if [ -d build/replxxLocal ]; then echo build/replxxLocal; else echo build/replxxSubmodule; fi) -endif BYTECODE_DIR = $(shell if [ -d build/bytecodeLocal ]; then echo bytecodeLocal; else echo bytecodeSubmodule; fi) ifeq ($(BYTECODE_DIR),bytecodeLocal) custom = 1 @@ -106,9 +111,7 @@ endif ifeq ($(WINDOWS), 1) i_f+= -DNO_MMAP i_lf+= -lpthread - ifeq ($(i_REPLXX_1), 1) - i_f+= -DUSE_REPLXX_IO - endif + endif ALL_CC_FLAGS = -std=gnu11 -Wall -Wno-unused-function -fms-extensions -ffp-contract=off -fno-math-errno -fno-strict-aliasing $(CCFLAGS) $(f) $(i_f) $(NOWARN) -DBYTECODE_DIR=$(BYTECODE_DIR) -DFFI=$(i_FFI) $(i_LIBS_CC) $(i_CC_PIE) @@ -129,23 +132,12 @@ ifeq ($(custom),) else @[ -x "$$(command -v sha256sum)" ] && hashInput="sha256sum"; \ [ -x "$$(command -v shasum)" ] && hashInput="shasum -a 256"; \ - printf "%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s" "${i_CC}" "${ALL_CC_FLAGS}" "${ALL_LD_FLAGS}" "${i_REPLXX_1}" "${REPLXX_FLAGS}" "${CXXFLAGS}" "${i_CXX}" "${BYTECODE_DIR}" "${REPLXX_DIR}" | $$hashInput | grep -oE '[0-9a-z]{64}' | head -c32 + printf "%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s" "${i_CC}" "${ALL_CC_FLAGS}" "${ALL_LD_FLAGS}" "${CXXFLAGS}" "${i_CXX}" "${BYTECODE_DIR}" | $$hashInput | grep -oE '[0-9a-z]{64}' | head -c32 endif else @printf "%s" "$(force_build_dir)" endif - -# simple non-incremental builds -single-o3: - $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -O3 -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) -single-o3g: - $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -O3 -g -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) -single-debug: - $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -DDEBUG -g -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) -single-c: - $(i_CC) $(ALL_CC_FLAGS) -DSINGLE_BUILD -o ${i_OUTPUT} src/opt/single.c $(ALL_LD_FLAGS) - # actual build run_incremental_0: ifeq ($(i_t),forbuild) @@ -154,11 +146,6 @@ endif ifeq ($(verbose),1) @echo "build directory: $$("$(MAKEHERE)" builddir)" @echo " bytecode: build/$(BYTECODE_DIR)" -ifeq ($(i_REPLXX_1),1) - @echo " replxx: $(REPLXX_DIR)" -else - @echo " replxx: not used" -endif @echo " cc invocation: $(CC_INC) \$$@.d -o \$$@ -c \$$<" @echo " ld invocation: $(i_LD) ${CCFLAGS} -o [build_dir]/BQN [build_dir]/*.o $(ALL_LD_FLAGS)" endif @@ -172,9 +159,6 @@ else ifeq ($(origin builddir),command line) @echo "$$("$(MAKEHERE)" builddir)" else # run build -ifeq ($(REPLXX_DIR),build/replxxSubmodule) - @git submodule update --init build/replxxSubmodule || (echo 'Failed to initialize submodule; clone CBQN as a git repo, or place local copies in build/ (see README.md#submodules).' && false) -endif ifeq ($(i_USE_BC_SUBMODULE),1) @git submodule update --init build/bytecodeSubmodule || (echo 'Failed to initialize submodule; clone CBQN as a git repo, or place local copies in build/ (see README.md#submodules).' && false) endif @@ -231,24 +215,3 @@ bytecodeMessage: ifeq ($(i_USE_BC_SUBMODULE),1) @echo "Using precompiled bytecode; see readme for how to build your own" endif - - - -# replxx -ifeq ($(i_REPLXX_1),1) -i_CXX := c++ -ifeq ($(origin CXX),command line) - i_CXX := $(CXX) -endif -i_LD = $(i_CXX) -REPLXX_FLAGS = -std=c++11 -Os - -ALL_CC_FLAGS += -DUSE_REPLXX -I$(REPLXX_DIR)/include $(i_CC_PIE) - -CXX_INC = $(i_CXX) $(CCFLAGS) $(REPLXX_FLAGS) $(CXXFLAGS) -DREPLXX_STATIC=1 -I$(REPLXX_DIR)/include -MMD -MP -MF -replxx_obj: ${addprefix ${bd}/, ConvertUTF.cpp.o wcwidth.cpp.o conversion.cxx.o escape.cxx.o history.cxx.o prompt.cxx.o replxx.cxx.o replxx_impl.cxx.o terminal.cxx.o util.cxx.o windows.cxx.o} -${bd}/%.o: $(REPLXX_DIR)/src/% - @echo $< - @$(CXX_INC) $@.d -o $@ -c $< -${bd}/BQN: replxx_obj -endif # replxx diff --git a/makefile b/makefile index 79a6178e..4da28c5a 100644 --- a/makefile +++ b/makefile @@ -1,53 +1,8 @@ SHELL = /usr/bin/env bash MAKEFLAGS+= --no-print-directory --no-builtin-rules --no-builtin-variables -# note: do not manually define any i_… arguments, or incremental compiling will not work properly! default: o3 -# targets that use build/makefile -for-build: # for running the build system & Singeli - @"${MAKE}" -f build/makefile run_incremental_0 i_t=forbuild i_CC=cc REPLXX=0 i_f="-O2 -DFOR_BUILD" i_FFI=0 i_SHARED=0 i_PIE= i_CC_PIE= i_EXPORT=0 i_OUTPUT_DEF=build/obj2/for_build4 -for-bootstrap: # for bootstrapping bytecode - @"${MAKE}" -f build/makefile run_incremental_0 i_t=for_bootstrap REPLXX=0 i_FFI=0 i_SHARED=0 i_PIE= i_CC_PIE= i_EXPORT=0 i_f='-DNATIVE_COMPILER -DONLY_NATIVE_COMP -DFORMATTER=0 -DNO_RT -DNO_EXPLAIN' i_USE_BC_SUBMODULE=0 BYTECODE_DIR=bytecodeNone -o3-makeonly: - @"${MAKE}" -f build/makefile run_incremental_0 i_t=o3 i_f="-O3" -c-makeonly: - @"${MAKE}" -f build/makefile run_incremental_0 custom=1 -# simple non-incremental builds -single-o3: - @"${MAKE}" -f build/makefile single-o3 -single-o3g: - @"${MAKE}" -f build/makefile single-o3g -single-debug: - @"${MAKE}" -f build/makefile single-debug -single-c: - @"${MAKE}" -f build/makefile single-c - - -i_REPLXX_1 = 1 -ifeq ($(origin REPLXX),command line) - i_REPLXX_1 = "$(REPLXX)" -endif -i_singeli_1 = 1 -ifeq ($(origin singeli),command line) - i_singeli_1 = "$(singeli)" -endif - -to-bqn-build: -ifeq ($(origin builddir),command line) - @echo "Error: 'builddir' unsupported"; false -endif -ifeq ($(origin clean),command line) - @echo "Error: build-specific 'clean' unsupported"; false -endif - @build/build from-makefile CC="$(CC)" CXX="$(CXX)" PIE="$(ENABLE_PIE)" OUTPUT="$(OUTPUT)" j="$(j)" \ - verbose="$(verbose)" notui="$(notui)" v="$(version)" \ - f="$(f)" lf="$(lf)" CCFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" REPLXX_FLAGS="$(REPLXX_FLAGS)" CXXFLAGS="$(CXXFLAGS)" \ - LD_LIBS="$(LD_LIBS)" NO_LDL="$(NO_LDL)" no_fPIC="$(no_fPIC)" \ - c="$(build_c)" debug="$(debug)" $(i_build_opts) $(build_opts) \ - os="$(target_os)" arch="$(target_arch)" has="$(has)" \ - shared="$(i_SHARED)" singeli="$(i_singeli_1)" replxx="$(i_REPLXX_1)" FFI="$(FFI)" - # targets that go to build.bqn o3: @"${MAKE}" to-bqn-build @@ -89,6 +44,53 @@ static-lib: static-bin: @"${MAKE}" to-bqn-build FFI=0 i_build_opts="static-bin" + + +# targets that use build/makefile +for-build: # for running the build system & Singeli + @"${MAKE}" -f build/makefile run_incremental_0 i_t=forbuild i_CC=cc REPLXX=0 i_f="-O2 -DFOR_BUILD" i_FFI=0 i_SHARED=0 i_PIE= i_CC_PIE= i_EXPORT=0 i_OUTPUT_DEF=build/obj2/for_build4 +for-bootstrap: # for bootstrapping bytecode + @"${MAKE}" -f build/makefile run_incremental_0 i_t=for_bootstrap REPLXX=0 i_FFI=0 i_SHARED=0 i_PIE= i_CC_PIE= i_EXPORT=0 i_f='-DNATIVE_COMPILER -DONLY_NATIVE_COMP -DFORMATTER=0 -DNO_RT -DNO_EXPLAIN' i_USE_BC_SUBMODULE=0 BYTECODE_DIR=bytecodeNone +o3-makeonly: + @"${MAKE}" -f build/makefile run_incremental_0 i_t=o3 i_f="-O3" +c-makeonly: + @"${MAKE}" -f build/makefile run_incremental_0 custom=1 +# simple non-incremental builds +single-o3: + @"${MAKE}" -f build/makefile single-o3 +single-o3g: + @"${MAKE}" -f build/makefile single-o3g +single-debug: + @"${MAKE}" -f build/makefile single-debug +single-c: + @"${MAKE}" -f build/makefile single-c + + + +i_REPLXX_1 = 1 +ifeq ($(origin REPLXX),command line) + i_REPLXX_1 = "$(REPLXX)" +endif +i_singeli_1 = 1 +ifeq ($(origin singeli),command line) + i_singeli_1 = "$(singeli)" +endif + +to-bqn-build: +ifeq ($(origin builddir),command line) + @echo "Error: 'builddir' unsupported"; false +endif +ifeq ($(origin clean),command line) + @echo "Error: build-specific 'clean' unsupported"; false +endif + @build/build from-makefile CC="$(CC)" CXX="$(CXX)" PIE="$(ENABLE_PIE)" OUTPUT="$(OUTPUT)" j="$(j)" \ + verbose="$(verbose)" notui="$(notui)" v="$(version)" \ + f="$(f)" lf="$(lf)" CCFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" REPLXX_FLAGS="$(REPLXX_FLAGS)" CXXFLAGS="$(CXXFLAGS)" \ + LD_LIBS="$(LD_LIBS)" NO_LDL="$(NO_LDL)" no_fPIC="$(no_fPIC)" \ + c="$(build_c)" debug="$(debug)" $(i_build_opts) $(build_opts) \ + os="$(target_os)" arch="$(target_arch)" has="$(has)" \ + shared="$(i_SHARED)" singeli="$(i_singeli_1)" replxx="$(i_REPLXX_1)" FFI="$(FFI)" + # mappings of old names o3-singeli: o3 o3g-singeli: o3g @@ -115,7 +117,8 @@ install: else \ echo "Not installing libcbqn.so as it wasn't built"; \ fi - + + uninstall: rm -f "$(DESTDIR)$(PREFIX)/bin/bqn"