Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

add tools as subtree #5

Merged
merged 7 commits into from
Jun 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

77 changes: 77 additions & 0 deletions contrib/devtools/git-subtree-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

DIR="$1"
COMMIT="$2"
if [ -z "$COMMIT" ]; then
COMMIT=HEAD
fi

# Taken from git-subtree (Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>)
find_latest_squash()
{
dir="$1"
sq=
main=
sub=
git log --grep="^git-subtree-dir: $dir/*\$" \
--pretty=format:'START %H%n%s%n%n%b%nEND%n' "$COMMIT" |
while read a b junk; do
case "$a" in
START) sq="$b" ;;
git-subtree-mainline:) main="$b" ;;
git-subtree-split:) sub="$b" ;;
END)
if [ -n "$sub" ]; then
if [ -n "$main" ]; then
# a rejoin commit?
# Pretend its sub was a squash.
sq="$sub"
fi
echo "$sq" "$sub"
break
fi
sq=
main=
sub=
;;
esac
done
}

latest_squash="$(find_latest_squash "$DIR")"
if [ -z "$latest_squash" ]; then
echo "ERROR: $DIR is not a subtree" >&2
exit 2
fi

set $latest_squash
old=$1
rev=$2
if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then
echo "ERROR: subtree commit $rev unavailable. Fetch/update the subtree repository" >&2
exit 2
fi
tree_subtree=$(git show -s --format="%T" $rev)
echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
tree_actual=$(git ls-tree -d "$COMMIT" "$DIR" | head -n 1)
if [ -z "$tree_actual" ]; then
echo "FAIL: subtree directory $DIR not found in $COMMIT" >&2
exit 1
fi
set $tree_actual
tree_actual_type=$2
tree_actual_tree=$3
echo "$DIR in $COMMIT currently refers to $tree_actual_type $tree_actual_tree"
if [ "d$tree_actual_type" != "dtree" ]; then
echo "FAIL: subtree directory $DIR is not a tree in $COMMIT" >&2
exit 1
fi
if [ "$tree_actual_tree" != "$tree_subtree" ]; then
git diff-tree $tree_actual_tree $tree_subtree >&2
echo "FAIL: subtree directory tree doesn't match subtree commit tree" >&2
exit 1
fi
echo "GOOD"
1 change: 0 additions & 1 deletion tools
Submodule tools deleted from fd7a6f
3 changes: 3 additions & 0 deletions tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# do not show binary directory
o

105 changes: 105 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

ifeq ($(BSPTOOLS),)
$(error You must first run 'source environment')
endif

ifeq ($(uname_S), Linux)
TOOLS_ENABLE_ESSENTIALS ?= n
TOOLS_ENABLE_OBJCONV ?= n
TOOLS_ENABLE_FASM ?= n
TOOLS_ENABLE_CMAKE ?= n
TOOLS_ENABLE_GNUTOOLS ?= n
TOOLS_ENABLE_KCONFIG ?= n
TOOLS_ENABLE_GCC ?= n
TOOLS_ENABLE_RUST ?= n
else
TOOLS_ENABLE_ESSENTIALS ?= y
TOOLS_ENABLE_OBJCONV ?= n
TOOLS_ENABLE_FASM ?= n
TOOLS_ENABLE_CMAKE ?= n
TOOLS_ENABLE_GNUTOOLS ?= n
TOOLS_ENABLE_KCONFIG ?= n
TOOLS_ENABLE_GCC ?= n
TOOLS_ENABLE_RUST ?= n
endif

# essentials
subdir-${TOOLS_ENABLE_ESSENTIALS} = \
autoconf \
automake \
libtool \
pkgconfig

# objconv (on macOS)
subdir-${TOOLS_ENABLE_OBJCONV} += \
objconv

# fasm (on macOS)
subdir-${TOOLS_ENABLE_FASM} += \
fasm

# cmake (on macOS)
subdir-${TOOLS_ENABLE_CMAKE} += \
cmake

# gnu utils (on macOS)
subdir-${TOOLS_ENABLE_GNUTOOLS} += \
coreutils

# kconfig
subdir-${TOOLS_ENABLE_KCONFIG} += \
kconfig

