`package` can now be installed.
parent
99d1005fbb
commit
f1cf318708
|
@ -0,0 +1,191 @@
|
||||||
|
PACKAGE = 'package'
|
||||||
|
VERSION = '0.1.0'
|
||||||
|
|
||||||
|
PREFIX := /usr/local
|
||||||
|
BINDIR := $(PREFIX)/bin
|
||||||
|
LIBDIR := $(PREFIX)/lib
|
||||||
|
SHAREDIR := $(PREFIX)/share
|
||||||
|
INCLUDEDIR := $(PREFIX)/include
|
||||||
|
MANDIR := $(SHAREDIR)/man
|
||||||
|
LIBEXECDIR := $(PREFIX)/libexec
|
||||||
|
|
||||||
|
CC := cc
|
||||||
|
AR := ar
|
||||||
|
RANLIB := ranlib
|
||||||
|
CFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
Q := @
|
||||||
|
|
||||||
|
all: package assemble-apk.sh src/config.cr
|
||||||
|
@:
|
||||||
|
|
||||||
|
package: src/main.cr src/config.cr src/context.cr src/instructions.cr src/main.cr src/package.cr src/recipe.cr src/sources.cr src/config.cr
|
||||||
|
@echo '[01;35m CR > [01;37mpackage[00m'
|
||||||
|
$(Q)crystal src/main.cr -o 'package'
|
||||||
|
|
||||||
|
|
||||||
|
package.install: package
|
||||||
|
@echo '[01;31m IN > [01;37m$(BINDIR)/package[00m'
|
||||||
|
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||||
|
$(Q)install -m0755 package $(DESTDIR)$(BINDIR)/package
|
||||||
|
|
||||||
|
package.clean:
|
||||||
|
@echo '[01;37m RM > [01;37mpackage[00m'
|
||||||
|
$(Q)rm -f package
|
||||||
|
|
||||||
|
package.uninstall:
|
||||||
|
@echo '[01;37m RM > [01;37m$(BINDIR)/package[00m'
|
||||||
|
$(Q)rm -f '$(DESTDIR)$(BINDIR)/package'
|
||||||
|
|
||||||
|
assemble-apk.sh:
|
||||||
|
|
||||||
|
assemble-apk.sh.install: assemble-apk.sh
|
||||||
|
@echo '[01;31m IN > [01;37m$(LIBEXECDIR)/package/assemble-apk.sh[00m'
|
||||||
|
$(Q)mkdir -p '$(DESTDIR)$(LIBEXECDIR)/package'
|
||||||
|
$(Q)install -m0755 assemble-apk.sh $(DESTDIR)$(LIBEXECDIR)/package/assemble-apk.sh
|
||||||
|
|
||||||
|
assemble-apk.sh.clean:
|
||||||
|
|
||||||
|
assemble-apk.sh.uninstall:
|
||||||
|
@echo '[01;37m RM > [01;37m$(LIBEXECDIR)/package/assemble-apk.sh[00m'
|
||||||
|
$(Q)rm -f '$(DESTDIR)$(LIBEXECDIR)/package/assemble-apk.sh'
|
||||||
|
|
||||||
|
src/config.cr: src/config.cr.in src
|
||||||
|
@echo '[01;32m SED > [01;37msrc/config.cr[00m'
|
||||||
|
$(Q)sed -e 's&@PREFIX@&$(PREFIX)&;s&@BINDIR@&$(BINDIR)&;s&@LIBDIR@&$(LIBDIR)&;s&@SHAREDIR@&$(SHAREDIR)&;s&@INCLUDEDIR@&$(INCLUDEDIR)&;s&@MANDIR@&$(MANDIR)&;s&@LIBEXECDIR@&$(LIBEXECDIR)&;' src/config.cr.in > 'src/config.cr'
|
||||||
|
$(Q)chmod +x 'src/config.cr'
|
||||||
|
|
||||||
|
|
||||||
|
src/config.cr.install:
|
||||||
|
$(Q):
|
||||||
|
|
||||||
|
src/config.cr.clean:
|
||||||
|
@echo '[01;37m RM > [01;37msrc/config.cr[00m'
|
||||||
|
$(Q)rm -f src/config.cr
|
||||||
|
|
||||||
|
src/config.cr.uninstall:
|
||||||
|
@echo '[01;37m RM > [01;37mfalse/config.cr[00m'
|
||||||
|
$(Q)rm -f '$(DESTDIR)false/config.cr'
|
||||||
|
|
||||||
|
src:
|
||||||
|
$(Q)mkdir -p src
|
||||||
|
$(DESTDIR)$(PREFIX):
|
||||||
|
@echo '[01;35m DIR > [01;37m$(PREFIX)[00m'
|
||||||
|
$(Q)mkdir -p $(DESTDIR)$(PREFIX)
|
||||||
|
$(DESTDIR)$(BINDIR):
|
||||||
|
@echo '[01;35m DIR > [01;37m$(BINDIR)[00m'
|
||||||
|
$(Q)mkdir -p $(DESTDIR)$(BINDIR)
|
||||||
|
$(DESTDIR)$(LIBDIR):
|
||||||
|
@echo '[01;35m DIR > [01;37m$(LIBDIR)[00m'
|
||||||
|
$(Q)mkdir -p $(DESTDIR)$(LIBDIR)
|
||||||
|
$(DESTDIR)$(SHAREDIR):
|
||||||
|
@echo '[01;35m DIR > [01;37m$(SHAREDIR)[00m'
|
||||||
|
$(Q)mkdir -p $(DESTDIR)$(SHAREDIR)
|
||||||
|
$(DESTDIR)$(INCLUDEDIR):
|
||||||
|
@echo '[01;35m DIR > [01;37m$(INCLUDEDIR)[00m'
|
||||||
|
$(Q)mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
$(DESTDIR)$(MANDIR):
|
||||||
|
@echo '[01;35m DIR > [01;37m$(MANDIR)[00m'
|
||||||
|
$(Q)mkdir -p $(DESTDIR)$(MANDIR)
|
||||||
|
install: subdirs.install package.install assemble-apk.sh.install src/config.cr.install
|
||||||
|
@:
|
||||||
|
|
||||||
|
subdirs.install:
|
||||||
|
|
||||||
|
uninstall: subdirs.uninstall package.uninstall assemble-apk.sh.uninstall src/config.cr.uninstall
|
||||||
|
@:
|
||||||
|
|
||||||
|
subdirs.uninstall:
|
||||||
|
|
||||||
|
test: all subdirs subdirs.test
|
||||||
|
@:
|
||||||
|
|
||||||
|
subdirs.test:
|
||||||
|
|
||||||
|
clean: package.clean assemble-apk.sh.clean src/config.cr.clean
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
|
||||||
|
dist: dist-gz dist-xz dist-bz2
|
||||||
|
$(Q)rm -- $(PACKAGE)-$(VERSION)
|
||||||
|
|
||||||
|
distdir:
|
||||||
|
$(Q)rm -rf -- $(PACKAGE)-$(VERSION)
|
||||||
|
$(Q)ln -s -- . $(PACKAGE)-$(VERSION)
|
||||||
|
|
||||||
|
dist-gz: $(PACKAGE)-$(VERSION).tar.gz
|
||||||
|
$(PACKAGE)-$(VERSION).tar.gz: distdir
|
||||||
|
@echo '[01;33m TAR > [01;37m$(PACKAGE)-$(VERSION).tar.gz[00m'
|
||||||
|
$(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/config.cr.in \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/context.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/instructions.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/main.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/package.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/recipe.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/sources.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/config.cr
|
||||||
|
|
||||||
|
dist-xz: $(PACKAGE)-$(VERSION).tar.xz
|
||||||
|
$(PACKAGE)-$(VERSION).tar.xz: distdir
|
||||||
|
@echo '[01;33m TAR > [01;37m$(PACKAGE)-$(VERSION).tar.xz[00m'
|
||||||
|
$(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/config.cr.in \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/context.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/instructions.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/main.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/package.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/recipe.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/sources.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/config.cr
|
||||||
|
|
||||||
|
dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
|
||||||
|
$(PACKAGE)-$(VERSION).tar.bz2: distdir
|
||||||
|
@echo '[01;33m TAR > [01;37m$(PACKAGE)-$(VERSION).tar.bz2[00m'
|
||||||
|
$(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/config.cr.in \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/context.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/instructions.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/main.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/package.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/recipe.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/sources.cr \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/config.cr
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo '[01;37m :: package-0.1.0[00m'
|
||||||
|
@echo ''
|
||||||
|
@echo '[01;37mGeneric targets:[00m'
|
||||||
|
@echo '[00m - [01;32mhelp [37m Prints this help message.[00m'
|
||||||
|
@echo '[00m - [01;32mall [37m Builds all targets.[00m'
|
||||||
|
@echo '[00m - [01;32mdist [37m Creates tarballs of the files of the project.[00m'
|
||||||
|
@echo '[00m - [01;32minstall [37m Installs the project.[00m'
|
||||||
|
@echo '[00m - [01;32mclean [37m Removes compiled files.[00m'
|
||||||
|
@echo '[00m - [01;32muninstall [37m Deinstalls the project.[00m'
|
||||||
|
@echo ''
|
||||||
|
@echo '[01;37mCLI-modifiable variables:[00m'
|
||||||
|
@echo ' - [01;34mCC [37m ${CC}[00m'
|
||||||
|
@echo ' - [01;34mCFLAGS [37m ${CFLAGS}[00m'
|
||||||
|
@echo ' - [01;34mLDFLAGS [37m ${LDFLAGS}[00m'
|
||||||
|
@echo ' - [01;34mDESTDIR [37m ${DESTDIR}[00m'
|
||||||
|
@echo ' - [01;34mPREFIX [37m ${PREFIX}[00m'
|
||||||
|
@echo ' - [01;34mBINDIR [37m ${BINDIR}[00m'
|
||||||
|
@echo ' - [01;34mLIBDIR [37m ${LIBDIR}[00m'
|
||||||
|
@echo ' - [01;34mSHAREDIR [37m ${SHAREDIR}[00m'
|
||||||
|
@echo ' - [01;34mINCLUDEDIR [37m ${INCLUDEDIR}[00m'
|
||||||
|
@echo ' - [01;34mMANDIR [37m ${MANDIR}[00m'
|
||||||
|
@echo ' - [01;34mLIBEXECDIR [37m ${LIBEXECDIR}[00m'
|
||||||
|
@echo ''
|
||||||
|
@echo '[01;37mProject targets: [00m'
|
||||||
|
@echo ' - [01;33mpackage [37m crystal[00m'
|
||||||
|
@echo ' - [01;33massemble-apk.sh[37m script[00m'
|
||||||
|
@echo ''
|
||||||
|
@echo '[01;37mMakefile options:[00m'
|
||||||
|
@echo ' - gnu: false'
|
||||||
|
@echo ' - colors: true'
|
||||||
|
@echo ''
|
||||||
|
@echo '[01;37mRebuild the Makefile with:[00m'
|
||||||
|
@echo ' zsh ./build.zsh -c'
|
||||||
|
.PHONY: all subdirs clean distclean dist install uninstall help
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
package=package
|
||||||
|
version=0.1.0
|
||||||
|
|
||||||
|
variables+=(
|
||||||
|
LIBEXECDIR '$(PREFIX)/libexec'
|
||||||
|
)
|
||||||
|
|
||||||
|
targets=(package assemble-apk.sh)
|
||||||
|
|
||||||
|
type[package]=crystal
|
||||||
|
sources[package]=src/main.cr
|
||||||
|
depends[package]="$(echo src/*.cr | sed 's| src/config.cr||') src/config.cr"
|
||||||
|
|
||||||
|
type[assemble-apk.sh]=script
|
||||||
|
|
||||||
|
targets+=(src/config.cr)
|
||||||
|
type[src/config.cr]=script
|
||||||
|
sources[src/config.cr]=src/config.cr.in
|
||||||
|
auto[src/config.cr]=true # Don’t display it in `make help`.
|
||||||
|
install[src/config.cr]=false
|
||||||
|
|
||||||
|
# FIXME: Clean and upstream this.
|
||||||
|
function script.install {
|
||||||
|
if [[ false == "${install[$target]}" ]]; then
|
||||||
|
write "$target.install:"
|
||||||
|
write "\t${Q}:"
|
||||||
|
write
|
||||||
|
else
|
||||||
|
binary.install "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install[assemble-apk.sh]='$(LIBEXECDIR)/package'
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
# These values are changed by `make` at build-time.
|
||||||
|
OWN_LIBEXEC_DIR = "@LIBEXECDIR@/package"
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
require "./config.cr"
|
||||||
|
|
||||||
# FIXME: Where should this go? We can’t just leave it here. :(
|
# FIXME: Where should this go? We can’t just leave it here. :(
|
||||||
def pkginfo(package)
|
def pkginfo(package)
|
||||||
du = `du -sk #{package.fake_root_directory}`
|
du = `du -sk #{package.fake_root_directory}`
|
||||||
|
@ -92,7 +94,7 @@ class Package::Context
|
||||||
Dir.mkdir_p File.dirname package_target
|
Dir.mkdir_p File.dirname package_target
|
||||||
|
|
||||||
# FIXME: This shouldn’t have to be in users’ PATH. libexec?
|
# FIXME: This shouldn’t have to be in users’ PATH. libexec?
|
||||||
r = run package.fake_root_directory, "assemble-apk.sh", [
|
r = run package.fake_root_directory, "#{OWN_LIBEXEC_DIR}/assemble-apk.sh", [
|
||||||
package_target
|
package_target
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Reference in New Issue