Former-commit-id:a02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]] Former-commit-id:06a8b51d6d
Former-commit-id:3360eb6c5f
123 lines
No EOL
3.3 KiB
Text
123 lines
No EOL
3.3 KiB
Text
# makefile.dist creates a tar archive of all files within the
|
|
# build directory given by the environment variable BUILD_DIR
|
|
|
|
# files to be included are specified in an include_files.txt file
|
|
# file arrangement is controlled by the arrange_files.sh script
|
|
|
|
.SILENT:
|
|
|
|
# include optional user defined variables
|
|
-include makefile.conf~
|
|
|
|
tar_archive=$$(basename $(BUILD_DIR)).tar
|
|
tmp_location=tmp~/$$(basename $(BUILD_DIR))
|
|
setup_dir=setup
|
|
uninstall_script=$$(basename $(realpath .))_uninstall.sh
|
|
permissions_script=$$(basename $(realpath .))_permissions.sh
|
|
|
|
ifndef INSTALL_DIR
|
|
INSTALL_DIR = $(HOME)/opt/$$(basename $(realpath .))
|
|
endif
|
|
|
|
init:
|
|
ifndef BUILD_DIR
|
|
echo BUILD_DIR is not defined
|
|
exit 1
|
|
endif
|
|
|
|
_all: init
|
|
# copy files from build_dir into tmp_location
|
|
mkdir -p $(tmp_location)
|
|
rsync -mau --include='*/' --include-from=include_files.txt \
|
|
--exclude='*' $(BUILD_DIR)/ $(tmp_location)
|
|
|
|
# remove _keep_me directory placeholders
|
|
find $(tmp_location) -name "_keep_me" -exec rm {} \;
|
|
|
|
# arrange the files
|
|
$$(export tmp_location=$(tmp_location);bash arrange_files.sh)
|
|
|
|
# create setup directory for install/uninstall files
|
|
mkdir -p $(tmp_location)/$(setup_dir)
|
|
|
|
# finished
|
|
|
|
all: clean _all _permissions_script _uninstall_script
|
|
|
|
_permissions_script:
|
|
# create permissions_script
|
|
$(MAKE) PERMISSIONS_ROOT=$(tmp_location) \
|
|
-f ../build.native/makefile.perm _create_permissions_script
|
|
sed "s|$(tmp_location)|..|" file_permissions.sh > \
|
|
$(tmp_location)/$(setup_dir)/$(permissions_script)
|
|
chmod a+x $(tmp_location)/$(setup_dir)/$(permissions_script)
|
|
rm file_permissions.sh
|
|
|
|
_uninstall_script:
|
|
# create uninstall_script
|
|
$$(cd $(tmp_location)/$(setup_dir);\
|
|
echo "cd \$$(dirname \$$0)" > $(uninstall_script);\
|
|
find ../ -type f -exec echo rm -f {} \; >> $(uninstall_script);\
|
|
find ../ -type l -exec echo unlink {} \; >> $(uninstall_script);\
|
|
find ../ -depth -type d -exec echo rmdir {} \; >> $(uninstall_script);\
|
|
echo "exit 0" >> $(uninstall_script);\
|
|
chmod a+x $(uninstall_script)\
|
|
)
|
|
|
|
clean: init
|
|
# rm tmp_location
|
|
rm -fr $(tmp_location)
|
|
# finished
|
|
|
|
install: init all
|
|
# copy files from tmp_location to install_dir
|
|
mkdir -p $(INSTALL_DIR)
|
|
rsync -au $(tmp_location)/ $(INSTALL_DIR)
|
|
# finished
|
|
|
|
uninstall: init
|
|
# call uninstall_script
|
|
$(INSTALL_DIR)/$(setup_dir)/$(uninstall_script)
|
|
# finished
|
|
|
|
dist: init all _tar_archive
|
|
|
|
_clean_tar_archive:
|
|
# rm tar_archive
|
|
rm -fr $(tar_archive)
|
|
# finished
|
|
|
|
_tar_archive:
|
|
# create tar_archive
|
|
tar -cvf $(tar_archive) -C $(tmp_location) .
|
|
# finished
|
|
|
|
distupdate: init update _clean_tar_archive _tar_archive
|
|
|
|
distclean: init clean _clean_tar_archive
|
|
|
|
distinstall: init
|
|
# untar tar_archive into install_dir
|
|
mkdir -p $(INSTALL_DIR)
|
|
tar -xpf $(tar_archive) -C $(INSTALL_DIR)
|
|
# finished
|
|
|
|
_update: init clean
|
|
# untar tar_archive
|
|
mkdir -p $(tmp_location)_tar
|
|
tar -xpf $(tar_archive) -C $(tmp_location)_tar
|
|
|
|
_updated_tmp_location:
|
|
# copy files from _all step into extracted tar files
|
|
cp -fa $(tmp_location)/* $(tmp_location)_tar
|
|
|
|
# move $(tmp_location)_tar to $(tmp_location)
|
|
rm -fr $(tmp_location)
|
|
mv $(tmp_location)_tar $(tmp_location)
|
|
|
|
update: _update _all _updated_tmp_location _permissions_script _uninstall_script
|
|
|
|
.PHONY: init all _all clean install update _update dist distclean distinstall
|
|
|
|
# include optional user defined targets (and possible target overrides)
|
|
-include makefile.targets~ |