diff options
Diffstat (limited to 'ffbuild')
-rw-r--r-- | ffbuild/.gitignore | 5 | ||||
-rw-r--r-- | ffbuild/arch.mak | 17 | ||||
-rw-r--r-- | ffbuild/common.mak | 176 | ||||
-rw-r--r-- | ffbuild/library.mak | 107 | ||||
-rwxr-xr-x | ffbuild/libversion.sh | 13 | ||||
-rwxr-xr-x | ffbuild/pkgconfig_generate.sh | 62 | ||||
-rwxr-xr-x | ffbuild/version.sh | 63 |
7 files changed, 443 insertions, 0 deletions
diff --git a/ffbuild/.gitignore b/ffbuild/.gitignore new file mode 100644 index 0000000000..38ed170752 --- /dev/null +++ b/ffbuild/.gitignore @@ -0,0 +1,5 @@ +/.config +/config.fate +/config.log +/config.mak +/config.sh diff --git a/ffbuild/arch.mak b/ffbuild/arch.mak new file mode 100644 index 0000000000..e09006efca --- /dev/null +++ b/ffbuild/arch.mak @@ -0,0 +1,17 @@ +OBJS-$(HAVE_ARMV5TE) += $(ARMV5TE-OBJS) $(ARMV5TE-OBJS-yes) +OBJS-$(HAVE_ARMV6) += $(ARMV6-OBJS) $(ARMV6-OBJS-yes) +OBJS-$(HAVE_ARMV8) += $(ARMV8-OBJS) $(ARMV8-OBJS-yes) +OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes) +OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes) + +OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes) +OBJS-$(HAVE_MIPSDSP) += $(MIPSDSP-OBJS) $(MIPSDSP-OBJS-yes) +OBJS-$(HAVE_MIPSDSPR2) += $(MIPSDSPR2-OBJS) $(MIPSDSPR2-OBJS-yes) +OBJS-$(HAVE_MSA) += $(MSA-OBJS) $(MSA-OBJS-yes) +OBJS-$(HAVE_MMI) += $(MMI-OBJS) $(MMI-OBJS-yes) + +OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes) +OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes) + +OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes) +OBJS-$(HAVE_X86ASM) += $(X86ASM-OBJS) $(X86ASM-OBJS-yes) diff --git a/ffbuild/common.mak b/ffbuild/common.mak new file mode 100644 index 0000000000..eb41b05ee6 --- /dev/null +++ b/ffbuild/common.mak @@ -0,0 +1,176 @@ +# +# common bits used by all libraries +# + +DEFAULT_X86ASMD=.dbg + +ifeq ($(DBG),1) +X86ASMD=$(DEFAULT_X86ASMD) +else +X86ASMD= +endif + +ifndef SUBDIR + +ifndef V +Q = @ +ECHO = printf "$(1)\t%s\n" $(2) +BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC +SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM + +MSG = $@ +M = @$(call ECHO,$(TAG),$@); +$(foreach VAR,$(BRIEF), \ + $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) +$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) +$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) +endif + +ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample + +# NASM requires -I path terminated with / +IFLAGS := -I. -I$(SRC_LINK)/ +CPPFLAGS := $(IFLAGS) $(CPPFLAGS) +CFLAGS += $(ECFLAGS) +CCFLAGS = $(CPPFLAGS) $(CFLAGS) +OBJCFLAGS += $(EOBJCFLAGS) +OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS) +ASFLAGS := $(CPPFLAGS) $(ASFLAGS) +CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) +X86ASMFLAGS += $(IFLAGS:%=%/) -I$(<D)/ -Pconfig.asm +NVCCFLAGS += -ptx + +HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS) +LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS) + +define COMPILE + $(call $(1)DEP,$(1)) + $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) +endef + +COMPILE_C = $(call COMPILE,CC) +COMPILE_CXX = $(call COMPILE,CXX) +COMPILE_S = $(call COMPILE,AS) +COMPILE_M = $(call COMPILE,OBJCC) +COMPILE_X86ASM = $(call COMPILE,X86ASM) +COMPILE_HOSTC = $(call COMPILE,HOSTCC) +COMPILE_NVCC = $(call COMPILE,NVCC) + +%.o: %.c + $(COMPILE_C) + +%.o: %.cpp + $(COMPILE_CXX) + +%.o: %.m + $(COMPILE_M) + +%.s: %.c + $(CC) $(CCFLAGS) -S -o $@ $< + +%.o: %.S + $(COMPILE_S) + +%_host.o: %.c + $(COMPILE_HOSTC) + +%$(DEFAULT_X86ASMD).asm: %.asm + $(DEPX86ASM) $(X86ASMFLAGS) -M -o $@ $< > $(@:.asm=.d) + $(X86ASM) $(X86ASMFLAGS) -e $< | sed '/^%/d;/^$$/d;' > $@ + +%.o: %.asm + $(COMPILE_X86ASM) + -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@) + +%.o: %.rc + $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $< + +%.i: %.c + $(CC) $(CCFLAGS) $(CC_E) $< + +%.h.c: + $(Q)echo '#include "$*.h"' >$@ + +%.ptx: %.cu + $(COMPILE_NVCC) + +%.ptx.c: %.ptx + $(Q)sh $(SRC_PATH)/compat/cuda/ptx2c.sh $@ $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) + +%.c %.h %.pc %.ver %.version: TAG = GEN + +# Dummy rule to stop make trying to rebuild removed or renamed headers +%.h: + @: + +# Disable suffix rules. Most of the builtin rules are suffix rules, +# so this saves some time on slow systems. +.SUFFIXES: + +# Do not delete intermediate files from chains of implicit rules +$(OBJS): +endif + +include $(SRC_PATH)/ffbuild/arch.mak + +OBJS += $(OBJS-yes) +SLIBOBJS += $(SLIBOBJS-yes) +FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS) +TESTPROGS += $(TESTPROGS-yes) + +LDLIBS = $(FFLIBS:%=%$(BUILDSUF)) +FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) $(FFLIBS:%=EXTRALIBS-%),$($(lib))) $(EXTRALIBS) + +OBJS := $(sort $(OBJS:%=$(SUBDIR)%)) +SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%)) +TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o) +TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF)) +HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o) +HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF)) +TOOLS += $(TOOLS-yes) +TOOLOBJS := $(TOOLS:%=tools/%.o) +TOOLS := $(TOOLS:%=tools/%$(EXESUF)) +HEADERS += $(HEADERS-yes) + +PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME)) +DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S))) +STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib))) + +SRC_DIR := $(SRC_PATH)/lib$(NAME) +ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) +SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) +SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) +HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o)) +PTXOBJS = $(filter %.ptx.o,$(OBJS)) +$(HOBJS): CCFLAGS += $(CFLAGS_HEADERS) +checkheaders: $(HOBJS) +.SECONDARY: $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=) + +alltools: $(TOOLS) + +$(HOSTOBJS): %.o: %.c + $(COMPILE_HOSTC) + +$(HOSTPROGS): %$(HOSTEXESUF): %.o + $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS) + +$(OBJS): | $(sort $(dir $(OBJS))) +$(HOBJS): | $(sort $(dir $(HOBJS))) +$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS))) +$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS))) +$(TESTOBJS): | $(sort $(dir $(TESTOBJS))) +$(TOOLOBJS): | tools + +OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS)) + +CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.pc *.ptx *.ptx.c *.ver *.version *$(DEFAULT_X86ASMD).asm *~ +LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a + +define RULES +clean:: + $(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS) +endef + +$(eval $(RULES)) + +-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d) diff --git a/ffbuild/library.mak b/ffbuild/library.mak new file mode 100644 index 0000000000..612bacb980 --- /dev/null +++ b/ffbuild/library.mak @@ -0,0 +1,107 @@ +include $(SRC_PATH)/ffbuild/common.mak + +ifeq (,$(filter %clean config,$(MAKECMDGOALS))) +-include $(SUBDIR)lib$(NAME).version +endif + +LIBVERSION := $(lib$(NAME)_VERSION) +LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR) +LIBMINOR := $(lib$(NAME)_VERSION_MINOR) +INCINSTDIR := $(INCDIR)/lib$(NAME) + +INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) + +all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc +all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc + +LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) +$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H + +$(SUBDIR)$(LIBNAME): $(OBJS) + $(RM) $@ + $(AR) $(ARFLAGS) $(AR_O) $^ + $(RANLIB) $@ + +install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig + +install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static +install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared + +define RULES +$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB)) +$(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME) + +$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME) + +$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o + $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS) + +$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR) + $$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$< > $$@ + +$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h ffbuild/config.sh | $(SUBDIR) + $$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" + +$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) + $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ + +$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) + $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME) + +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver + $(SLIB_CREATE_DEF_CMD) + $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS) + $(SLIB_EXTRA_CMD) + +ifdef SUBDIR +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS) +endif + +clean:: + $(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \ + $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%) + +install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME) + $(Q)mkdir -p "$(SHLIBDIR)" + $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" + $$(STRIP) "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" + $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),(cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F));) + $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)") + $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)") + $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)") + +install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME) + $(Q)mkdir -p "$(LIBDIR)" + $$(INSTALL) -m 644 $$< "$(LIBDIR)" + $(LIB_INSTALL_EXTRA_CMD) + +install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) + $(Q)mkdir -p "$(INCINSTDIR)" + $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" + +install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc + $(Q)mkdir -p "$(PKGCONFIGDIR)" + $$(INSTALL) -m 644 $$^ "$(PKGCONFIGDIR)" + +uninstall-libs:: + -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \ + "$(SHLIBDIR)/$(SLIBNAME)" \ + "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)" + -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%") + -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%") + -$(RM) "$(LIBDIR)/$(LIBNAME)" + +uninstall-headers:: + $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS)) + -rmdir "$(INCINSTDIR)" + +uninstall-pkgconfig:: + $(RM) "$(PKGCONFIGDIR)/lib$(FULLNAME).pc" +endef + +$(eval $(RULES)) + +$(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME) +$(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME) + +testprogs: $(TESTPROGS) diff --git a/ffbuild/libversion.sh b/ffbuild/libversion.sh new file mode 100755 index 0000000000..990ce9f640 --- /dev/null +++ b/ffbuild/libversion.sh @@ -0,0 +1,13 @@ +toupper(){ + echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ +} + +name=lib$1 +ucname=$(toupper ${name}) +file=$2 + +eval $(awk "/#define ${ucname}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file") +eval ${ucname}_VERSION=\$${ucname}_VERSION_MAJOR.\$${ucname}_VERSION_MINOR.\$${ucname}_VERSION_MICRO +eval echo "${name}_VERSION=\$${ucname}_VERSION" +eval echo "${name}_VERSION_MAJOR=\$${ucname}_VERSION_MAJOR" +eval echo "${name}_VERSION_MINOR=\$${ucname}_VERSION_MINOR" diff --git a/ffbuild/pkgconfig_generate.sh b/ffbuild/pkgconfig_generate.sh new file mode 100755 index 0000000000..e5de6716d2 --- /dev/null +++ b/ffbuild/pkgconfig_generate.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +. ffbuild/config.sh + +if test "$shared" = "yes"; then + shared=true +else + shared=false +fi + +shortname=$1 +name=lib${shortname} +fullname=${name}${build_suffix} +comment=$2 +libs=$(eval echo \$extralibs_${shortname}) +deps=$(eval echo \$${shortname}_deps) + +for dep in $deps; do + depname=lib${dep} + fulldepname=${depname}${build_suffix} + . ${depname}/${depname}.version + depversion=$(eval echo \$${depname}_VERSION) + requires="$requires ${fulldepname} >= ${depversion}, " +done +requires=${requires%, } + +version=$(grep ${name}_VERSION= $name/${name}.version | cut -d= -f2) + +cat <<EOF > $name/$fullname.pc +prefix=$prefix +exec_prefix=\${prefix} +libdir=$libdir +includedir=$incdir + +Name: $fullname +Description: $comment +Version: $version +Requires: $($shared || echo $requires) +Requires.private: $($shared && echo $requires) +Conflicts: +Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs) +Libs.private: $($shared && echo $libs) +Cflags: -I\${includedir} +EOF + +mkdir -p doc/examples/pc-uninstalled +includedir=${source_path} +[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.." + cat <<EOF > doc/examples/pc-uninstalled/${name}-uninstalled.pc +prefix= +exec_prefix= +libdir=\${pcfiledir}/../../../$name +includedir=${source_path} + +Name: $fullname +Description: $comment +Version: $version +Requires: $requires +Conflicts: +Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${fullname#lib} $($shared || echo $libs) +Cflags: -I\${includedir} +EOF diff --git a/ffbuild/version.sh b/ffbuild/version.sh new file mode 100755 index 0000000000..edc4dd33c5 --- /dev/null +++ b/ffbuild/version.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# Usage: version.sh <ffmpeg-root-dir> <output-version.h> <extra-version> + +# check for git short hash +if ! test "$revision"; then + if (cd "$1" && grep git RELEASE 2> /dev/null >/dev/null) ; then + revision=$(cd "$1" && git describe --tags --match N 2> /dev/null) + else + revision=$(cd "$1" && git describe --tags --always 2> /dev/null) + fi +fi + +# Shallow Git clones (--depth) do not have the N tag: +# use 'git-YYYY-MM-DD-hhhhhhh'. +test "$revision" || revision=$(cd "$1" && + git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null) + +# Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or +# ffmpeg-HEAD-hhhhhhh. +if [ -z "$revision" ]; then + srcdir=$(cd "$1" && pwd) + case "$srcdir" in + */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) + git_hash="${srcdir##*-}";; + */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) + git_hash="${srcdir##*-}";; + esac +fi + +# no revision number found +test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null) + +# Append the Git hash if we have one +test "$revision" && test "$git_hash" && revision="$revision-$git_hash" + +# releases extract the version number from the VERSION file +version=$(cd "$1" && cat VERSION 2> /dev/null) +test "$version" || version=$revision + +test -n "$3" && version=$version-$3 + +if [ -z "$2" ]; then + echo "$version" + exit +fi + +NEW_REVISION="#define FFMPEG_VERSION \"$version\"" +OLD_REVISION=$(cat "$2" 2> /dev/null | head -4 | tail -1) + +# String used for preprocessor guard +GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//') + +# Update version header only on revision changes to avoid spurious rebuilds +if test "$NEW_REVISION" != "$OLD_REVISION"; then + cat << EOF > "$2" +/* Automatically generated by version.sh, do not manually edit! */ +#ifndef $GUARD +#define $GUARD +$NEW_REVISION +#endif /* $GUARD */ +EOF +fi |