New makefile.
This commit is contained in:
parent
ee118a497f
commit
30030fc949
135
Makefile
Normal file
135
Makefile
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
PACKAGE = 'networkctl'
|
||||||
|
VERSION = '0.0.1'
|
||||||
|
|
||||||
|
PREFIX := /usr/local
|
||||||
|
BINDIR := $(PREFIX)/bin
|
||||||
|
LIBDIR := $(PREFIX)/lib
|
||||||
|
SHAREDIR := $(PREFIX)/share
|
||||||
|
INCLUDEDIR := $(PREFIX)/include
|
||||||
|
MANDIR := $(SHAREDIR)/man
|
||||||
|
|
||||||
|
CC := cc
|
||||||
|
AR := ar
|
||||||
|
RANLIB := ranlib
|
||||||
|
CFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
Q := @
|
||||||
|
|
||||||
|
all: networkctl
|
||||||
|
@:
|
||||||
|
|
||||||
|
networkctl: src/main.cr
|
||||||
|
@echo '[01;35m CR > [01;37mnetworkctl[00m'
|
||||||
|
$(Q)crystal build --release $(CRFLAGS) src/main.cr -o 'networkctl'
|
||||||
|
|
||||||
|
|
||||||
|
networkctl.install: networkctl
|
||||||
|
@echo '[01;31m IN > [01;37m$(BINDIR)/networkctl[00m'
|
||||||
|
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
|
||||||
|
$(Q)install -m0755 networkctl $(DESTDIR)$(BINDIR)/networkctl
|
||||||
|
|
||||||
|
networkctl.clean:
|
||||||
|
@echo '[01;37m RM > [01;37mnetworkctl[00m'
|
||||||
|
$(Q)rm -f networkctl
|
||||||
|
|
||||||
|
networkctl.uninstall:
|
||||||
|
@echo '[01;37m RM > [01;37m$(BINDIR)/networkctl[00m'
|
||||||
|
$(Q)rm -f '$(DESTDIR)$(BINDIR)/networkctl'
|
||||||
|
|
||||||
|
$(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 networkctl.install
|
||||||
|
@:
|
||||||
|
|
||||||
|
subdirs.install:
|
||||||
|
|
||||||
|
uninstall: subdirs.uninstall networkctl.uninstall
|
||||||
|
@:
|
||||||
|
|
||||||
|
subdirs.uninstall:
|
||||||
|
|
||||||
|
test: all subdirs subdirs.test
|
||||||
|
@:
|
||||||
|
|
||||||
|
subdirs.test:
|
||||||
|
|
||||||
|
clean: networkctl.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/main.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/main.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/main.cr
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo '[01;37m :: networkctl-0.0.1[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 ''
|
||||||
|
@echo '[01;37mProject targets: [00m'
|
||||||
|
@echo ' - [01;33mnetworkctl [37m crystal[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
|
||||||
|
|
8
project.zsh
Normal file
8
project.zsh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
package=networkctl
|
||||||
|
version=0.0.1
|
||||||
|
|
||||||
|
targets=(networkctl)
|
||||||
|
type[networkctl]=crystal
|
||||||
|
sources[networkctl]=src/main.cr
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
file_option : String? = nil
|
file_option : String? = nil
|
||||||
|
|
||||||
OptionParser.parse! do |parser|
|
OptionParser.parse do |parser|
|
||||||
parser.on "-s", "--simulation", "Export the network configuration." do
|
parser.on "-s", "--simulation", "Export the network configuration." do
|
||||||
Context.simulation = true
|
Context.simulation = true
|
||||||
end
|
end
|
||||||
|
13
src/indent.cr
Normal file
13
src/indent.cr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
def indent(n : Int, text : String)
|
||||||
|
String.build do |str|
|
||||||
|
text.split("\n").each do |line|
|
||||||
|
n.times do
|
||||||
|
str << "\t"
|
||||||
|
end
|
||||||
|
|
||||||
|
str << line
|
||||||
|
str << "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
10
src/tests.cr
Normal file
10
src/tests.cr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
require "./indent"
|
||||||
|
|
||||||
|
str = "truc
|
||||||
|
sur
|
||||||
|
plusieurs
|
||||||
|
lignes"
|
||||||
|
|
||||||
|
indented = indent 2, str
|
||||||
|
|
||||||
|
puts indented
|
Loading…
Reference in New Issue
Block a user