# gcc (on macOS)
subdir-${TOOLS_ENABLE_GCC} += \
gmp \
mpfr \
mpc \
isl \
gnugcc

# rust & cargo (on macOS)
subdir-${TOOLS_ENABLE_RUST} += \
rust

automake_depends-y = \
autoconf

libtool_depends-y = \
automake

pkgconfig_depends-y = \
libtool

objconv_depends-y = \
pkgconfig

fasm_depends-y = \
objconv

cmake_depends-y = \
pkgconfig

coreutils_depends-y = \
pkgconfig

kconfig_depends-y = \
pkgconfig

gmp_depends-y = \
pkgconfig

mpfr_depends-y = \
gmp

mpc_depends-y = \
mpfr

isl_depends-y = \
mpc

gnugcc_depends-y = \
isl


include Makefile.lib
66 changes: 66 additions & 0 deletions tools/Makefile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

.PHONY: clone config build install uninstall clean

# debug commands
ifeq (${PRINT_DEBUG}, y)
OUTPUT_DEV =
else
OUTPUT_DEV = > /dev/null 2>&1
endif

# common macros
# $(call patchme,DIRECTORY_TO_BE_PATCHED)
define patchme
if [ -d "$(1)" ] && [ -d "patches" ] && [ ! -f ".patched" ]; then \
$(foreach F, $(wildcard $(shell find patches -type f \( -name "*.patch" \) | sort)), patch -d $(1) -p1 < $(F); echo $(F) >> .patched;) \
fi
endef

# make targets
clone: __FORCE
@echo "\033[1;31m CLONE ${target_name}\033[0m"
@if [ ! -f .cloned ]; then \
${MAKE} ${target_name}_clone $(OUTPUT_DEV); \
if [ $$? -ne 0 ] ; then exit 1; else touch .cloned; fi; \
fi;

config: clone __FORCE
@echo "\033[0;36m CONFIG ${target_name}\033[0m"
@if [ ! -f .configured ]; then \
${MAKE} ${target_name}_config $(OUTPUT_DEV); \
if [ $$? -ne 0 ] ; then exit 1; else touch .configured; fi; \
fi;

build: config __FORCE
@echo "\033[0;35m BUILD ${target_name}\033[0m"
@if [ ! -f .built ]; then \
${MAKE} ${target_name}_build $(OUTPUT_DEV); \
if [ $$? -ne 0 ] ; then exit 1; else touch .built; fi; \
fi;

clean: __FORCE
@echo "\033[0;33m CLEAN ${target_name}\033[0m"
@${MAKE} ${target_name}_clean $(OUTPUT_DEV);
@rm -rf .built
@rm -rf .configured

distclean: __FORCE
@echo "\033[0;31m DISTCLEAN ${target_name}\033[0m"
@${MAKE} ${target_name}_distclean $(OUTPUT_DEV);
@rm -rf .built
@rm -rf .configured
@rm -rf .patched
@rm -rf .cloned

install: build __FORCE
@echo "\033[1;34m INSTALL ${target_name}\033[0m"
@${MAKE} ${target_name}_install $(OUTPUT_DEV);

uninstall: __FORCE
@echo "\033[1;31m UNINSTALL ${target_name}\033[0m"
@${MAKE} ${target_name}_uninstall $(OUTPUT_DEV);

all: install

__FORCE:
@true
1 change: 1 addition & 0 deletions tools/Makefile.lib
25 changes: 25 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Tools

### add subtree to project
```
$ git remote add tools https://github.com/kozyilmaz/tools.git
$ git subtree add --prefix=tools/ --squash tools master
```

### check subtree after clean clone
```
$ git fetch https://github.com/kozyilmaz/tools.git master
$ ./contrib/devtools/git-subtree-check.sh tools
```

### sync subtree repositories
```
$ git remote add tools-remote https://github.com/kozyilmaz/tools.git
$ git subtree pull --prefix=tools/ --squash tools-remote master
```

### two ways of checking subtrees
```
$ git log | grep git-subtree-dir | tr -d ' ' | cut -d ":" -f2 | sort | uniq
$ git log | grep git-subtree-dir | tr -d ' ' | cut -d ":" -f2 | sort | uniq | xargs -I {} bash -c 'if [ -d $(git rev-parse --show-toplevel)/{} ] ; then echo {}; fi'
```
29 changes: 29 additions & 0 deletions tools/autoconf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

