Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -11,28 +11,30 @@ *.so *~ *.vg *.massif *._out -Makefile +GNUmakefile +make-*.make autosetup/jimsh0 config.log config.make -bindings/cpp/Makefile bindings/cpp/test doc/Doxyfile -f-apps/Makefile f-apps/zipped.zip f-apps/f-acat f-apps/f-add f-apps/f-adiff f-apps/f-annotate f-apps/f-checkin +f-apps/f-ciwoco f-apps/f-config f-apps/f-delta f-apps/f-event +f-apps/f-extract f-apps/f-ls +f-apps/f-merge f-apps/f-mfparse f-apps/f-new f-apps/f-parseparty f-apps/f-query f-apps/f-resolve @@ -51,11 +53,10 @@ f-apps/f-test-line-diff f-apps/f-test-merge3 f-apps/f-test-merge f-apps/f-test-reserved-name-check include/fossil-scm/autoconfig.h -src/Makefile tools/text2c bindings/s2/f-s2sh */tmp/* doc/libfossil-API-html/* compile_commands* ADDED GNUmakefile.in Index: GNUmakefile.in ================================================================== --- /dev/null +++ GNUmakefile.in @@ -0,0 +1,133 @@ +#!/usr/bin/make # help out emacs +# +# Top-level autosetup-filtered Makefile for libfossil. This particular +# build is for Unix platforms with GNU Make 4+. +all: +ROOT.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +DISTCLEAN.root += $(ROOT.MAKEFILE) +TOP_DIR := $(patsubst %/,%,$(dir $(ROOT.MAKEFILE))) + +#ShakeNMake.CISH_SOURCES := $(wildcard *.c) $(wildcard $(SRC.DIR)/*.c) + +######################################################################## +# Some common vars used by shakenmake.make and/or the sub-makes +# (make-*.make). +DIR.top := @srcdir@ +DIR.src := @srcdir@/src +DIR.client := @srcdir@/client +DIR.tools := @srcdir@/tools +DIR.include := @srcdir@/include +DIR.bindings := @srcdir@/bindings +DIR.f-apps := @srcdir@/f-apps +ShakeNMake.CISH_SOURCES := $(wildcard \ + $(DIR.src)/*.[ch] \ + $(DIR.f-apps)/*.[ch] \ + $(DIR.client)/fnc/*.[ch] \ + $(DIR.bindings)/cpp/*.[ch]pp \ + $(DIR.tools)/*.[ch] \ + $(DIR.include)/fossil-scm/*.{h,hpp} \ +) +include config.make +include shakenmake.make + +######################################################################## +# Subdir/module builds... +# +# Maintenance reminders: all relevant symbols in the sub-makefiles +# (make-XXX.make) MUST be unique across the whole global +# namespace. Similarly, all relevant paths must point to that +# subdir. That is particularly of interest with the BIN/DLL/LIB and +# CLEAN.xxx rules, which may require another level of $(var) +# indirection for that purpose. It's also important when using +# CPPFLAGS and such, to keep subdir-specific flags from leaking across +# makefiles. Similarly, when using ShakeNMake.install.XXX, the vars +# must appended to instead of overwritten. +######################################################################## +# INCLUDE_SINGLE_SUBMAKE includes file make-$(1).make if it exists, +# else this is a no-op. It protects against multiple inclusion. +INCLUDED_SUBMAKES := +define INCLUDE_SINGLE_SUBMAKE + SINGLE.$(1) := $$(wildcard make-$(1).make) + ifneq (,$$(SINGLE.$(1))) + ifneq ($(1),$$(strip $$(filter $(1),$$(INCLUDED_SUBMAKES)))) + $(1):# kludge + ifneq (,$$(strip $$(filter distclean-$(1) clean-$(1),$(MAKECMDGOALS)))) + MAKING_CLEAN.$(1):=1 + endif + INCLUDED_SUBMAKES+=$(1) + $$(info Importing sub-make: $(1)) + include $$(SINGLE.$(1)) + endif + endif +endef +# If passed an explicit make target matching make-XXX.make then +# include that makefile. Note that we must always include +# make-libf.make because all sub-makes depend on those bits. +$(eval $(call INCLUDE_SINGLE_SUBMAKE,libf)) +ifneq (,$(MAKECMDGOALS)) + $(foreach f,$(MAKECMDGOALS),$(eval $(call INCLUDE_SINGLE_SUBMAKE,$(f)))) +endif +INCLUDED_SUBMAKES:=$(strip $(INCLUDED_SUBMAKES)) +#$(info INCLUDED_SUBMAKES=$(INCLUDED_SUBMAKES)) +ifneq (libf-only,$(strip $(filter libf-only,$(INCLUDED_SUBMAKES)))) +ifeq (libf,$(INCLUDED_SUBMAKES)) + # ^^^^ no submakes were explicitly called for, so include them all... + themakes := f-apps + ifeq (1,$(BUILD_CLIENT_FNC)) + themakes += client-fnc + endif + ifneq (,$(CXX)) + themakes += binding-cpp + endif + $(foreach f,$(themakes),$(eval $(call INCLUDE_SINGLE_SUBMAKE,$(f)))) + undefine themakes + #$(info MAKEFILE_LIST=$(MAKEFILE_LIST)) +endif +endif +undefine INCLUDED_SUBMAKES +undefine INCLUDE_SINGLE_SUBMAKE +# /subdir builds +######################################################################## + +$(call ShakeNMake.CALL.CLEAN-SET,root) +DISTCLEAN.root += config.make +# All GENERATED make-*.make files... +DISTCLEAN.root += make-libf.make \ + make-f-apps.make \ + make-client-fnc.make \ + make-binding-cpp + + +ifeq ($(MAKE_COMPILATION_DB),yes) +all: compile_commands.json +compile_commands.json: + @$(RM) $@ + sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compdb_dir)/*.o.json > $@+ + @if test -s $@+; then mv $@+ $@; else $(RM) $@+; fi +endif + +AUTOCONFIG_H := $(DIR.include)/fossil-scm/autoconfig.h +DISTCLEAN.root += $(AUTOCONFIG_H) $(ROOT.MAKEFILE) config.log \ + autosetup/jimsh0 \ + $(wildcard compile_commands/*) compile_commands.json+ + +# automake compatibility. do nothing for all these targets +#EMPTY_AUTOMAKE_TARGETS := dvi pdf ps info html tags ctags mostlyclean maintainer-clean check installcheck installdirs \ +# install-pdf install-ps install-info install-html -install-dvi uninstall install-exec install-data distdir +#.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +#$(EMPTY_AUTOMAKE_TARGETS): + +## @top_srcdir@/Makefile.in: # b/c AUTODEPS contains this name (it probably shouldn't) +#$(FSL.OBJ): @AUTODEPS@ @top_srcdir@/Makefile @top_srcdir@/config.make + +# Reconfigure if needed +#ifeq ($(findstring clean,$(MAKECMDGOALS)),) +#@top_srcdir@/config.make: @AUTODEPS@ @top_srcdir@/config.make.in +# @@AUTOREMAKE@ +#endif + +# Or on demand +reconfig: + @AUTOREMAKE@ + +CLEAN.root += $(wildcard $(DIR.top)/*~) Index: auto.def ================================================================== --- auto.def +++ auto.def @@ -385,18 +385,17 @@ wh-bin-define install wh-bin-define etags # Each generated Makefile requires an input file with a .in extension: wh-make-from-dot-in { - config.make - Makefile - src/Makefile - f-apps/Makefile - bindings/Makefile - bindings/cpp/Makefile - client/Makefile - client/fnc/Makefile + config.make + Makefile + GNUmakefile + make-libf.make + make-f-apps.make + make-client-fnc.make + make-binding-cpp.make } wh-make-from-dot-in { doc/Doxyfile } 1 ADDED bindings/cpp/GNUmakefile Index: bindings/cpp/GNUmakefile ================================================================== --- /dev/null +++ bindings/cpp/GNUmakefile @@ -0,0 +1,5 @@ +all: +clean: + $(MAKE) -C ../.. binding-cpp clean-binding-cpp +%: + $(MAKE) -C ../.. binding-cpp $@ DELETED bindings/cpp/Makefile.in Index: bindings/cpp/Makefile.in ================================================================== --- bindings/cpp/Makefile.in +++ /dev/null @@ -1,124 +0,0 @@ -all: -include ../../subdir-inc.make -#$(error $(TOP_SRCDIR)) -#CPPFLAGS += -I$(TOP_INCDIR) -#CPPFLAGS += -I$(TOP_SRCDIR)/include -CPPFLAGS += -I$(TOP_SRCDIR)/src# workaround for in-tree sqlite3.h -CXXFLAGS += -fPIC -Wall -Werror -DISTCLEAN_FILES += Makefile -#INCLUDES_PATH ?= $(HOME)/include /usr/local/include /usr/include - -LIBFOSSIL.LDFLAGS := -L$(TOP_SRCDIR) -lfossil -lz - -#ifeq (,$(strip $(filter distclean clean,$(MAKECMDGOALS)))) -#$(LIBFOSSIL.LDFLAGS): -# $(MAKE) -C .. -#endif - -CPP.SRC := \ - Context.cpp \ - Db.cpp \ - Deck.cpp \ - Exception.cpp \ - Fossil.cpp \ - OStream.cpp - -OBJECTS := $(patsubst %.cpp,%.o,$(CPP.SRC)) - -libfossil++.DLL.OBJECTS := $(OBJECTS) -libfossil++.BIN.LDFLAGS := -lstdc++ -fPIC $(LIBFOSSIL.LDFLAGS)# -lsqlite3 -lz -libfossil++.LIB.OBJECTS := $(libfossil++.DLL.OBJECTS) -Makefile: Makefile.in -$(libfossil++.DLL.OBJECTS): Makefile -######################################################################## -# Shared lib -$(eval $(call ShakeNMake.CALL.RULES.DLLS,libfossil++)) -all: $(libfossil++.DLL) -$(libfossil++.DLL): $(libfossil++.DLL.OBJECTS) -#Static lib (don't work well with _some_ C++ template uses) -#$(eval $(call ShakeNMake.CALL.RULES.LIBS,libfossil++)) -#all: $(libfossil++.LIB) -#$(libfossil++.LIB): $(libfossil++.LIB.OBJECTS) - -test.BIN.OBJECTS := test.o -ifeq (0,1) -test.BIN.LDFLAGS := $(LIBFOSSIL.LDFLAGS) $(EXTRA_LIBS) -lstdc++ -L. -lfossil++ @SH_LINKFLAGS@ -else -test.BIN.OBJECTS += $(libfossil++.DLL.OBJECTS) -test.BIN.LDFLAGS := $(LIBFOSSIL.LDFLAGS) $(EXTRA_LIBS) -lstdc++ @SH_LINKFLAGS@ -endif -$(eval $(call ShakeNMake.CALL.RULES.BINS,test)) -all: $(test.BIN) - - -######################################################################## -# A quick-n-dirty amalgamation build... -INCD := $(TOP_INCDIR)/fossil-scm -AMAL_D := $(TOP_SRCDIR_REL) -AMAL_C := $(AMAL_D)/libfossil.c -AMAL_H := $(AMAL_D)/libfossil.h -AMAL_CPP := $(AMAL_D)/libfossil++.cpp -AMAL_HPP := $(AMAL_D)/libfossil++.hpp -AMAL_CONF.H := $(AMAL_D)/libfossil-config.h -CLEAN_FILES += $(AMAL_HPP) $(AMAL_CPP) - -AMAL_CPP.SRC := \ - $(CPP.SRC) - -# ACHTUNG: in AMAL_H.SRC, $(AMAL_CONF.H) MUST be included first. -AMAL_HPP.SRC := \ - $(INCD)/fossil.hpp - -$(AMAL_HPP.SRC): -$(AMAL_CPP.SRC): -$(AMAL_HPP): Makefile $(AMAL_HPP.SRC) -$(AMAL_CPP): Makefile $(AMAL_HPP) $(AMAL_CPP.SRC) -$(AMAL_CONF.H): $(MAIN_MAKEFILES) - -$(AMAL_HPP): - @echo "Creating $@..." - @{ \ - echo '#if !defined(FSLPP_AMALGAMATION_BUILD)'; \ - echo '#define FSLPP_AMALGAMATION_BUILD 1'; \ - echo '#endif'; \ - echo '#include "$(notdir $(AMAL_H))"'; \ - } > $@ - @{ \ - for i in $(AMAL_HPP.SRC); do \ - echo "/* start of file $$i */"; \ - cat $$i; \ - echo "/* end of file $$i */"; \ - done; \ - } | sed \ - -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h[>"]/d' \ - -e '/[ ]*#[ ]*include[ ]*.*".*config\.h[>"]/d' \ - >> $@ - -$(AMAL_CPP): $(AMAL_HPP) - @echo "Creating $@..." - @echo '#include "$(notdir $(AMAL_HPP))"' > $@ - @{ \ - for i in $(AMAL_CPP.SRC); do \ - echo "/* start of file $$i */"; \ - cat $$i; \ - echo "/* end of file $$i */"; \ - done; \ - } | sed \ - -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h.*[>"]/d' \ - >> $@ - -AMAL_CPP_FLAGS := -I$(TOP_INCDIR) -I$(TOP_SRCDIR_REL) -I. -I$(TOP_SRCDIR_REL)/src# for sqlite3.h :/ -.PHONY: amal -amal: $(AMAL_CPP) - @ls -ls $(AMAL_CPP) $(AMAL_HPP) - @if which g++ >/dev/null; then \ - echo "Trying GCC..."; \ - g++ -c $(AMAL_CPP) -pedantic -Wstrict-aliasing -Wall -Werror -Wno-long-long $(AMAL_CPP_FLAGS); \ - fi; true - @if which clang >/dev/null; then \ - echo "Trying clang..."; \ - clang -c $(AMAL_CPP) -pedantic -Wstrict-aliasing -Wall -Werror -Wno-long-long $(AMAL_CPP_FLAGS); \ - fi; true - -# /amalgamation -######################################################################## Index: bindings/cpp/OStream.cpp ================================================================== --- bindings/cpp/OStream.cpp +++ bindings/cpp/OStream.cpp @@ -173,11 +173,11 @@ FslOutputFStream::FslOutputFStream( fsl_output_f out, void * outState ) : sb(new FslOutputFStreamBuf(out, outState, *this)){ } int FslOutputFStream::fslAppendfF( void * state, - void const * s, unsigned long n ){ + void const * s, fsl_size_t n ){ FslOutputFStream * out = static_cast(state); if(out->good()){ out->write( (char const *)s, (std::streamsize)n ); return out->good() ? 0 : -1; }else return -1; Index: bindings/cpp/test.cpp ================================================================== --- bindings/cpp/test.cpp +++ bindings/cpp/test.cpp @@ -107,11 +107,11 @@ fsl_ckout_version_info(cx, &rid, &uuid); fout << "Checkout version: "< "</dev/null || echo Unknown') -ifneq ($(filter $(PLATFORM),Darwin),) - FNC_LDFLAGS += -liconv -endif -FNC_LDFLAGS += $(LIB_CURSES) -lutil -lpthread -FNC_LDFLAGS += - -# This is needed for Mac builds, else they don't see the -# wide-char curses APIs: -CPPFLAGS += -D_XOPEN_SOURCE_EXTENDED - -fnc.BIN.OBJECTS += fnc.o -fnc.BIN.LDFLAGS := $(FNC_LDFLAGS) -$(eval $(call ShakeNMake.CALL.RULES.BIN,fnc)) -all: $(fnc.BIN) -$(fnc.BIN.OBJECTS): $(LIBF_STATIC_CLIENT_OBJ_DEPS) - -ShakeNMake.install.bins := $(fnc.BIN) -ShakeNMake.install.man1 := fnc.1 Index: config.make.in ================================================================== --- config.make.in +++ config.make.in @@ -36,17 +36,18 @@ #TOP_SRCDIR_ABS := $(dir $(realpath $(CONFIG.MAKE))) TOP_SRCDIR_REL := $(patsubst %/,%,$(dir $(CONFIG.MAKE))) TOP_SRCDIR_ABS := $(realpath $(TOP_SRCDIR_REL)) #$(error TOP_SRCDIR_REL=$(TOP_SRCDIR_REL)) -SRC.DIR := $(TOP_SRCDIR_REL)/src +DIR.src := $(TOP_SRCDIR_REL)/src # Project-specific CFLAGS TOP_INCDIR := $(TOP_SRCDIR_REL)/include COMPAT_DIR := $(TOP_SRCDIR_REL)/compat #CPPFLAGS += -D_GNU_SOURCE -Wall -Werror -I. -I$(TOP_INCDIR) -CPPFLAGS += -I. -I$(TOP_INCDIR) -I$(SRC.DIR) +CPPFLAGS += -I. -I$(TOP_INCDIR) -I$(DIR.src) +# ^^^ DIR.src is for in-tree sqlite3.h # -I$(COMPAT_DIR)/javavm/export -I$(COMPAT_DIR)/tcl-8.6/generic ifneq (,$(wildcard $(HOME)/include/*)) # This is admittedly primarily for my own sake! CPPFLAGS += -I$(HOME)/include endif ADDED doc/GNUmakefile Index: doc/GNUmakefile ================================================================== --- /dev/null +++ doc/GNUmakefile @@ -0,0 +1,28 @@ +#!/usr/bin/make -f +all: +include ../subdir-inc.make + +.NOTPARALLEL: # stop (make doc upload) from racing + +OUT_PREFIX := libfossil-API- +clean-doxy: + -rm -fr $(OUT_PREFIX)* + +DISTCLEAN_FILES += Doxyfile +clean: clean-doxy + +Doxyfile: Doxyfile.in + @echo "ERROR: need to reconfigure to create Doxyfile!"; \ + exit 1 + +doc doxy: Doxyfile + @echo "Generating API docs..." + @doxygen + @echo "Output is in: "; ls -1td $(OUT_PREFIX)* + +all: + @echo "Run 'make doc' to generate the API docs with doxygen." + +upload: + cd libfossil-API-html || exit $$?; \ + rsync -rzq -e ssh --delete . wh:www.f/doxygen/libfossil/ DELETED doc/Makefile Index: doc/Makefile ================================================================== --- doc/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/make -f -all: -include ../subdir-inc.make - -.NOTPARALLEL: # stop (make doc upload) from racing - -OUT_PREFIX := libfossil-API- -clean-doxy: - -rm -fr $(OUT_PREFIX)* - -DISTCLEAN_FILES += Doxyfile -clean: clean-doxy - -Doxyfile: Doxyfile.in - @echo "ERROR: need to reconfigure to create Doxyfile!"; \ - exit 1 - -doc doxy: Doxyfile - @echo "Generating API docs..." - @doxygen - @echo "Output is in: "; ls -1td $(OUT_PREFIX)* - -all: - @echo "Run 'make doc' to generate the API docs with doxygen." - -upload: - cd libfossil-API-html || exit $$?; \ - rsync -rzq -e ssh --delete . wh:www.f/doxygen/libfossil/ ADDED f-apps/Makefile Index: f-apps/Makefile ================================================================== --- /dev/null +++ f-apps/Makefile @@ -0,0 +1,5 @@ +all: +%: + $(MAKE) -C .. f-apps $@ +clean: + $(MAKE) -C .. f-apps clean-f-apps DELETED f-apps/Makefile.in Index: f-apps/Makefile.in ================================================================== --- f-apps/Makefile.in +++ /dev/null @@ -1,101 +0,0 @@ -all: -OBJ.DIR := .# KLUDGE for libfossil-specific hack in deps generator -include ../subdir-inc.make -#$(error $(TOP_INCDIR)) -#CPPFLAGS += -I$(TOP_INCDIR) -CPPFLAGS += -I$(TOP_DIR)/include -CPPFLAGS += -I$(TOP_DIR)/src# workaround for in-tree sqlite3.h -DISTCLEAN_FILES += Makefile - -HAS_ADDED_LIBF_STATIC := 0 -ifeq (,$(CC_PROFILE_FLAG)) - LIBFOSSIL.LDFLAGS := -L.. -L../src -lfossil -else - # For profiling builds to report useful stuff we have to statically - # link... - LIBFOSSIL.LDFLAGS := $(LIBF_STATIC_CLIENT_LDFLAGS) - HAS_ADDED_LIBF_STATIC := 1 -endif - -ifeq (0,@LIBFOSSIL_SHARED@) - # In static build, we need some extra flags... - LIBFOSSIL.LDFLAGS += $(LDFLAGS_MODULE_LOADER) -ifeq (0,$(HAS_ADDED_LIBF_STATIC)) - LIBFOSSIL.LDFLAGS += $(LIBF_STATIC_CLIENT_LDFLAGS) -endif -endif - -TEST_BINS_LDFLAGS := $(LIBFOSSIL.LDFLAGS) $(EXTRA_LIBS) @SH_LINKFLAGS@ - -TEST_BINS_LIBDEPS := $(wildcard ../libfossil.*) -ifneq (,$($(TEST_BINS_LIBDEPS))) -ifeq (,$(strip $(filter distclean clean,$(MAKECMDGOALS)))) -$(TEST_BINS_LIBDEPS): - $(MAKE) -C .. -endif -endif - -######################################################################## -# Sets up binary build rules for binary named $1. This only works -# for the basic test binaries which all have common compile/link -# bits. Assumes sources are in $1.c. -define RULES_F_BIN -$(1).BIN.OBJECTS += $(1).o -$(1).BIN.LDFLAGS += $$(TEST_BINS_LDFLAGS) -$(call ShakeNMake.CALL.RULES.BIN,$(1)) -$$($(1).BIN): $$(TEST_BINS_LIBDEPS) -all: $$($(1).BIN) -CLEAN_BINS += $$($(1).BIN) -ifneq (,$(CC_PROFILE_FLAG)) -$$($(1).BIN.OBJECTS): $$(LIBF_STATIC_CLIENT_OBJ_DEPS) -endif -endef - -ShakeNMake.install.bins := \ - f-acat \ - f-add \ - f-adiff \ - f-annotate \ - f-aparse \ - f-ci \ - f-ciwoco \ - f-co \ - f-config \ - f-delta \ - f-extract \ - f-ls \ - f-merge \ - f-new \ - f-open \ - f-parseparty \ - f-query \ - f-rebuild \ - f-repostat \ - f-resolve \ - f-revert \ - f-rm \ - f-status \ - f-tag \ - f-timeline \ - f-update \ - f-vdiff \ - f-wiki \ - f-zip - -F_BINS := \ - $(ShakeNMake.install.bins) \ - f-event \ - f-sanity \ - f-sizeof \ - f-_scratchpad \ - f-_template \ - f-test-ciwoco \ - f-test-diff-builder \ - f-test-line-diff \ - f-test-merge3 \ - f-test-reserved-name-check \ - test - -test.BIN.LDFLAGS += -lz - -$(foreach fbin,$(F_BINS),$(eval $(call RULES_F_BIN,$(fbin)))) Index: f-apps/f-ci.c ================================================================== --- f-apps/f-ci.c +++ f-apps/f-ci.c @@ -62,20 +62,41 @@ /* fall through */ default: ttype = FSL_TAGTYPE_ADD; break; } +#if 0 if(0==fsl_strncmp("sym-",t, 4)){ rc = fcli_err_set(FSL_RC_MISUSE, "Do not set sym-XYZ tags (used for branching) " "with the --tag flag: they will not be properly " "processed as sym-tags. Use --branch=name to " "add this checkin to a new branch and cancel " "its previous branch tag."); - /* If we ever do allow sym- tags here, they must require - a value. */ - }else{ + goto end; + } +#else + if(0==fsl_strncmp("sym-",t, 4)){ + if(!t[4]){ + rc = fcli_err_set(FSL_RC_MISUSE, + "Missing suffix for sym- tag."); + }else if(v){ + rc = fcli_err_set(FSL_RC_MISUSE, + "In a checkin, sym- tags may not " + "have a value."); + }else if(FSL_TAGTYPE_PROPAGATING==ttype){ + /* We disallow propagating sym- tags here (1) for compatibility + with how (fossil ci --tag) works and because it's unclear how + they (mis?)interact with branch tags. */ + rc = fcli_err_set(FSL_RC_MISUSE, + "In a checkin, sym- tags may not " + "be propagating."); + } + if(rc) goto end; + } +#endif + { fsl_card_T * tt = fsl_card_T_malloc(ttype, 0, t, v); fsl_list_append(&App.liTags, tt) /*reminder: fcli will crash on alloc error*/; } end: @@ -140,11 +161,11 @@ FCLI_FLAG_X("t","tag","name[=value]",&App.tagArg, fcli_flag_callback_tag, "Adds the given tag with an optional value. " "May be used multiple times. " "Prefix the name with * for a propagating tag. " - "A prefix of + (add tag) is equivalent to no prefix." + "A prefix of + (add tag) is equivalent to no prefix. " "May NOT be used to remove flags, so tag names must " "not start with '-'."), FCLI_FLAG_BOOL(0,"baseline",&fBaseline, "Force creationg of a baseline checkin artifact, not a delta. " "Default is automatic determination."), Index: f-apps/f-sanity.c ================================================================== --- f-apps/f-sanity.c +++ f-apps/f-sanity.c @@ -21,14 +21,15 @@ #ifdef _MSC_VER #define THIS_SRC_FNAME "f-sanity.c" /*A peculiarity of msvc x64 compiler (and not x86!) is that __FILE__ will be a relative path as seen at compile-time. But since the cwd of the compiler is -snot the source dir, this relative path will be incorrect at runtime, when our +not the source dir, this relative path will be incorrect at runtime, when our cwd IS in the source dir, and tests will fail.*/ #else -#define THIS_SRC_FNAME __FILE__ +// 2021-12-21: since moving to a top-level makefile, we can't use __FILE__ here... +#define THIS_SRC_FNAME "f-sanity.c" #endif #ifdef FSL_AMALGAMATION_BUILD #include "../libfossil.h" #else @@ -1342,11 +1343,11 @@ int rc; fsl_confirm_detail deets = fsl_confirm_detail_empty; assert(NULL==f->confirmer.callback); deets.eventId = FSL_CEVENT_OVERWRITE_MOD_FILE; - deets.filename = __FILE__; + deets.filename = THIS_SRC_FNAME; rc = fsl_cx_confirm(f, &deets, &answer); assert(0==rc); assert(FSL_CRESPONSE_NEVER==answer.response && "API guaranty violation"); answer.response = FSL_CRESPONSE_INVALID; @@ -1381,25 +1382,25 @@ fsl_cx_confirmer(f, &fcon, &oldConfimer ); } assert(fsl_confirm_callback_f_test==f->confirmer.callback); assert(message==f->confirmer.callbackState); deets.eventId = FSL_CEVENT_OVERWRITE_MOD_FILE; - deets.filename = __FILE__; + deets.filename = THIS_SRC_FNAME; rc = fsl_cx_confirm(f, &deets, &answer); assert(0==rc); assert(FSL_CRESPONSE_CANCEL==answer.response); answer.response = FSL_CRESPONSE_INVALID; deets.eventId = FSL_CEVENT_OVERWRITE_UNMGD_FILE; - deets.filename = __FILE__; + deets.filename = THIS_SRC_FNAME; rc = fsl_cx_confirm(f, &deets, &answer); assert(0==rc); assert(FSL_CRESPONSE_YES==answer.response); answer.response = FSL_CRESPONSE_INVALID; deets.eventId = FSL_CEVENT_RM_MOD_UNMGD_FILE; - deets.filename = __FILE__; + deets.filename = THIS_SRC_FNAME; rc = fsl_cx_confirm(f, &deets, &answer); assert(0==rc); assert(FSL_CRESPONSE_ALWAYS==answer.response); fsl_cx_confirmer(f, &oldConfimer, NULL ); @@ -1829,11 +1830,11 @@ actually run. Checkin will refuse to do anything if no files are modified. */ fsl_ckout_manage_opt aOpt = fsl_ckout_manage_opt_empty; - aOpt.filename = "Makefile"/*generated file*/; + aOpt.filename = "../GNUmakefile"/*generated file*/; aOpt.relativeToCwd = true; aOpt.checkIgnoreGlobs = false; rc = fsl_ckout_manage(f, &aOpt); assert(!rc); assert(1==aOpt.counts.added); @@ -1887,13 +1888,13 @@ static void test_cx_glob_lists(void){ fsl_cx * f = fcli_cx(); char const * match; int globs = FSL_GLOBS_IGNORE; f_out("fsl_cx_glob_matches() tests...\n"); - match = fsl_cx_glob_matches(f, globs, "Makefile"); + match = fsl_cx_glob_matches(f, globs, "GNUmakefile"); assert(match); - assert(0==fsl_strcmp("Makefile",match)); + assert(0==fsl_strcmp("GNUmakefile",match)); match = fsl_cx_glob_matches(f, globs, "f-apps/f-sanity"); assert(match); match = fsl_cx_glob_matches(f, globs, "no-such-glob"); @@ -2357,11 +2358,11 @@ } static void test_file_cp_mv(void){ TEST_HEADER; int rc; - char const *zFrom = __FILE__; + char const *zFrom = THIS_SRC_FNAME; char const *zTo; char const *zTo2; fsl_buffer bTo = fsl_buffer_empty; fsl_buffer bTo2 = fsl_buffer_empty; ADDED make-binding-cpp.make.in Index: make-binding-cpp.make.in ================================================================== --- /dev/null +++ make-binding-cpp.make.in @@ -0,0 +1,113 @@ +$(call ShakeNMake.CALL.CLEAN-SET,binding-cpp) +ifneq (1,$(MAKING_CLEAN)) +binding-cpp: all +endif +LFPP.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +CXXFLAGS += -fPIC -Wall -Werror + +DIR.cpp := $(DIR.bindings)/cpp +CPP.SRC := $(patsubst %,$(DIR.cpp)/%,\ + Context.cpp \ + Db.cpp \ + Deck.cpp \ + Exception.cpp \ + Fossil.cpp \ + OStream.cpp) + +LFPP_OBJECTS := $(patsubst %.cpp,%.o,$(CPP.SRC)) +$(LFPP_OBJECTS): $(LFPP.MAKEFILE) +libf++ := $(DIR.cpp)/libfossil++ +$(libf++).DLL.OBJECTS := $(LFPP_OBJECTS) +$($(libf++).DLL.OBJECTS): $(libfossil.library) +$(libf++).BIN.LDFLAGS := -lstdc++ -fPIC $(LIBF_CLIENT_LDFLAGS) +$(libf++).LIB.OBJECTS := $($(libf++).DLL.OBJECTS) +$($(libf++).DLL.OBJECTS): $(MAKEFILE_LIST) +######################################################################## +# Shared lib +$(eval $(call ShakeNMake.CALL.RULES.DLLS,$(libf++))) +$($(libf++).DLL): $($(libf++).DLL.OBJECTS) +CLEAN.binding-cpp += $($(libf++).DLL.OBJECTS) $($(libf++).DLL) +all: $($(libf++).DLL) + +CPPTest := $(DIR.cpp)/test +$(CPPTest): $(libfossil.library) +$(CPPTest).BIN.OBJECTS := $(CPPTest).o +ifeq (0,1) +$(CPPTest).BIN.LDFLAGS := $($(libf++).BIN.LDFLAGS) $(EXTRA_LIBS) -lstdc++ -L. -lfossil++ @SH_LINKFLAGS@ +else +$(CPPTest).BIN.OBJECTS += $($(libf++).DLL.OBJECTS) +$(CPPTest).BIN.LDFLAGS := $(LIBF_CLIENT_LDFLAGS) $(EXTRA_LIBS) -lstdc++ @SH_LINKFLAGS@ +endif +$(eval $(call ShakeNMake.CALL.RULES.BINS,$(CPPTest))) +CLEAN.binding-cpp += $($(CPPTest).BIN) $($(CPPTest).BIN.OBJECTS) +all: $($(CPPTest).BIN) + +######################################################################## +# A quick-n-dirty amalgamation build... +LFPP.AMAL_D := $(DIR.top) +LFPP.AMAL_CPP := $(LFPP.AMAL_D)/libfossil++.cpp +LFPP.AMAL_HPP := $(LFPP.AMAL_D)/libfossil++.hpp +LFPP.AMAL_CONF.H := $(LFPP.AMAL_D)/libfossil-config.h +CLEAN.binding-cpp += $(LFPP.AMAL_HPP) $(LFPP.AMAL_CPP) + +LFPP.AMAL_CPP.SRC := \ + $(CPP.SRC) + +# ACHTUNG: in LFPP.AMAL_H.SRC, $(LFPP.AMAL_CONF.H) MUST be included first. +LFPP.AMAL_HPP.SRC := \ + $(DIR.include)/fossil-scm/fossil.hpp + +$(LFPP.AMAL_HPP.SRC): +$(LFPP.AMAL_CPP.SRC): +$(LFPP.AMAL_HPP): $(LFPP.AMAL_HPP.SRC) +$(LFPP.AMAL_CPP): $(LFPP.AMAL_HPP) $(LFPP.AMAL_CPP.SRC) +$(LFPP.AMAL_CONF.H): $(MAIN_MAKEFILES) + +$(LFPP.AMAL_HPP): + @echo "Creating $@..." + @{ \ + echo '#if !defined(FSLPP_AMALGAMATION_BUILD)'; \ + echo '#define FSLPP_AMALGAMATION_BUILD 1'; \ + echo '#endif'; \ + echo '#include "$(notdir $(libfossil.h))"'; \ + } > $@ + @{ \ + for i in $(LFPP.AMAL_HPP.SRC); do \ + echo "/* start of file $$i */"; \ + cat $$i; \ + echo "/* end of file $$i */"; \ + done; \ + } | sed \ + -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h[>"]/d' \ + -e '/[ ]*#[ ]*include[ ]*.*".*config\.h[>"]/d' \ + >> $@ + +$(LFPP.AMAL_CPP): $(LFPP.AMAL_HPP) + @echo "Creating $@..." + @echo '#include "$(notdir $(LFPP.AMAL_HPP))"' > $@ + @{ \ + for i in $(LFPP.AMAL_CPP.SRC); do \ + echo "/* start of file $$i */"; \ + cat $$i; \ + echo "/* end of file $$i */"; \ + done; \ + } | sed \ + -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h.*[>"]/d' \ + >> $@ + +LFPP.AMAL_CPP_FLAGS := -I$(DIR.include) -I$(DIR.top) -I. -I$(DIR.src)# for sqlite3.h :/ +.PHONY: amal +amalpp: $(LFPP.AMAL_CPP) + @ls -ls $(LFPP.AMAL_CPP) $(LFPP.AMAL_HPP) + @if which g++ >/dev/null; then \ + echo "Trying GCC..."; \ + g++ -c $(LFPP.AMAL_CPP) -pedantic -Wstrict-aliasing -Wall -Werror -Wno-long-long $(LFPP.AMAL_CPP_FLAGS); \ + fi; true + @if which clang >/dev/null; then \ + echo "Trying clang..."; \ + clang -c $(LFPP.AMAL_CPP) -pedantic -Wstrict-aliasing -Wall -Werror -Wno-long-long $(LFPP.AMAL_CPP_FLAGS); \ + fi; true + +# /amalgamation +######################################################################## +CLEAN.binding-cpp += $(wildcard $(DIR.cpp)/*~) ADDED make-client-fnc.make.in Index: make-client-fnc.make.in ================================================================== --- /dev/null +++ make-client-fnc.make.in @@ -0,0 +1,43 @@ +$(call ShakeNMake.CALL.CLEAN-SET,client-fnc) +ifneq (1,$(MAKING_CLEAN)) +client-fnc: all +endif +DIR.fnc := $(DIR.client)/fnc +FNC.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +LIB_CURSES := @LIB_CURSES@ +ifeq (,$(LIB_CURSES)) +$(error Expecting LIB_CURSES to be set by the configure process.) +endif +CFLAGS_CURSES := @CFLAGS_CURSES@ +fnc.CPPFLAGS += $(CFLAGS_CURSES) + +######################################################################## +# To build fnc, we need the curses and pthread libraries. +# -lz is for libfossil +# -liconv is for libfossil on macOS +# -lutil is... ??? +# -lm is for sqlite3 +FNC_LDFLAGS := $(LIBF_STATIC_CLIENT_LDFLAGS) +PLATFORM := $(shell sh -c 'uname 2>/dev/null || echo Unknown') +ifneq ($(filter $(PLATFORM),Darwin),) + FNC_LDFLAGS += -liconv +endif +FNC_LDFLAGS += $(LIB_CURSES) -lutil -lpthread +# This is needed for Mac builds, else they don't see the +# wide-char curses APIs: +fnc.CPPFLAGS += -D_XOPEN_SOURCE_EXTENDED + +DFNC := $(DIR.fnc)/fnc +$(DFNC).BIN.OBJECTS += $(DFNC).o +$($(DFNC).BIN.OBJECTS): $(libfossil.h) $(FNC.MAKEFILE) +$(DFNC).BIN.LDFLAGS := $(FNC_LDFLAGS) +$(eval $(call ShakeNMake.CALL.RULES.BIN,$(DFNC))) +$($(DFNC).BIN): $(LIBF_STATIC_CLIENT_OBJ_DEPS) +all: $($(DFNC).BIN) +CLEAN.client-fnc := $($(DFNC).BIN) $($(DFNC).BIN.OBJECTS) +$(fnc.BIN.OBJECTS): $(LIBF_STATIC_CLIENT_OBJ_DEPS) +$(fnc.BIN.OBJECTS): CPPFLAGS+=$(fnc.CPPFLAGS) + +ShakeNMake.install.bins += $($(DFNC).BIN) +ShakeNMake.install.man1 += $(DIR.fnc)/fnc.1 +CLEAN.client-fnc += $(wildcard $(DIR.fnc)/*~) ADDED make-f-apps.make.in Index: make-f-apps.make.in ================================================================== --- /dev/null +++ make-f-apps.make.in @@ -0,0 +1,95 @@ +$(call ShakeNMake.CALL.CLEAN-SET,f-apps) +ifneq (1,$(MAKING_CLEAN)) +f-apps: all +endif +fapps.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) + +fapps.ADDED_LIBF_STATIC := 0 +ifeq (,$(CC_PROFILE_FLAG)) + fapps.LDFLAGS := -L$(DIR.top) -lfossil +else + # For profiling builds to report useful stuff we have to statically + # link... + fapps.LDFLAGS := $(LIBF_STATIC_CLIENT_LDFLAGS) + fapps.ADDED_LIBF_STATIC := 1 +endif + +ifeq (0,@LIBFOSSIL_SHARED@) + # In static build, we need some extra flags... + fapps.LDFLAGS += $(LDFLAGS_MODULE_LOADER) +ifeq (0,$(fapps.ADDED_LIBF_STATIC)) + fapps.LDFLAGS += $(LIBF_STATIC_CLIENT_LDFLAGS) +endif +endif + +TEST_BINS_LDFLAGS := $(fapps.LDFLAGS) @SH_LINKFLAGS@ +TEST_BINS_DEPS := $(libfossil.OBJ) +TEST_BINS_DEPS += $(libfossil.library) + +######################################################################## +# Sets up binary build rules for binary named $1. This only works +# for the basic test binaries which all have common compile/link +# bits. Assumes sources are in $1.c. +define RULES_F_BIN +# $(1).bin := $$(DIR.f-apps)/$(1) +$(1).BIN.OBJECTS += $(1).o +$$($(1).BIN.OBJECTS): $$(fapps.MAKEFILE) +$(1).BIN.LDFLAGS += $$(TEST_BINS_LDFLAGS) +$(call ShakeNMake.CALL.RULES.BIN,$(1)) +$$($(1).BIN): $$(TEST_BINS_DEPS) +all: $$($(1).BIN) +CLEAN.f-apps += $$($(1).BIN) $$($(1).BIN.OBJECTS) +ifneq (,$(CC_PROFILE_FLAG)) +$$($(1).BIN.OBJECTS): $$(LIBF_STATIC_CLIENT_OBJ_DEPS) +endif +endef + +# Binaries which might get installed... +F_BINS.1 := $(patsubst %,$(DIR.f-apps)/%,\ + f-acat \ + f-add \ + f-adiff \ + f-annotate \ + f-aparse \ + f-ci \ + f-ciwoco \ + f-co \ + f-config \ + f-delta \ + f-extract \ + f-ls \ + f-merge \ + f-new \ + f-open \ + f-parseparty \ + f-query \ + f-rebuild \ + f-repostat \ + f-resolve \ + f-revert \ + f-rm \ + f-status \ + f-tag \ + f-timeline \ + f-update \ + f-vdiff \ + f-wiki \ + f-zip) + +# Test/non-installed binaries... +F_BINS.2 := $(patsubst %,$(DIR.f-apps)/%,\ + f-event \ + f-sanity \ + f-sizeof \ + f-_scratchpad \ + f-_template \ + f-test-ciwoco \ + f-test-diff-builder \ + f-test-line-diff \ + f-test-merge3 \ + f-test-reserved-name-check \ + test) + +ShakeNMake.install.bins += $(F_BINS.1) +$(foreach fbin,$(F_BINS.1) $(F_BINS.2),$(eval $(call RULES_F_BIN,$(fbin)))) +CLEAN.fnc += $(wildcard $(DIR.f-apps)/*~) ADDED make-libf-only.make Index: make-libf-only.make ================================================================== --- /dev/null +++ make-libf-only.make @@ -0,0 +1,7 @@ +# This file is a workaround to enable a clean rebuild of _just_ libf. +ifeq (,$(libfossil.c)) +#^^^^^ make-libf.make not yet included +include make-libf.make +else +default: +endif ADDED make-libf.make.in Index: make-libf.make.in ================================================================== --- /dev/null +++ make-libf.make.in @@ -0,0 +1,366 @@ +ifneq (1,$(MAKING_CLEAN)) +all: libf +endif +$(call ShakeNMake.CALL.CLEAN-SET,libf) + +CPPFLAGS += -DBUILD_libfossil -DSQLITE_CORE +LIBF.EXTRA_LIBS := -lz +LIBF.EXTRA_LIBS += $(LDFLAGS_MODULE_LOADER) +LIBF.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +# libfossil*.* are "public" names for use with deps in subdir sources. +LIBF_AMAL_D := @srcdir@ +libfossil.c := $(LIBF_AMAL_D)/libfossil.c +libfossil.o := $(LIBF_AMAL_D)/libfossil.o +libfossil.h := $(LIBF_AMAL_D)/libfossil.h +libfossil-config.h := $(LIBF_AMAL_D)/libfossil-config.h +CLEAN.libf += $(libfossil.o) $(libfossil.h) $(libfossil.c) $(libfossil-config.h) + +# Flags for clients of the shared/static library: +LIBF_CLIENT_LDFLAGS := -L$(DIR.top) -lfossil -lz +SQLITE3.OBJ := $(DIR.src)/sqlite3.o +SQLITE3.C := $(wildcard $(DIR.src)/sqlite3.c) +ifneq (,$(SQLITE3.C)) + HAVE_OWN_SQLITE := 1 +else + HAVE_OWN_SQLITE := 0 + LIBF_CLIENT_LDFLAGS := -lsqlite3 +endif +# $(libfossil.o) client .o files should have these as deps: +LIBF_STATIC_CLIENT_OBJ_DEPS := $(libfossil.o) +ifeq (1,$(HAVE_OWN_SQLITE)) + LIBF_STATIC_CLIENT_OBJ_DEPS += $(SQLITE3.OBJ) +endif +# $(libfossil.o) client .o files should link with: +LIBF_STATIC_CLIENT_LDFLAGS := $(LIBF_STATIC_CLIENT_OBJ_DEPS) -lz -lm +# ^^^ fixme: add -lpthread when using external sqlite3. + + +# FSL.SRC.BASE = all sources which can go in the amalgamation build +# FSL.SRC = FSL.SRC.BASE + generated/added sources +FSL.SRC.BASE := $(patsubst %,$(DIR.src)/%, \ + fsl.c \ + annotate.c \ + appendf.c \ + auth.c \ + bag.c \ + buffer.c \ + cache.c \ + checkin.c \ + checkout.c \ + cli.c \ + content.c \ + config.c \ + cx.c \ + db.c \ + deck.c \ + delta.c \ + diff.c \ + diff2.c \ + encode.c \ + event.c \ + fs.c \ + forum.c \ + glob.c \ + io.c \ + leaf.c \ + list.c \ + lookslike.c \ + md5.c \ + merge.c \ + merge3.c \ + popen.c \ + pq.c \ + repo.c \ + schema.c \ + search.c \ + sha1.c \ + sha3.c \ + strftime.c \ + tag.c \ + ticket.c \ + udf.c \ + utf8.c \ + vfile.c \ + vpath.c \ + wiki.c \ + zip.c) + +FSL_ENABLE_SQLITE_REGEXP := 0 +ifeq (1,$(FSL_ENABLE_SQLITE_REGEXP)) + FSL.SRC.BASE += ext_regexp.c +endif + +FSL.SRC := $(FSL.SRC.BASE) +ifeq (1,$(HAVE_OWN_SQLITE)) + FSL.SRC += $(SQLITE3.C) +endif + +FSL.OBJ := $(patsubst %.c,%.o,$(FSL.SRC)) +$(FSL.OBJ): $(LIBF.MAKEFILE) +CLEAN.libf += $(FSL.OBJ) + +######################################################################## +# Transform schema SQL files into source form. We don't use fossil(1)'s +# approach because it relies on unspecified length limits on C string +# literals. Yeah, it works, but i'm funny about the C Standard. +#include $(TOP_SRCDIR_REL)/tools.make +BIN.TEXT2C := $(DIR.tools)/text2c +$(BIN.TEXT2C): $(DIR.tools)/text2c.c + cc $< -o $@ +DISTCLEAN.libf += $(BIN.TEXT2C) + +define SQL2C +$(2): +$(1).c: $(2) $$(BIN.TEXT2C) +ifneq (1,$(MAKING_CLEAN)) + @echo "Creating $$@ from $(2)..."; \ + { \ + echo '/* Binary form of file $(2) */'; \ + echo '/** @page page_$$(notdir $1) Schema: $$(notdir $(2))'; \ + echo '@code'; \ + cat "$(2)"; \ + echo ' @endcode'; \ + echo ' @see $$(subst _cstr,,$$(notdir $1))()'; \ + echo '*/'; \ + $$(BIN.TEXT2C) fsl_$$(notdir $1) < $(2); \ + echo '/* end of $(2) */'; \ + } > $$@; +endif +FSL.SRC += $(1).c +FSL.SRC.BASE += $(1).c +FSL.OBJ += $(1).o +DISTCLEAN.libf += $(1).c +sql: $(1).c +endef + +SQL.DIR := @srcdir@/sql +$(eval $(call SQL2C,$(DIR.src)/schema_config_cstr,$(SQL.DIR)/config.sql)) +$(eval $(call SQL2C,$(DIR.src)/schema_repo1_cstr,$(SQL.DIR)/repo-static.sql)) +$(eval $(call SQL2C,$(DIR.src)/schema_repo2_cstr,$(SQL.DIR)/repo-transient.sql)) +$(eval $(call SQL2C,$(DIR.src)/schema_ckout_cstr,$(SQL.DIR)/checkout.sql)) +$(eval $(call SQL2C,$(DIR.src)/schema_ticket_cstr,$(SQL.DIR)/ticket.sql)) +$(eval $(call SQL2C,$(DIR.src)/schema_ticket_reports_cstr,$(SQL.DIR)/ticket-reports.sql)) +$(eval $(call SQL2C,$(DIR.src)/schema_forum_cstr,$(SQL.DIR)/forum.sql)) +# end SQL transformation bits +######################################################################## + +# These are the flags used by fossil's embedded sqlite3: +$(SQLITE3.OBJ): CPPFLAGS+=-DNDEBUG=1 \ + -DSQLITE_DQS=0 \ + -DSQLITE_THREADSAFE=0 \ + -DSQLITE_DEFAULT_MEMSTATUS=0 \ + -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \ + -DSQLITE_LIKE_DOESNT_MATCH_BLOBS \ + -DSQLITE_OMIT_DECLTYPE \ + -DSQLITE_OMIT_PROGRESS_CALLBACK \ + -DSQLITE_OMIT_SHARED_CACHE \ + -DSQLITE_OMIT_LOAD_EXTENSION \ + -DSQLITE_MAX_EXPR_DEPTH=0 \ + -DSQLITE_USE_ALLOCA \ + -DSQLITE_ENABLE_LOCKING_STYLE=0 \ + -DSQLITE_DEFAULT_FILE_FORMAT=4 \ + -DSQLITE_ENABLE_EXPLAIN_COMMENTS \ + -DSQLITE_ENABLE_FTS4 \ + -DSQLITE_ENABLE_DBSTAT_VTAB \ + -DSQLITE_ENABLE_JSON1 \ + -DSQLITE_ENABLE_FTS5 \ + -DSQLITE_ENABLE_STMTVTAB \ + -DSQLITE_HAVE_ZLIB \ + -DSQLITE_INTROSPECTION_PRAGMAS \ + -DSQLITE_ENABLE_DBPAGE_VTAB \ + -DSQLITE_TRUSTED_SCHEMA=0 + +# FIXME: update libf sql tracing: -DSQLITE_OMIT_DEPRECATED + +$(SQLITE3.OBJ): CFLAGS+=-Wno-sign-compare +ifneq (,$(CC_PROFILE_FLAG)) +$(SQLITE3.OBJ): CFLAGS:=$(filter-out $(CC_PROFILE_FLAG),$(CFLAGS)) +# ^^^ gprof data into sqlite3 is just noise for us, so strip the +# profiling flag from this file. +endif +ifneq (,$(filter clang,$(CC))) +# Workaround for clang +$(SQLITE3.OBJ): CFLAGS+=-Wno-unused-const-variable +endif + +CLEAN.libf += $(FSL.OBJ) +ifeq (1,$(HAVE_OWN_SQLITE)) +# in-tree sqlite3 +# -lm: one of the sqlite build opts (FTS?) requires log(3). + LIBF.EXTRA_LIBS += -lm +else +# system/external sqlite3 + LIBF.EXTRA_LIBS += -lpthread +endif + +libfossil.DLL.OBJECTS := $(FSL.OBJ) +libfossil.DLL.LDFLAGS := @SH_LDFLAGS@ $(LIBF.EXTRA_LIBS) +libfossil.LIB.OBJECTS := $(libfossil.DLL.OBJECTS) +######################################################################## +# Shared lib +ifeq (1,@LIBFOSSIL_SHARED@) +$(eval $(call ShakeNMake.CALL.RULES.DLLS,libfossil)) +CLEAN.libf += $(libfossil.DLL) +libf: $(libfossil.DLL) +$(libfossil.DLL): $(libfossil.DLL.OBJECTS) +ShakeNMake.install.dlls += $(libfossil.DLL) +endif + +# Static lib +ifeq (1,@LIBFOSSIL_STATIC@) +$(eval $(call ShakeNMake.CALL.RULES.LIBS,libfossil)) +libf: $(libfossil.LIB) +$(libfossil.LIB): $(libfossil.LIB.OBJECTS) +CLEAN.libf += $(libfossil.LIB) +ShakeNMake.install.libs += $(libfossil.LIB) +endif + +######################################################################## +# $(libfossil.library) is intended to be used as a dependency for +# clients which link to -lfossil. It will be either the DLL or LIB file +# for the library. Reminder: we cannot use $(wildcard) here because +# this string is, on the first build, eval'd before libfossil is +# compiled. +libfossil.library := $(word 1,$(libfossil.DLL) $(libfossil.LIB)) +#$(info libfossil.library=$(libfossil.library)) + +######################################################################## +# A quick-n-dirty amalgamation build... +DIR.inc-fossil := $(DIR.include)/fossil-scm + +############################################################ +# libfossil.c.SRC = the list of source files (.c and private .h) to include +# in $(libfossil.c). +#libfossil.c.SRC := fossil-ext_regexp.h +libfossil.c.SRC += \ + $(FSL.SRC.BASE) + +ifeq (0,1) +# the tcl bits currently break the amalgamation +libfossil.c.SRC += \ + $(COMPAT_DIR)/javavm/export/jni_md.h \ + $(COMPAT_DIR)/javavm/export/jni.h \ + $(COMPAT_DIR)/tcl-8.6/generic/tcl.h \ + $(COMPAT_DIR)/tcl-8.6/generic/tclDecls.h \ + $(COMPAT_DIR)/tcl-8.6/generic/tclPlatDecls.h +endif + +############################################################ +# libfossil.h.SRC = the list of public header files to include +# in $(libfossil.h). +libfossil.h.SRC := \ + $(DIR.inc-fossil)/fossil-config.h \ + $(DIR.inc-fossil)/fossil.h \ + $(DIR.inc-fossil)/fossil-util.h \ + $(DIR.inc-fossil)/fossil-core.h \ + $(DIR.inc-fossil)/fossil-db.h \ + $(DIR.inc-fossil)/fossil-hash.h \ + $(DIR.inc-fossil)/fossil-repo.h \ + $(DIR.inc-fossil)/fossil-checkout.h \ + $(DIR.inc-fossil)/fossil-confdb.h \ + $(DIR.inc-fossil)/fossil-vpath.h \ + $(DIR.inc-fossil)/fossil-internal.h \ + $(DIR.inc-fossil)/fossil-auth.h \ + $(DIR.inc-fossil)/fossil-forum.h \ + $(DIR.inc-fossil)/fossil-pages.h \ + $(DIR.inc-fossil)/fossil-cli.h +$(libfossil.h.SRC): +$(libfossil.c.SRC): +libfossil.h_MAKEFILES := $(filter-out $(ShakeNMake.CISH_DEPS_FILE),$(MAKEFILE_LIST)) +$(libfossil.h): $(libfossil.h_MAKEFILES) $(libfossil.h.SRC) $(libfossil-config.h) +$(libfossil.c): $(libfossil.h_MAKEFILES) $(libfossil.h) $(libfossil.c.SRC) +$(libfossil-config.h): $(libfossil.h_MAKEFILES) + @echo "Generating $@ ..." + cd $(TOP_SRCDIR_REL) && sh configure --amal + +$(libfossil.h): + @echo "Creating $@..." + @{ \ + echo '#if !defined(FSL_AMALGAMATION_BUILD)'; \ + echo '#define FSL_AMALGAMATION_BUILD 1'; \ + echo '#endif'; \ + echo '#if defined(HAVE_CONFIG_H)'; \ + echo '# include "config.h"'; \ + echo '#endif'; \ + echo '#include "$(notdir $(libfossil-config.h))"'; \ + } > $@ + @{ \ + for i in $(libfossil.h.SRC); do \ + echo "/* start of file $$i */"; \ + cat $$i; \ + echo "/* end of file $$i */"; \ + done; \ + } | sed \ + -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h[>"]/d' \ + -e '/[ ]*#[ ]*include[ ]*.*".*config\.h"/d' \ + >> $@ + +$(libfossil.c): $(libfossil.h) + @echo "Creating $@..." + @echo '#include "$(notdir $(libfossil.h))"' > $@ + @{ \ + for i in $(libfossil.c.SRC); do \ + echo "/* start of file $$i */"; \ + cat $$i; \ + echo "/* end of file $$i */"; \ + done; \ + } | sed \ + -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h[>"]/d' \ + >> $@ + +$(libfossil.o): $(FSL.OBJ)# avoids mixed build output +amal: $(libfossil.c) +# /amalgamation +######################################################################## + +######################################################################## +# amalgamation "unversioned" files for hosting in the main fossil repo +amal-dist.zip := libfossil-amalgamation.zip +amal-dist.html := amalgamation.html +FDB := $(wildcard .fslckout _FOSSIL_) +LIBF_AMAL_CPP_FLAGS := -I$(DIR.top) +LIBF_AMAL_CPP_FLAGS += -I$(DIR.src)# for local sqlite3.h and sqlite3ext.h +$(libfossil.o): $(libfossil.c) $(libfossil.h) $(libfossil-config.h) $(FSL.SRC) + @echo "Amalgamation files:"; \ + ls -la $(libfossil.c) $(libfossil.h) $(libfossil-config.h) + $(CC) $(CPPFLAGS) $(LIBF_AMAL_CPP_FLAGS) $(CFLAGS) -c "$<" -o "$@" + @echo "Reminder: it will need these sqlite3 files to build:"; \ + echo "sqlite3.h, sqlite3ext.h, and optionally a local copy of sqlite3.c" + @echo "Reminder: run 'amal-push' from the top dir to push a build to the main server." +amal: $(libfossil.o) +.PHONY: amal $(amal-dist.zip) $(amal-dist.html) $(FDB) +$(FDB): + @test -f $@ || { echo "Missing fossil checkout db."; exit 1; } +$(amal-dist.zip): $(libfossil.o) $(FDB) + zip $@ $(libfossil.c) $(libfossil.h) $(libfossil-config.h) +SQL_VINFO := select e.mtime,b.uuid from event e, blob b where b.rid=e.objid and e.type='ci' order by e.mtime desc limit 1; +# ^^^^^^^ ==> 12345.6789,'hash' +$(amal-dist.html): $(FDB) + @{ \ + echo "
"; \ + echo ""; \ + echo "

