Remove Makefile. Replace with Rakefile.

This commit is contained in:
Glenn Y. Rolland 2015-08-09 16:35:04 +02:00
parent ff5701250e
commit 457fec514e
2 changed files with 25 additions and 191 deletions

166
Makefile
View file

@ -1,166 +0,0 @@
NAME=qasim
DESTDIR=
DEV_DESTDIR=tmp
CONFDIR=$(DESTDIR)/etc
BINDIR=$(DESTDIR)/usr/bin
MANDIR=$(DESTDIR)/usr/share/man
DOCDIR=$(DESTDIR)/usr/share/doc
SHAREDIR=$(DESTDIR)/usr/share
RUBYVERSION=2.0
RDOC=rdoc$(RUBYVERSION)
all: \
build \
install
clean: \
clean-ui \
clean-qrc \
clean-bin \
clean-lib \
clean-data \
clean-doc
build: \
build-ui \
build-qrc \
build-bin \
build-lib \
build-data
doc: build-doc
install: \
install-ui \
install-qrc \
install-bin \
install-lib \
install-data
## DOC SECTION
install-doc:
# # install documentation
rm -fr $(DOCDIR)/$(NAME)
mkdir -p $(DOCDIR)/$(NAME)
cp -a doc $(DOCDIR)/$(NAME)
## QRC -> QRC_RB SECTION
QRC_FILES=$(wildcard lib/$(NAME)/*.qrc)
RBQRC_FILES=$(patsubst %.qrc,%_qrc.rb,$(QRC_FILES))
clean-qrc:
rm -f $(RBQRC_FILES)
build-qrc: $(RBQRC_FILES)
echo $(RBQRC_FILES)
install-qrc: $(RBQRC_FILES)
# FIXME install qrc
%_qrc.rb: %.qrc
rbrcc $< -o $@
## UI -> UI_RB SECTION
UI_FILES=$(wildcard lib/$(NAME)/ui/*.ui)
RBUI_FILES=$(patsubst %.ui,%_ui.rb,$(UI_FILES))
clean-ui:
rm -f $(RBUI_FILES)
build-ui: $(RBUI_FILES)
echo $(RBUI_FILES)
install-ui: $(RBUI_FILES)
# FIXME install
%_ui.rb: %.ui
rbuic4 $< -o $@
sed -e '/^module Ui/,/^end # module Ui/d' \
-i $@
## BINARY SECTION
clean-bin:
# remove external packages
rm -fr vendor/bundle
build-bin:
install-bin:
env |sort
mkdir -p $(BINDIR)
for binfile in bin/*.rb ; do \
BINFILE=`basename $$binfile |sed -e 's/.rb$$//'`; \
install -D -o root -g root -m 755 $$binfile $(BINDIR)/$$BINFILE; \
sed -i -e 's|^QASIM_INCLUDE_DIR.*|QASIM_INCLUDE_DIR = "$(SHAREDIR)/$(NAME)/lib"|' $(BINDIR)/$$BINFILE; \
sed -i -e 's|^QASIM_DATA_DIR.*|QASIM_DATA_DIR = "$(SHAREDIR)/$(NAME)"|' $(BINDIR)/$$BINFILE; \
done
#install -D -o root -g root -m 755 $(CURDIR)/bin/$(NAME)-gui.rb $(BINDIR)/$(NAME)-gui
## LIB SECTION
clean-lib:
build-lib:
install-lib:
IFS="" find lib -name '*.rb' | while read libfile ; do \
install -D -o root -g root -m 644 $$libfile $(SHAREDIR)/$(NAME)/$$libfile; \
done
## DATA SECTION
clean-data:
build-data:
install-data:
## Install man pages
mkdir -p $(MANDIR)/man1
for binfile in bin/*.rb ; do \
BINFILE=`basename $$binfile |sed -e 's/.rb$$//'`; \
cat man/$${BINFILE}.1 | gzip > $(MANDIR)/man1/$${BINFILE}.1.gz ; \
done
#
## Install icons
mkdir -p $(SHAREDIR)/$(NAME)/icons
install -D -o root -g root -m 644 $(CURDIR)/data/icons/$(NAME).svg \
$(SHAREDIR)/$(NAME)/icons/$(NAME).svg
#
## Install completion file
# install -D -o root -g root -m 644 $(CURDIR)/$(NAME).completion $(DESTDIR)/etc/bash_completion.d/$(NAME)
#
## Install configuration files
mkdir -p $(CONFDIR)/xdg/autostart
install -D -o root -g root -m 644 $(CURDIR)/conf/$(NAME).desktop \
$(CONFDIR)/xdg/autostart/$(NAME).desktop
install -D -o root -g root -m 644 $(CURDIR)/conf/$(NAME).desktop \
$(SHAREDIR)/applications/$(NAME).desktop
mkdir -p $(CONFDIR)/$(NAME)
install -D -o root -g root -m 644 $(CURDIR)/conf/config \
$(CONFDIR)/$(NAME)/config
install -D -o root -g root -m 644 $(CURDIR)/conf/default.map \
$(CONFDIR)/$(NAME)/default.map
#
# Install examples
mkdir -p $(DOCDIR)/$(NAME)/examples
for f in `ls examples`; do \
cat examples/$$f | gzip -f9 > $(DOCDIR)/$(NAME)/examples/$$f.gz ; \
done
## OTHER
.PHONY: destdir
dev-install:
rm -fr $(DEV_DESTDIR)
fakeroot $(MAKE) install DESTDIR=$(DEV_DESTDIR)

View file

@ -13,6 +13,7 @@ RDOC="rdoc#{RUBYVERSION}"
QRC_FILES=Dir.glob("lib/#{NAME}/*.qrc") QRC_FILES=Dir.glob("lib/#{NAME}/*.qrc")
RBQRC_FILES=QRC_FILES.map{ |f| f.sub(/\.qrc$/,'_qrc.rb') } RBQRC_FILES=QRC_FILES.map{ |f| f.sub(/\.qrc$/,'_qrc.rb') }
RBQRC_TO_QRC = lambda{|f| f.gsub(/_qrc\.rb/,'.qrc') }
UI_FILES=Dir.glob("lib/#{NAME}/ui/*.ui") UI_FILES=Dir.glob("lib/#{NAME}/ui/*.ui")
RBUI_FILES=UI_FILES.map{ |f| f.sub(/\.ui$/,'_ui.rb') } RBUI_FILES=UI_FILES.map{ |f| f.sub(/\.ui$/,'_ui.rb') }
@ -21,16 +22,13 @@ require 'rake'
#Rake.application.options.trace_rules = true #Rake.application.options.trace_rules = true
desc "Do everything" desc "Default task (build)"
task :all => [:build, :install] task :all => :build
desc "Clean everything" desc "Clean everything"
task :clean => [ task :clean => [
:"ui:clean", :"ui:clean",
:"qrc:clean", :"qrc:clean",
#:clean_bin,
#:clean_lib,
#:clean_data,
:"gem:clean" :"gem:clean"
] ]
@ -38,37 +36,37 @@ desc "Build everything"
task :build => [ task :build => [
:"ui:build", :"ui:build",
:"qrc:build", :"qrc:build",
#:build_bin, :"doc:build",
#:build_lib,
#:build_data,
:"gem:build" :"gem:build"
] ]
desc "Install everything"
task :install => [
#:"ui:install",
#:"qrc:install",
#:install_bin,
#:install_lib,
#:install_data
]
desc "Build documentation" namespace :data do
task :doc => [:build_doc] task :build do
task :clean_doc do
rm_rf doc
end end
task :build_doc => :clean_doc do task :clean do
end
end
namespace :doc do
task :clean do
rm_rf "doc"
end
task :build => :clean do
sh %Q{#{RDOC} sh %Q{#{RDOC}
--promiscuous --promiscuous
--inline-source --inline-source
--line-numbers --line-numbers
-o doc lib/$(NAME)/ -o doc
lib/#{NAME}/
bin/ bin/
} }
end end
end
namespace :qrc do namespace :qrc do
desc "Clean QRC files" desc "Clean QRC files"
@ -81,11 +79,12 @@ namespace :qrc do
puts RBQRC_FILES puts RBQRC_FILES
end end
rule "_qrc.rb" => lambda{|f| f.gsub(/_qrc\.rb/,'.qrc') } do |t| rule "_qrc.rb" => RBQRC_TO_QRC do |t|
sh %Q{rbrcc #{t.source} -o #{t.name}} sh %Q{rbrcc #{t.source} -o #{t.name}}
end end
end end
namespace :ui do namespace :ui do
desc "Clean UI files" desc "Clean UI files"
task :clean do task :clean do
@ -113,6 +112,7 @@ namespace :gem do
end end
end end
require "bundler/gem_tasks" require "bundler/gem_tasks"
require 'rake/testtask' require 'rake/testtask'