summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-09-21 22:37:06 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:51 -0500
commit6949720562f2cc0e07c10a15b248917f0171b285 (patch)
tree8f5186f2de30864f3f6be0591fb79010515a0f6b
parent62ea924dec11db1a56594a19d042db7d9edc71ee (diff)
downloadperk-6949720562f2cc0e07c10a15b248917f0171b285.tar.bz2
perk-6949720562f2cc0e07c10a15b248917f0171b285.tar.xz
build system: support setting an external folder as the source directory.
-rw-r--r--Makefile.in7
-rw-r--r--config.usage2
-rwxr-xr-xconfigure42
3 files changed, 41 insertions, 10 deletions
diff --git a/Makefile.in b/Makefile.in
index 8d3e543..1bbc47f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,7 @@
PACKAGE = @package@
NICKNAME = @nickname@
PROJECT_DIR = @project_dir@
+SOURCE_DIR = @source_dir@
GIT_REFERENCE_INDEX = @git_reference_index@
CUSTOM_INSTALL_HEADERS = @custom_install_headers@
AVOID_VERSION = @avoid_version@
@@ -101,10 +102,10 @@ include $(PROJECT_DIR)/project/overrides.mk
$(APP_SRCS:%.c=%.o): CFLAGS_STATIC = $(CFLAGS_APP)
-src/%.lo: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag
+src/%.lo: $(SOURCE_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag
$(CC) -c -o $@ $< $(CFLAGS_SHARED)
-src/%.o: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag
+src/%.o: $(SOURCE_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag
$(CC) -c -o $@ $< $(CFLAGS_STATIC)
lib/%$(OS_LIB_SUFFIX)$(VER_XYZ):
@@ -220,7 +221,7 @@ host.tag: Makefile
version.tag: $(GIT_REFERENCE_INDEX)
$(PROJECT_DIR)/sysinfo/version.sh \
- -s $(PROJECT_DIR) \
+ -s $(SOURCE_DIR) \
-o build/$(PACKAGE)_version.h \
-p $(PACKAGE)
touch version.tag
diff --git a/config.usage b/config.usage
index 47599e9..4a351e4 100644
--- a/config.usage
+++ b/config.usage
@@ -6,6 +6,7 @@ supported switches:
--nickname
--avoid-version
+ --source-dir
--prefix
--exec-prefix
@@ -47,6 +48,7 @@ supported switches:
supported variables:
--------------------
NICKNAME
+ SOURCE_DIR
PREFIX
EXEC_PREFIX
diff --git a/configure b/configure
index 6894bc6..6875689 100755
--- a/configure
+++ b/configure
@@ -33,13 +33,9 @@ init_vars()
. "$mb_config" || exit 2
fi
- # git
- if [ -d "$mb_project_dir/.git" ]; then
- mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
- fi
-
# project
mb_nickname=$NICKNAME
+ mb_source_dir=$SOURCE_DIR
# dirs
mb_prefix=$PREFIX
@@ -124,10 +120,33 @@ verify_build_directory()
}
+verify_source_directory()
+{
+ if [ -z "$mb_source_dir" ]; then
+ if [ "$mb_require_source_dir" = yes ]; then
+ error_msg "$mb_package: specifying an external source directory is required."
+ error_msg "you can set the source directory either via --source-dir=<path>,"
+ error_msg "or by setting the SOURCE_DIR variable."
+ exit 2
+ fi
+ fi
+}
+
+
common_defaults()
{
+ # git
+ if [ -n "$mb_source_dir" ]; then
+ if [ -d "$mb_source_dir/.git" ]; then
+ mb_git_reference_dir="\$(SOURCE_DIR)/.git"
+ fi
+ elif [ -d "$mb_project_dir/.git" ]; then
+ mb_git_reference_dir="\$(PROJECT_DIR)/.git"
+ fi
+
# project
[ -z "$mb_nickname" ] && mb_nickname=$mb_package
+ [ -z "$mb_source_dir" ] && mb_source_dir=$mb_project_dir
[ -z "$mb_avoid_version" ] && mb_avoid_version='no'
# dirs
@@ -370,6 +389,7 @@ config_copy()
sed -e 's^@package@^'"$mb_package"'^g' \
-e 's^@nickname@^'"$mb_nickname"'^g' \
-e 's^@project_dir@^'"$mb_project_dir"'^g' \
+ -e 's^@source_dir@^'"$mb_source_dir"'^g' \
-e 's^@git_reference_index@^'"$mb_git_reference_index"'^g' \
-e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \
-e 's^@avoid_version@^'"$mb_avoid_version"'^g' \
@@ -604,6 +624,9 @@ for arg ; do
--avoid-version)
mb_avoid_version='yes'
;;
+ --source-dir=*)
+ mb_source_dir=${arg#*=}
+ ;;
*)
error_msg ${arg#}: "unsupported config argument."
@@ -614,14 +637,19 @@ done
-# three: defaults
+# three: validation
+verify_source_directory
+
+
+
+# four: defaults
common_defaults
native_defaults
cross_defaults
-# four: config
+# five: config
config_flags
config_copy
config_support