This page hosts builds of the libfossil "; \ + echo "AmalgamationBuild. "; \ + echo "It only hosts the \"latest\" build and is updated periodically by a "; \ + echo "project contributor."; \ + echo "

"; \ + echo "
"; \
+	echo "$(amal-dist.zip)"; \
+	echo "Size: $$(ls -la $(amal-dist.zip) | awk '{print $$5}') bytes"; \
+	vinfo=$$(echo "$(SQL_VINFO)" | fossil sql); \
+	echo "Last updated (YYYY-MM-DD):" $$(echo "select strftime('%Y-%m-%d %H:%M',$${vinfo%%,*})" | fossil sql | cut -d\' -f2) UTC; \
+	version=$$(echo $${vinfo} | cut -d\' -f2); \
+	echo "Source code version: $${version:0:16}"; \
+	echo "Zip file SHA3-256 hash:" $$(fossil sha3sum $(amal-dist.zip) | cut -d' ' -f1); \
+	echo "
"; \ + } > $@ + @echo "Created $@" +amal-dist: $(amal-dist.zip) $(amal-dist.html) + vinfo=$$(echo "$(SQL_VINFO)" | fossil sql); \ + fossil uv add $(amal-dist.zip) $(amal-dist.html) --mtime $${vinfo%%,*} + fossil uv list +amal-push: amal-dist + fossil uv sync + +DISTCLEAN.libf += $(amal-dist.zip) $(amal-dist.html) +CLEAN.libf += $(wildcard $(DIR.src)/*~) Index: shakenmake.make ================================================================== --- shakenmake.make +++ shakenmake.make @@ -14,31 +14,35 @@ # are $(call)able functions, and ShakeNMake.EVAL entries, which are # $(eval)able code. # ######################################################################## - ######################################################################## # Calculate the top of the source tree, in case this is included # from a subdir. ShakeNMake.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) $(ShakeNMake.MAKEFILE):# avoid breaking some deps checks if someone renames this file (been there, done that) TOP_SRCDIR_REL ?= $(patsubst %/,%,$(dir $(ShakeNMake.MAKEFILE))) #TOP_SRCDIR := $(shell cd -P $(TOP_SRCDIR_REL) && pwd) TOP_SRCDIR := $(realpath $(TOP_SRCDIR_REL)) #$(error TOP_SRCDIR_REL=$(TOP_SRCDIR_REL) TOP_SRCDIR=$(TOP_SRCDIR)) -#TOP_INCDIR := $(TOP_SRCDIR_REL)/include -#TOP_INCDIR := $(TOP_SRCDIR)/include -#INCLUDES += -I. -I$(TOP_INCDIR) -I$(HOME)/include #CPPFLAGS += $(INCLUDES) -#TOP_DIR ?= .#$(PWD) -#ShakeNMake.CISH_SOURCES += $(wildcard *.c) +MAKING_CLEAN ?= 0 +ifneq (,$(strip $(filter distclean clean,$(MAKECMDGOALS)))) + MAKING_CLEAN:=1 +endif +ifneq (,$(strip $(findstring clean-,$(MAKECMDGOALS)))) + # ^^^ if any clean-XXX or distclean-XXX target is run, + # assume we're globally cleaning up. Using clean-xxx and non-clean + # rules in the same invocation is madness. + MAKING_CLEAN:=1 +endif +#$(info MAKING_CLEAN=$(MAKING_CLEAN)) PACKAGE.MAKEFILE := $(firstword $(MAKEFILE_LIST))# normally either Makefile or GNUmakefile $(PACKAGE.MAKEFILE): - ######################################################################## # ShakeNMake.CALL.FIND_FILE call()able function: # $1 = app name # $2 = optional path ($(PATH) is always included) @@ -73,23 +77,46 @@ @$(MAKE) --no-print-directory -C $* clean clean-.: @-deep=0; while [[ $$deep -lt $(MAKELEVEL) ]]; do \ echo -n $(ShakeNMake.SUBMAKE.INDENT); deep=$$((deep+1)); done; \ echo "Cleaning up $(CURDIR)..."; \ - rm -f $@.$$$$ $(CLEAN_FILES) + rm -f ./$@.$$$$ $(CLEAN_FILES) clean: | clean-. distclean-%: @$(MAKE) --no-print-directory -C $* distclean distclean-.: @-deep=0; while [[ $$deep -lt $(MAKELEVEL) ]]; do \ echo -n $(ShakeNMake.SUBMAKE.INDENT); deep=$$((deep+1)); done; \ echo "Dist-cleaning $(CURDIR)..."; \ - rm -f $@.$$$$ $(CLEAN_FILES) $(DISTCLEAN_FILES) + rm -f ./$@.$$$$ $(CLEAN_FILES) $(DISTCLEAN_FILES) distclean: | distclean-. + +######################################################################## +# $(call)able which installs clean-$(1) and distclean-$(1) rules which +# rm's all files/dirs listed in $(CLEAN.$(1)) and $(DISTCLEAN.$(1)) +# when the clean resp. distclean targets are run. The intention of +# this is to allow splitting-up of the CLEAN_FILES/DISTCLEAN_FILES +# into separate sets to avoid potential too-many-files problems on +# large top-level build files. +define ShakeNMake.EVAL.CLEAN-SET +clean-.: clean-$(1) +clean-$(1): + @echo "Cleaning up [$(1)]..."; \ + rm -f ./$@.$$$$ $$(CLEAN.$(1)) +distclean-.: distclean-$(1) +distclean-$(1): + @echo "Dist-cleaning up [$(1)]..."; \ + rm -f ./$@.$$$$ $$(CLEAN.$(1)) $$(DISTCLEAN.$(1)) +endef +# For each space-delimited argument, eval's ShakeNMake.EVAL.CLEAN-SET +# for that argument. +define ShakeNMake.CALL.CLEAN-SET +$(foreach cset,$(1),$(eval $(call ShakeNMake.EVAL.CLEAN-SET,$(cset)))) +endef ######################################################################## # An internal hack to enable "quiet" output. $(1) is a string which # is shown ONLY if ShakeNMake.QUIET!=1 ShakeNMake.QUIET ?= 0 @@ -112,14 +139,16 @@ # ShakeNMake.EVAL.RULES.LIB creates rules to build static library # $(1).a define ShakeNMake.EVAL.RULES.LIB $(1).LIB = $(1).a $(1).LIB: $$($(1).LIB) -CLEAN_FILES += $$($(1).LIB) +CLEAN.shakenmake += $$($(1).LIB) $$($(1).LIB): $$($(1).LIB.OBJECTS) +ifneq (1,$$(MAKING_CLEAN)) @$(call ShakeNMake.CALL.SETX,"AR [$$@]"); \ $$(ShakeNMake.BIN.AR) crs $$@ $$($(1).LIB.OBJECTS) +endif endef define ShakeNMake.CALL.RULES.LIBS $(foreach liba,$(1),$(eval $(call ShakeNMake.EVAL.RULES.LIB,$(liba)))) endef # end ShakeNMake.EVAL.RULES.LIB @@ -139,18 +168,20 @@ define ShakeNMake.EVAL.RULES.DLL $(1).DLL = $(1)$(ShakeNMake.EXTENSIONS.DLL) ifneq (.DLL,$(ShakeNMake.EXTENSIONS.DLL)) $(1).DLL: $$($(1).DLL) endif -CLEAN_FILES += $$($(1).DLL) +CLEAN.shakenmake += $$($(1).DLL) $$($(1).DLL): $$($(1).DLL.SOURCES) $$($(1).DLL.OBJECTS) +ifneq (1,$$(MAKING_CLEAN)) @test x = "x$$($(1).DLL.OBJECTS)$$($(1).DLL.SOURCES)" && { \ echo "$(1).DLL.OBJECTS and/or $(1).DLL.SOURCES are/is undefined!"; exit 1; }; \ $(call ShakeNMake.CALL.SETX,"LD [$$@]"); \ $$(CC) -o $$@ -shared $$(LDFLAGS) $(LDLIBS) \ $$($(1).DLL.OBJECTS) \ $$($(1).DLL.LDFLAGS) +endif endef ######################################################################## # $(call ShakeNMake.CALL.RULES.DLLS,[list]) calls and $(eval)s # ShakeNMake.EVAL.RULES.DLL for each entry in $(1) define ShakeNMake.CALL.RULES.DLLS @@ -175,18 +206,20 @@ # developers. i subscribe more to the school of thought that distclean # is for cleaning up configure-created files. That said, shake-n-make # isn't designed to use a configure-like process, so that is probably # moot here and we probably (maybe?) should clean up bins only in # distclean. As always: hack it to suit your preference: -CLEAN_FILES += $$($(1).BIN) +CLEAN.shakenmake += $$($(1).BIN) $$($(1).BIN): $$($(1).BIN.OBJECTS) +ifneq (1,$$(MAKING_CLEAN)) @test x = "x$$($(1).BIN.OBJECTS)" && { \ echo "$(1).BIN.OBJECTS is undefined!"; exit 1; }; \ $(call ShakeNMake.CALL.SETX,"LINK [$$@]"); \ $$(CC) -o $$@ \ $$($(1).BIN.OBJECTS) \ $$(LDFLAGS) $$($(1).BIN.LDFLAGS) +endif endef ######################################################################## # $(call ShakeNMake.EVAL.RULES.BINS,[list]) calls and $(eval)s # ShakeNMake.CALL.RULES.BIN for each entry in $(1) define ShakeNMake.CALL.RULES.BINS @@ -253,10 +286,11 @@ $(foreach dir,$(1),$(eval $(call ShakeNMake.CALL.SUBDIR,$(dir)))) endef # end ShakeNMake.CALL.SUBDIRS and friends ######################################################################## + ######################################################################## # Automatic dependencies generation for C/C++ code... # To disable deps generation, set ShakeNMake.USE_MKDEPS=0 *before* # including this file. @@ -265,54 +299,51 @@ ShakeNMake.USE_MKDEPS ?= 0 else ShakeNMake.USE_MKDEPS ?= 1 endif #$(warning ShakeNMake.USE_MKDEPS=$(ShakeNMake.USE_MKDEPS)); +ShakeNMake.CISH_DEPS_FILE := .make.c_deps +$(ShakeNMake.CISH_DEPS_FILE): ifeq (1,$(ShakeNMake.USE_MKDEPS)) ShakeNMake.CISH_SOURCES ?= $(wildcard *.cpp *.c *.c++ *.h *.hpp *.h++ *.hh) #$(warning ShakeNMake.CISH_SOURCES=$(ShakeNMake.CISH_SOURCES)) - ifneq (,$(ShakeNMake.CISH_SOURCES)) ShakeNMake.CISH_DEPS_FILE := .make.c_deps -ShakeNMake.BIN.MKDEP = gcc -w -E -MM $(CPPFLAGS) -#$(ShakeNMake.CISH_SOURCES): $(filter-out $(ShakeNMake.CISH_DEPS_FILE),$(MAKEFILE_LIST)) -CLEAN_FILES += $(ShakeNMake.CISH_DEPS_FILE) +ShakeNMake.BIN.MKDEP = gcc -w -E -MM -MG -MP $(CPPFLAGS) +CLEAN.shakenmake += $(ShakeNMake.CISH_DEPS_FILE) +ShakeNMake.INJECTED_DEPS := $(filter-out $(ShakeNMake.CISH_DEPS_FILE),$(MAKEFILE_LIST)) +ShakeNMake.INJECTED_DEPS := $(filter-out $(ShakeNMake.MAKEFILE),$(MAKEFILE_LIST)) +# ^^^^ wouldn't normally do that but this file changes so seldom and deps generation +# takes ages on a raspberry pi. $(ShakeNMake.CISH_DEPS_FILE): $(PACKAGE.MAKEFILE) $(ShakeNMake.MAKEFILE) $(ShakeNMake.CISH_SOURCES) +ifneq (1,$(MAKING_CLEAN)) @touch $@; test x = "x$(ShakeNMake.CISH_SOURCES)" && exit 0; \ echo "Generating dependencies..."; \ - $(ShakeNMake.BIN.MKDEP) $(ShakeNMake.CISH_SOURCES) 2>/dev/null > $@ || exit - -# perl -i -pe 's|^(.+)\.o:\s*((\w+/)*)|$(OBJ.DIR)/$$1.o: $(filter-out $(ShakeNMake.CISH_DEPS_FILE),$(MAKEFILE_LIST))\n$(OBJ.DIR)/$$1.o: $$2|' $@ -# That perl bit is a big, ugly, tree-specific hack for libfossil! -# gcc -E -MM strips directory parts (why, i cannot imagine), so we've got to -# hack the output. + $(ShakeNMake.BIN.MKDEP) $(ShakeNMake.CISH_SOURCES) 2>/dev/null > $@ + @echo "Unmangling gcc-generated deps..."; \ + perl -i -pe 's|^(.+)\.o:\s*((\w+/)*)|$$3$$1.o: $(ShakeNMake.INJECTED_DEPS) $$2|' $@ +endif +# Ugly tree-specific hack for libfossil: +# gcc -E -MM strips leading directory parts on the dep target +# (why, i cannot imagine), so we've got to hack its output. # Example: input= src/Foo.cpp # Generated deps: # Foo.o: src/Foo.cpp ... # So we re-extract that first path and prepend it to Foo.o using the # above perl. We also add $(MAKEFILE_LIST) has a prereq of all src # files because i belong to the school of tought which believes that # changes to the arbitrary build options set in the makefiles should # cause a rebuild. -# if [[ x = "x$(TOP_DIR)" ]]; then echo "REMOVE THIS TREE-SPECIFIC HACK!"; exit 1; fi;\ -#ifeq (,$(TOP_DIR)) -#$(error Tree-specific hack in place here. See the comments and remove these lines or set TOP_DIR) -#endif -# normally we also want: -# || $(ShakeNMake.BIN.RM) -f $@ 2>/dev/null -# because we don't want a bad generated makefile to kill the build, but gcc -E -# is returning 1 when some generated files do not yet exist. deps: $(ShakeNMake.CISH_DEPS_FILE) ifneq (,$(strip $(filter distclean clean install,$(MAKECMDGOALS)))) # $(warning Skipping C/C++ deps generation.) # ABSOLUTEBOGO := $(shell $(ShakeNMake.BIN.RM) -f $(ShakeNMake.CISH_DEPS_FILE)) else #$(warning Including C/C++ deps.) -include $(ShakeNMake.CISH_DEPS_FILE) endif - endif # ^^^^ ifneq(,$(ShakeNMake.CISH_SOURCES)) endif # ^^^^ end $(ShakeNMake.USE_MKDEPS) ######################################################################## @@ -336,11 +367,11 @@ $(CPPFLAGS) \ $(TARGET_ARCH) \ $1 endef -CLEAN_FILES += $(wildcard *.o.d) +CLEAN.shakenmake += $(wildcard *.o.d) %.o: %.c $(mkdir_compdb) @$(call ShakeNMake.CALL.SETX,"CC [$@]"); \ $(COMPILE.c) -MM -MF $(@).d -MP -MT $@.d $(COMPILE.c.OPTIONS) $(OUTPUT_OPTION) $< # $(call ShakeNBake.CALL.MkDep.Tromey,$<,$@,$(@).d); @@ -382,11 +413,11 @@ touch $@; true # ^^^^ Martin G. reports that etags fails with "Unknown option: -" on his # Ubuntun 18.04 system. Since this isn't a critical feature, we can just # force this step to succeed. tags: $(TAGFILE) - CLEAN_FILES += $(TAGFILE) + CLEAN.shakenmake += $(TAGFILE) all: $(TAGFILE) endif endif # ^^^ bin_etags endif @@ -429,25 +460,17 @@ ShakeNMake.CALL.INSTALL.grep_kludge = echo $(1) "" | grep -q '[a-zA-Z0-9]' || exit 0 ######################################################################## # $(call ShakeNMake.CALL.INSTALL,file_list,destdir[,install-sh-flags]) # Installs files $(1) to $(DESTDIR)$(2). $(3) is passed on to # $(ShakeNMake.BIN.INSTALL). -# -# This code has some rather old logic in it when uses 'cmp' to compare -# the source and dest files, and does not update the destination if -# they are the same. This was originally in place because the install -# code was used to copy header files around the source tree during -# build-time, and we wanted to avoid breaking dependencies. It hasn't -# been used in that way in a long, long time (2003? 2004?) and can -# probably be removed, as it just slows down the install process. ShakeNMake.CALL.INSTALL = $(call ShakeNMake.CALL.INSTALL.grep_kludge,$(1)); \ tgtdir="$(DESTDIR)$(2)"; \ test -d "$$tgtdir" || mkdir -p "$${tgtdir}" \ || { err=$$?; echo "$(@): mkdir -p $${tgtdir} failed"; exit $$err; }; \ for b in $(1) ""; do test -z "$$b" && continue; \ - b=$${b\#\#*/}; \ - target="$${tgtdir}/$$b"; \ + b2=$${b\#\#*/}; \ + target="$${tgtdir}/$$b2"; \ cmd="$(ShakeNMake.BIN.INSTALL) $(3) $$b $$target"; echo $$cmd; $$cmd || exit; \ done ######################################################################## # $(call ShakeNMake.CALL.UNINSTALL,file_list,source_dir) @@ -461,11 +484,12 @@ # authority. ShakeNMake.CALL.UNINSTALL = $(call ShakeNMake.CALL.INSTALL.grep_kludge,$(1)); \ tgtdir="$(DESTDIR)$(2)"; \ test -e "$${tgtdir}" || exit 0; \ for b in $(1) ""; do test -z "$$b" && continue; \ - fp="$${tgtdir}/$$b"; test -e "$$fp" || continue; \ + b2=$${b\#\#*/}; \ + fp="$${tgtdir}/$$b2"; test -e "$$fp" || continue; \ cmd="rm $$fp"; echo $$cmd; $$cmd || exit $$?; \ done; \ tgtdir="$(2)"; \ while test x != "x$${tgtdir}" -a '$(prefix)' != "$${tgtdir}" \ -a '/' != "$${tgtdir}" -a -d "$(DESTDIR)$${tgtdir}"; do \ @@ -534,5 +558,6 @@ $(foreach NUM,1 2 3 4 5 6 7 8 9,$(call \ ShakeNMake.CALL.define-install-set,man$(NUM),$(prefix)/share/man/man$(NUM),$(ShakeNMake.INSTALL.flags.nonbins))) endif # /install ######################################################################## +$(call ShakeNMake.CALL.CLEAN-SET,shakenmake) ADDED src/GNUmakefile Index: src/GNUmakefile ================================================================== --- /dev/null +++ src/GNUmakefile @@ -0,0 +1,5 @@ +all: +clean: + $(MAKE) -C .. libf-only clean-libf +%: + $(MAKE) -C .. libf-only $@ DELETED src/Makefile.in Index: src/Makefile.in ================================================================== --- src/Makefile.in +++ /dev/null @@ -1,287 +0,0 @@ -all: -include ../subdir-inc.make -#$(error $(TOP_SRCDIR)) -CPPFLAGS += -DBUILD_libfossil -DSQLITE_CORE -#CPPFLAGS += -I$(TOP_INCDIR) -#CPPFLAGS += -I$(TOP_SRCDIR)/include -#CPPFLAGS += -I$(TOP_SRCDIR)/src# workaround for in-tree sqlite3.h -EXTRA_LIBS := -lz -EXTRA_LIBS += $(LDFLAGS_MODULE_LOADER) -DISTCLEAN_FILES += Makefile -#INCLUDES_PATH ?= $(HOME)/include /usr/local/include /usr/include - - -# FSL.SRC.BASE = all sources which can go in the amalgamation build -# FSL.SRC = FSL.SRC.BASE + generated/added sources -FSL.SRC.BASE := \ - fsl.c \ - annotate.c \ - appendf.c \ - auth.c \ - bag.c \ - buffer.c \ - cache.c \ - checkin.c \ - checkout.c \ - cli.c \ - content.c \ - config.c \ - cx.c \ - db.c \ - deck.c \ - delta.c \ - diff.c \ - diff2.c \ - encode.c \ - event.c \ - fs.c \ - forum.c \ - glob.c \ - io.c \ - leaf.c \ - list.c \ - lookslike.c \ - md5.c \ - merge.c \ - merge3.c \ - popen.c \ - pq.c \ - repo.c \ - schema.c \ - search.c \ - sha1.c \ - sha3.c \ - strftime.c \ - tag.c \ - ticket.c \ - udf.c \ - utf8.c \ - vfile.c \ - vpath.c \ - wiki.c \ - zip.c - -FSL_ENABLE_SQLITE_REGEXP := 0 -ifeq (1,$(FSL_ENABLE_SQLITE_REGEXP)) - FSL.SRC.BASE += ext_regexp.c -endif - -FSL.SRC := $(FSL.SRC.BASE) - -ifneq (,$(wildcard sqlite3.c)) - FSL.SRC += sqlite3.c - HAVE_OWN_SQLITE := 1 -else - HAVE_OWN_SQLITE := 0 -endif - -FSL.OBJ := $(patsubst %.c,%.o,$(FSL.SRC)) - -######################################################################## -# Transform schema SQL files into source form. We don't use fossil(1)'s -# approach because it relies on unspecified length limits on C string -# literals. Yeah, it works, but i'm funny about the C Standard. -#include $(TOP_SRCDIR_REL)/tools.make -DIR.TOOLS := $(TOP_SRCDIR_REL)/tools -BIN.TEXT2C := $(DIR.TOOLS)/text2c -$(BIN.TEXT2C): $(DIR.TOOLS)/text2c.c - cc $< -o $@ -CLEAN_FILES += $(BIN.TEXT2C) - -define SQL2C -$(2): -$(1).c: $(2) $$(BIN.TEXT2C) - @echo "Creating $$@ from $(2)..."; \ - { \ - echo '/* Binary form of file $(2) */'; \ - echo '/** @page page_$(1) Schema: $$(notdir $(2))'; \ - echo '@code'; \ - cat "$(2)"; \ - echo ' @endcode'; \ - echo ' @see $$(subst _cstr,,$(1))()'; \ - echo '*/'; \ - $$(BIN.TEXT2C) fsl_$(1) < $(2); \ - echo '/* end of $(2) */'; \ - } > $$@; -FSL.SRC += $(1).c -FSL.SRC.BASE += $(1).c -FSL.OBJ += $(1).o -DISTCLEAN_FILES += $(1).c -sql: $(1).c -endef - -SQL.DIR := $(TOP_SRCDIR_REL)/sql -$(eval $(call SQL2C,schema_config_cstr,$(SQL.DIR)/config.sql)) -$(eval $(call SQL2C,schema_repo1_cstr,$(SQL.DIR)/repo-static.sql)) -$(eval $(call SQL2C,schema_repo2_cstr,$(SQL.DIR)/repo-transient.sql)) -$(eval $(call SQL2C,schema_ckout_cstr,$(SQL.DIR)/checkout.sql)) -$(eval $(call SQL2C,schema_ticket_cstr,$(SQL.DIR)/ticket.sql)) -$(eval $(call SQL2C,schema_ticket_reports_cstr,$(SQL.DIR)/ticket-reports.sql)) -$(eval $(call SQL2C,schema_forum_cstr,$(SQL.DIR)/forum.sql)) -# end SQL transformation bits -######################################################################## - -# These are the flags used by fossil's embedded sqlite3: -sqlite3.o: CPPFLAGS+=-DNDEBUG=1 \ - -DSQLITE_DQS=0 \ - -DSQLITE_THREADSAFE=0 \ - -DSQLITE_DEFAULT_MEMSTATUS=0 \ - -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \ - -DSQLITE_LIKE_DOESNT_MATCH_BLOBS \ - -DSQLITE_OMIT_DECLTYPE \ - -DSQLITE_OMIT_PROGRESS_CALLBACK \ - -DSQLITE_OMIT_SHARED_CACHE \ - -DSQLITE_OMIT_LOAD_EXTENSION \ - -DSQLITE_MAX_EXPR_DEPTH=0 \ - -DSQLITE_USE_ALLOCA \ - -DSQLITE_ENABLE_LOCKING_STYLE=0 \ - -DSQLITE_DEFAULT_FILE_FORMAT=4 \ - -DSQLITE_ENABLE_EXPLAIN_COMMENTS \ - -DSQLITE_ENABLE_FTS4 \ - -DSQLITE_ENABLE_DBSTAT_VTAB \ - -DSQLITE_ENABLE_JSON1 \ - -DSQLITE_ENABLE_FTS5 \ - -DSQLITE_ENABLE_STMTVTAB \ - -DSQLITE_HAVE_ZLIB \ - -DSQLITE_INTROSPECTION_PRAGMAS \ - -DSQLITE_ENABLE_DBPAGE_VTAB \ - -DSQLITE_TRUSTED_SCHEMA=0 - -# FIXME: update libf sql tracing: -DSQLITE_OMIT_DEPRECATED - -sqlite3.o: CFLAGS+=-Wno-sign-compare -ifneq (,$(CC_PROFILE_FLAG)) -sqlite3.o: CFLAGS:=$(filter-out $(CC_PROFILE_FLAG),$(CFLAGS)) -# ^^^ gprof data into sqlite3 is just noise for us, so strip the -# profiling flag from this file. -endif -ifneq (,$(filter clang,$(CC))) -# Workaround for clang -sqlite3.o: CFLAGS+=-Wno-unused-const-variable -endif - -CLEAN_FILES += $(FSL.OBJ) -ifeq (1,$(HAVE_OWN_SQLITE)) -# in-tree sqlite3 -# -lm: one of the sqlite build opts (FTS?) requires log(3). - EXTRA_LIBS += -lm -else -# system/external sqlite3 - EXTRA_LIBS += -lpthread -endif - -libfossil.DLL.OBJECTS := $(FSL.OBJ) -libfossil.DLL.LDFLAGS := @SH_LDFLAGS@ $(EXTRA_LIBS) -libfossil.LIB.OBJECTS := $(libfossil.DLL.OBJECTS) -######################################################################## -# Shared lib -ifeq (1,@LIBFOSSIL_SHARED@) -$(eval $(call ShakeNMake.CALL.RULES.DLLS,libfossil)) -all: $(libfossil.DLL) -$(libfossil.DLL): $(libfossil.DLL.OBJECTS) -ShakeNMake.install.dlls := $(libfossil.DLL) -endif - -# Static lib -ifeq (1,@LIBFOSSIL_STATIC@) -$(eval $(call ShakeNMake.CALL.RULES.LIBS,libfossil)) -all: $(libfossil.LIB) -$(libfossil.LIB): $(libfossil.LIB.OBJECTS) -ShakeNMake.install.libs := $(libfossil.LIB) -endif - -######################################################################## -# A quick-n-dirty amalgamation build... -INCD := $(TOP_INCDIR)/fossil-scm -AMAL_D := $(TOP_SRCDIR_REL) -AMAL_C := $(AMAL_D)/libfossil.c -AMAL_O := $(AMAL_D)/libfossil.o -AMAL_H := $(AMAL_D)/libfossil.h -AMAL_CONF.H := $(AMAL_D)/libfossil-config.h -CLEAN_FILES += $(AMAL_H) $(AMAL_C) $(AMAL_CONF.H) - -############################################################ -# AMAL_C.SRC = the list of source files (.c and private .h) to include -# in $(AMAL_C). -#AMAL_C.SRC := fossil-ext_regexp.h -AMAL_C.SRC += \ - $(FSL.SRC.BASE) - -ifeq (0,1) -# the tcl bits currently break the amalgamation -AMAL_C.SRC += \ - $(COMPAT_DIR)/javavm/export/jni_md.h \ - $(COMPAT_DIR)/javavm/export/jni.h \ - $(COMPAT_DIR)/tcl-8.6/generic/tcl.h \ - $(COMPAT_DIR)/tcl-8.6/generic/tclDecls.h \ - $(COMPAT_DIR)/tcl-8.6/generic/tclPlatDecls.h -endif - -############################################################ -# AMAL_H.SRC = the list of public header files to include -# in $(AMAL_H). -AMAL_H.SRC := \ - $(INCD)/fossil-config.h \ - $(INCD)/fossil.h \ - $(INCD)/fossil-util.h \ - $(INCD)/fossil-core.h \ - $(INCD)/fossil-db.h \ - $(INCD)/fossil-hash.h \ - $(INCD)/fossil-repo.h \ - $(INCD)/fossil-checkout.h \ - $(INCD)/fossil-confdb.h \ - $(INCD)/fossil-vpath.h \ - $(INCD)/fossil-internal.h \ - $(INCD)/fossil-auth.h \ - $(INCD)/fossil-forum.h \ - $(INCD)/fossil-pages.h \ - $(INCD)/fossil-cli.h -$(AMAL_H.SRC): -$(AMAL_C.SRC): -AMAL_H_MAKEFILES := $(filter-out $(ShakeNMake.CISH_DEPS_FILE),$(MAKEFILE_LIST)) -$(AMAL_H): $(AMAL_H_MAKEFILES) $(AMAL_H.SRC) $(AMAL_CONF.H) -$(AMAL_C): $(AMAL_H_MAKEFILES) $(AMAL_H) $(AMAL_C.SRC) -$(AMAL_CONF.H): $(AMAL_H_MAKEFILES) - @echo "Generating $@ ..." - cd $(TOP_SRCDIR_REL) && sh configure --amal - -$(AMAL_H): - @echo "Creating $@..." - @{ \ - echo '#if !defined(FSL_AMALGAMATION_BUILD)'; \ - echo '#define FSL_AMALGAMATION_BUILD 1'; \ - echo '#endif'; \ - echo '#if defined(HAVE_CONFIG_H)'; \ - echo '# include "config.h"'; \ - echo '#endif'; \ - echo '#include "$(notdir $(AMAL_CONF.H))"'; \ - } > $@ - @{ \ - for i in $(AMAL_H.SRC); do \ - echo "/* start of file $$i */"; \ - cat $$i; \ - echo "/* end of file $$i */"; \ - done; \ - } | sed \ - -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h[>"]/d' \ - -e '/[ ]*#[ ]*include[ ]*.*".*config\.h"/d' \ - >> $@ - -$(AMAL_C): $(AMAL_H) - @echo "Creating $@..." - @echo '#include "$(notdir $(AMAL_H))"' > $@ - @{ \ - for i in $(AMAL_C.SRC); do \ - echo "/* start of file $$i */"; \ - cat $$i; \ - echo "/* end of file $$i */"; \ - done; \ - } | sed \ - -e '/[ ]*#[ ]*include[ ]*.*fossil.*\.h[>"]/d' \ - >> $@ - -$(AMAL_O): $(FSL.OBJ)# avoids mixed build output -#all: $(AMAL_C) -amal: $(AMAL_C) -# /amalgamation -######################################################################## Index: src/schema_ckout_cstr.c ================================================================== --- src/schema_ckout_cstr.c +++ src/schema_ckout_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/checkout.sql */ +/* Binary form of file ./sql/checkout.sql */ /** @page page_schema_ckout_cstr Schema: checkout.sql @code -- The VVAR table holds miscellanous information about the local database -- in the form of name-value pairs. This is similar to the VAR table -- table in the repository except that this table holds information that @@ -264,6 +264,6 @@ 97, 115, 32, 39, 70, 83, 76, 67, 39, 46, 10, 80, 82, 65, 71, 77, 65, 32, 99, 107, 111, 117, 116, 46, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 95, 105, 100, 61, 50, 53, 50, 48, 48, 54, 54, 55, 52, 59, 10, 0}; char const * fsl_schema_ckout_cstr = fsl_schema_ckout_cstr_a; -/* end of ../sql/checkout.sql */ +/* end of ./sql/checkout.sql */ Index: src/schema_config_cstr.c ================================================================== --- src/schema_config_cstr.c +++ src/schema_config_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/config.sql */ +/* Binary form of file ./sql/config.sql */ /** @page page_schema_config_cstr Schema: config.sql @code -- This file contains the schema for the database that is kept in the -- ~/.fossil file and that stores information about the users setup. -- @@ -34,6 +34,6 @@ 39, 70, 83, 76, 71, 39, 46, 10, 80, 82, 65, 71, 77, 65, 32, 99, 102, 103, 46, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 95, 105, 100, 61, 50, 53, 50, 48, 48, 54, 54, 55, 53, 59, 10, 0}; char const * fsl_schema_config_cstr = fsl_schema_config_cstr_a; -/* end of ../sql/config.sql */ +/* end of ./sql/config.sql */ Index: src/schema_forum_cstr.c ================================================================== --- src/schema_forum_cstr.c +++ src/schema_forum_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/forum.sql */ +/* Binary form of file ./sql/forum.sql */ /** @page page_schema_forum_cstr Schema: forum.sql @code CREATE TABLE repo.forumpost( fpid INTEGER PRIMARY KEY, -- BLOB.rid for the artifact froot INT, -- fpid of the thread root @@ -34,6 +34,6 @@ 114, 101, 112, 111, 46, 102, 111, 114, 117, 109, 116, 104, 114, 101, 97, 100, 32, 79, 78, 32, 102, 111, 114, 117, 109, 112, 111, 115, 116, 40, 102, 114, 111, 111, 116, 44, 102, 109, 116, 105, 109, 101, 41, 59, 10, 0}; char const * fsl_schema_forum_cstr = fsl_schema_forum_cstr_a; -/* end of ../sql/forum.sql */ +/* end of ./sql/forum.sql */ Index: src/schema_repo1_cstr.c ================================================================== --- src/schema_repo1_cstr.c +++ src/schema_repo1_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/repo-static.sql */ +/* Binary form of file ./sql/repo-static.sql */ /** @page page_schema_repo1_cstr Schema: repo-static.sql @code -- This file contains parts of the schema that are fixed and -- unchanging across Fossil versions. @@ -424,6 +424,6 @@ 97, 32, 102, 111, 115, 115, 105, 108, 32, 114, 101, 112, 111, 115, 105, 116, 111, 114, 121, 46, 10, 80, 82, 65, 71, 77, 65, 32, 114, 101, 112, 111, 46, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 95, 105, 100, 61, 50, 53, 50, 48, 48, 54, 54, 55, 51, 59, 10, 0}; char const * fsl_schema_repo1_cstr = fsl_schema_repo1_cstr_a; -/* end of ../sql/repo-static.sql */ +/* end of ./sql/repo-static.sql */ Index: src/schema_repo2_cstr.c ================================================================== --- src/schema_repo2_cstr.c +++ src/schema_repo2_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/repo-transient.sql */ +/* Binary form of file ./sql/repo-transient.sql */ /** @page page_schema_repo2_cstr Schema: repo-transient.sql @code -- This file contains parts of the schema that can change from one -- version to the next. The data stored in these tables is -- reconstructed from the information in the main repo schema by the @@ -704,6 +704,6 @@ 111, 46, 99, 104, 101, 114, 114, 121, 112, 105, 99, 107, 95, 99, 105, 100, 32, 79, 78, 32, 99, 104, 101, 114, 114, 121, 112, 105, 99, 107, 40, 99, 104, 105, 108, 100, 105, 100, 41, 59, 10, 0}; char const * fsl_schema_repo2_cstr = fsl_schema_repo2_cstr_a; -/* end of ../sql/repo-transient.sql */ +/* end of ./sql/repo-transient.sql */ Index: src/schema_ticket_cstr.c ================================================================== --- src/schema_ticket_cstr.c +++ src/schema_ticket_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/ticket.sql */ +/* Binary form of file ./sql/ticket.sql */ /** @page page_schema_ticket_cstr Schema: ticket.sql @code -- Template for the TICKET table CREATE TABLE repo.ticket( -- Do not change any column that begins with tkt_ @@ -77,6 +77,6 @@ 103, 95, 105, 100, 120, 49, 32, 79, 78, 32, 116, 105, 99, 107, 101, 116, 99, 104, 110, 103, 40, 116, 107, 116, 95, 105, 100, 44, 32, 116, 107, 116, 95, 109, 116, 105, 109, 101, 41, 59, 10, 0}; char const * fsl_schema_ticket_cstr = fsl_schema_ticket_cstr_a; -/* end of ../sql/ticket.sql */ +/* end of ./sql/ticket.sql */ Index: src/schema_ticket_reports_cstr.c ================================================================== --- src/schema_ticket_reports_cstr.c +++ src/schema_ticket_reports_cstr.c @@ -1,6 +1,6 @@ -/* Binary form of file ../sql/ticket-reports.sql */ +/* Binary form of file ./sql/ticket-reports.sql */ /** @page page_schema_ticket_reports_cstr Schema: ticket-reports.sql @code INSERT INTO reportfmt(title,mtime,cols,sqlcode) VALUES('All Tickets',julianday('1970-01-01'),'#ffffff Key: #f2dcdc Active @@ -59,6 +59,6 @@ 44, 10, 32, 32, 115, 116, 97, 116, 117, 115, 44, 10, 32, 32, 115, 117, 98, 115, 121, 115, 116, 101, 109, 44, 10, 32, 32, 116, 105, 116, 108, 101, 10, 70, 82, 79, 77, 32, 116, 105, 99, 107, 101, 116, 39, 41, 59, 10, 0}; char const * fsl_schema_ticket_reports_cstr = fsl_schema_ticket_reports_cstr_a; -/* end of ../sql/ticket-reports.sql */ +/* end of ./sql/ticket-reports.sql */