target_name ?= autoconf

include ../Makefile.build

AUTOCONF_VERSION="2.69"

autoconf_clone:
if [ ! -f "autoconf-$(AUTOCONF_VERSION).tar.gz" ]; then curl -OL http://ftp.gnu.org/gnu/autoconf/autoconf-$(AUTOCONF_VERSION).tar.gz; fi
if [ ! -d "autoconf-$(AUTOCONF_VERSION)" ]; then tar xzf autoconf-$(AUTOCONF_VERSION).tar.gz; fi

autoconf_config:
( cd autoconf-$(AUTOCONF_VERSION); ./configure --prefix=${BSPTOOLS}/o )

autoconf_build:
make -C autoconf-$(AUTOCONF_VERSION) -j ${BSPJOB}

autoconf_install:
make -C autoconf-$(AUTOCONF_VERSION) install

autoconf_uninstall:
make -C autoconf-$(AUTOCONF_VERSION) uninstall

autoconf_clean:
if [ -f "autoconf-$(AUTOCONF_VERSION)/Makefile" ]; then make -C autoconf-$(AUTOCONF_VERSION) distclean; fi

autoconf_distclean:
rm -rf autoconf-$(AUTOCONF_VERSION)
rm -rf autoconf-$(AUTOCONF_VERSION).tar.gz
29 changes: 29 additions & 0 deletions tools/automake/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

target_name ?= automake

include ../Makefile.build

AUTOMAKE_VERSION="1.15"

automake_clone:
if [ ! -f "automake-$(AUTOMAKE_VERSION).tar.gz" ]; then curl -OL http://ftp.gnu.org/gnu/automake/automake-$(AUTOMAKE_VERSION).tar.gz; fi;
if [ ! -d "automake-$(AUTOMAKE_VERSION)" ]; then tar xzf automake-$(AUTOMAKE_VERSION).tar.gz; fi

automake_config:
( cd automake-$(AUTOMAKE_VERSION); ./configure --prefix=${BSPTOOLS}/o; )

automake_build:
make -C automake-$(AUTOMAKE_VERSION) -j ${BSPJOB}

automake_install:
make -C automake-$(AUTOMAKE_VERSION) install

automake_uninstall:
make -C automake-$(AUTOMAKE_VERSION) uninstall

automake_clean:
if [ -f "automake-$(AUTOMAKE_VERSION)/Makefile" ]; then make -C automake-$(AUTOMAKE_VERSION) distclean; fi

automake_distclean:
rm -rf automake-$(AUTOMAKE_VERSION)
rm -rf automake-$(AUTOMAKE_VERSION).tar.gz
29 changes: 29 additions & 0 deletions tools/cmake/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

target_name ?= cmake

include ../Makefile.build

CMAKE_VERSION="3.8.1"

cmake_clone:
if [ ! -f "cmake-$(CMAKE_VERSION).tar.gz" ]; then curl -OL https://cmake.org/files/v3.8/cmake-$(CMAKE_VERSION).tar.gz; fi;
if [ ! -d "cmake-$(CMAKE_VERSION)" ]; then tar xzf cmake-$(CMAKE_VERSION).tar.gz; fi

cmake_config:
( cd cmake-$(CMAKE_VERSION); CFLAGS="" CXXFLAGS="" ./bootstrap --prefix=${BSPTOOLS}/o; )

cmake_build:
make -C cmake-$(CMAKE_VERSION) -j ${BSPJOB}

cmake_install:
make -C cmake-$(CMAKE_VERSION) -j ${BSPJOB} install

cmake_uninstall:
make -C cmake-$(CMAKE_VERSION) uninstall

cmake_clean:
if [ -f "cmake-$(CMAKE_VERSION)/Makefile" ]; then make -C cmake-$(CMAKE_VERSION) distclean; fi

cmake_distclean:
rm -rf cmake-$(CMAKE_VERSION)
rm -rf cmake-$(CMAKE_VERSION).tar.gz
Loading