diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d38c149c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +*~ diff --git a/Makefile b/Makefile index aa71aa08..4387c7a7 100644 --- a/Makefile +++ b/Makefile @@ -1,57 +1,108 @@ - -PYTHON_VERSION=2.7 -PYTHON_LIBS=FindPackage GetAvailable GuessLatest CheckDependencies DescribeProgram UseFlags Corrections -PYTHON_SITE=lib/python$(PYTHON_VERSION)/site-packages PROGRAM=Scripts VERSION=git-$(shell date +%Y%m%d) goboPrograms?=/Programs PREFIX?= -DESTDIR=$(goboPrograms)/$(PROGRAM)/$(VERSION) +DESTDIR=$(PREFIX)/$(goboPrograms)/$(PROGRAM)/$(VERSION) -man_files = $(shell cd bin; grep -l Parse_Options * | xargs -i echo share/man/man1/{}.1) -exec_files = $(patsubst src/%.c,bin/%,$(wildcard src/*.c)) +INSTALL_FILE = install +INSTALL_DIR = install -d -all: python $(exec_files) manuals +PYTHON_VERSION=2.7 +PYTHON_LIBS=FindPackage GetAvailable GuessLatest CheckDependencies DescribeProgram UseFlags Corrections +PYTHON_SITE=python$(PYTHON_VERSION)/site-packages -debug: python - cd src; $(MAKE) debug +RUBY_VERSION=1.8 +RUBY_SITE=ruby/site_ruby/$(RUBY_VERSION) +RUBY_DIR=$(RUBY_SITE)/gobo + +MAN_FILES = $(shell cd bin;grep -l Parse_Options * | xargs -i echo share/man/man1/{}.1) +EXEC_FILES = $(patsubst src/%.c,%,$(wildcard src/*.c)) +SCRIPT_FILES = AddUser AttachProgram DeduceName FindPackage GoboPath install PrioritiseUpdates ScriptFunctions UnversionExecutables VersionExecutables Alien AugmentCommandNotFoundDatabase Dependencies FindQuick GrepQuick InstallPackage ProblemReport SignProgram UpdateKdeRecipe which Alien-Cabal CheckDependants DescribeProgram FixAttributes GrepReplace KillProcess RemoveBroken SuggestDuplicates UpdateSettings xmlcatalog Alien-CPAN CheckDependencies DetachProgram FixDirReferences GuessLatest ListProgramFiles RemoveEmpty SuggestUpdates UpdateXorgRecipe Alien-LuaRocks CleanModules DisableProgram FixInfo GuessProgramCase RemoveProgram SymlinkProgram UpgradeSystem Alien-PIP Corrections FilterColors GenBuildInformation HasCompatiblePackage MergeTree Rename SystemFind UseFlags Alien-RubyGems CreatePackage FilterLines GetAvailable Hashes NamingConventions RescueInstallPackage SystemInfo VerifyProgram + +.PHONY: all clean install + +all: python manuals + @$(MAKE) -C src + $(foreach EXE_FILE, $(EXEC_FILES), \ + cp -af src/$(EXE_FILE) bin ; \ + chmod a+x bin/$(EXE_FILE) ; \ + ) python: - for f in $(PYTHON_LIBS); \ - do libf=$(PYTHON_SITE)/$$f.py; \ - rm -f $$libf; ln -nfs ../../../bin/$$f $$libf; \ - done - cd $(PYTHON_SITE) && \ + mkdir -p lib/$(PYTHON_SITE) + $(foreach PYTHON_LIB, $(PYTHON_LIBS), \ + ln -nfs ../../../bin/$(PYTHON_LIB) lib/$(PYTHON_SITE)/$(PYTHON_LIB).py ; \ + ) + cp lib/python/*.py lib/$(PYTHON_SITE) + cd lib/$(PYTHON_SITE) && \ for f in *.py; \ - do python -c "import `basename $$f .py`"; \ + do python -c "import `basename $$f .py`"; \ done -clean: - rm -rf Resources/FileHash* - find * -path "*~" -or -path "*/.\#*" -or -path "*.bak" | xargs rm -f - cd src && $(MAKE) clean - cd $(PYTHON_SITE) && rm -f *.pyc *.pyo - rm -f $(exec_files) +python_clean: + rm -rf lib/$(dir $(PYTHON_SITE)) + +clean: python_clean + @$(MAKE) -C src clean + @echo "Cleaning man pages" rm -rf share/man/man1 + @echo "Cleaning binaries" + $(foreach EXE_FILE, $(EXEC_FILES), \ + rm -f src/$(EXE_FILE) ; \ + rm -f bin/$(EXE_FILE) ; \ + ) + rm -rf Resources/FileHash* + +python_install: python + @echo "Installing python libraries" + mkdir -p $(DESTDIR)/lib/$(dir $(PYTHON_SITE)) + cp -r lib/$(dir $(PYTHON_SITE)) $(DESTDIR)/lib -manuals: $(man_files) +ruby_install: + @echo "Installing ruby libraries" + $(INSTALL_DIR) -d -m 755 $(DESTDIR)/lib/$(RUBY_SITE) + cp -r lib/$(RUBY_DIR) $(DESTDIR)/lib/$(RUBY_SITE) -$(man_files): share/man/man1/%.1: bin/% +$(MAN_FILES): share/man/man1/%.1: bin/% @mkdir -p share/man/man1 help2man --name=" " --source="GoboLinux" --no-info $< --output $@ -$(exec_files): bin/%: src/% - cp -af $< $@ - chmod a+x $@ +manuals: $(MAN_FILES) + +install_manuals: $(MAN_FILES) + $(INSTALL_DIR) -d -m 755 $(DESTDIR)/share/man/man1 + $(foreach MAN_FILE, $(MAN_FILES), \ + $(INSTALL_FILE) -m 644 $(MAN_FILE) $(DESTDIR)/share/man/man1 ; \ + ) + +install_scripts: + @echo "Installing scripts" + $(INSTALL_DIR) -d -m 755 $(DESTDIR)/bin + $(foreach SCRIPT_FILE, $(SCRIPT_FILES), \ + $(INSTALL_FILE) -m 755 bin/$(SCRIPT_FILE) $(DESTDIR)/bin ; \ + ) + +install_data: + @echo "Installing Data" + $(INSTALL_DIR) -d -m 755 $(DESTDIR)/Data + cp -r Data $(DESTDIR) + +install_resources: + @echo "Installing Resources" + cp -r Resources $(DESTDIR) + +install_share_data: + @echo "Installing share data" + cp -rf share $(DESTDIR) -src/%: src/%.c - $(MAKE) -C src +install_functions: + @echo "Installing Functions" + cp -rf Functions $(DESTDIR) -.PHONY: all python manuals debug clean +prepare_install: + @echo "Installing $(PROGRAM) into $(DESTDIR)" + $(INSTALL_DIR) -m 755 $(DESTDIR) -install: python $(exec_files) manuals - @echo "Installing Scripts into $(PREFIX)/$(DESTDIR)" - @install -d -m 755 $(PREFIX)/$(DESTDIR) - @echo "Copying files ..." - @./bin/ListProgramFiles `pwd` | grep -v "^src" | grep -v "^Makefile" | \ - cpio --pass-through --quiet --verbose --unconditional $(PREFIX)/$(DESTDIR) +install: all prepare_install install_scripts install_data install_resources install_share_data install_functions python_install ruby_install install_manuals + @$(MAKE) DESTDIR=$(DESTDIR) -C src install + @echo "Installed $(PROGRAM) into $(DESTDIR)" diff --git a/lib/python2.7/site-packages/Alien.py b/lib/python/Alien.py similarity index 100% rename from lib/python2.7/site-packages/Alien.py rename to lib/python/Alien.py diff --git a/lib/python2.7/site-packages/GuessProgramCase.py b/lib/python/GuessProgramCase.py similarity index 100% rename from lib/python2.7/site-packages/GuessProgramCase.py rename to lib/python/GuessProgramCase.py diff --git a/lib/python2.7/site-packages/PythonUtils.py b/lib/python/PythonUtils.py similarity index 100% rename from lib/python2.7/site-packages/PythonUtils.py rename to lib/python/PythonUtils.py diff --git a/lib/python2.7/site-packages/Corrections.py b/lib/python2.7/site-packages/Corrections.py deleted file mode 120000 index dacbb2f7..00000000 --- a/lib/python2.7/site-packages/Corrections.py +++ /dev/null @@ -1 +0,0 @@ -../../../bin/Corrections \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 7afb4672..182a5458 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,55 +1,74 @@ - -MYCFLAGS = -O2 -Wall +DESTDIR?= CC = gcc +CFLAGS = -O2 -Wall +INSTALL_FILE=install -s +INSTALL_DIR=install -d -STATIC=-static -ifeq ($(shell uname -s),Darwin) - STATIC= -endif - +# Running on windows IS_CYGWIN=$(shell uname | grep -i cygwin &>/dev/null && echo yes || echo no) ifeq ($(IS_CYGWIN),yes) RM_EXE=-rm -f *.exe endif +STATIC_CFLAGS = $(CFLAGS) -static +ifneq ($(shell uname -s),Darwin) + STATIC_CFLAGS = $(CFLAGS) +endif + +# Add compiler options +ifdef DEBUG + CFLAGS += -g -DDEBUG + STATIC_CFLAGS += -g -DDEBUG + INSTALL_FILE=install +endif + +exec_files = $(patsubst %.c,%,$(wildcard *.c)) + dynamic_exec = BackgroundExec SuperUserName IsExecutable usleep LinkOrExpandAll List CommandNotFound GetSupportedFilesystems static_exec = RescueSymlinkProgram other_exec = FindDependencies Runner # first rule -default: all -.PHONY: all default +.PHONY: all clean static debug install all: $(dynamic_exec) $(static_exec) $(other_exec) $(dynamic_exec): %: %.c - $(CC) $(MYCFLAGS) $< -o $@ - @if [ -e "$@.exe" ]; then \ + @echo "Compiling $@" + $(CC) $(CFLAGS) $< -o $@ + if [ -e "$@.exe" ]; then \ mv $@.exe $@; \ fi $(static_exec): %: %.c - $(CC) $(MYCFLAGS) $< -o $@ $(STATIC) - @if [ -e "$@.exe" ]; then \ + @echo "Compiling $@" + $(CC) $(STATIC_CFLAGS) $< -o $@ + if [ -e "$@.exe" ]; then \ mv $@.exe $@; \ fi FindDependencies: %: %.c - $(CC) $(MYCFLAGS) $< -o $@ -DBUILD_MAIN + @echo "Compiling $@" + $(CC) $(CFLAGS) $< -o $@ -DBUILD_MAIN Runner: Runner.c FindDependencies.c - $(CC) $(MYCFLAGS) $^ -o $@ - chmod 4755 $@ - -debug: MYCFLAGS = -g -DDEBUG -Wall -debug: all - -static: MYCFLAGS = $(STATIC) -static: all + @echo "Compiling $@" + $(CC) $(CFLAGS) $^ -o $@ clean: + @echo "Cleaning sources" rm -f $(dynamic_exec) $(static_exec) $(other_exec) lib*.so lib*.so.* *.o $(RM_EXE) -.PHONY: all clean static debug install +install: all + @echo "Installing compiled binaries" +ifndef DESTDIR + $(error DESTDIR is not set) +endif + $(INSTALL_DIR) -d -m 755 $(DESTDIR)/bin + $(foreach EXEC_FILE, $(exec_files), \ + $(INSTALL_FILE) -m 755 $(EXEC_FILE) $(DESTDIR)/bin ; \ + ) + chmod 4755 $(DESTDIR)/bin/Runner +