1
0
mirror of https://git.baguette.netlib.re/Baguette/networkctl synced 2024-12-18 13:03:30 +00:00

New makefile.

This commit is contained in:
Philippe PITTOLI 2019-11-05 01:13:57 +01:00
parent ee118a497f
commit 30030fc949
5 changed files with 167 additions and 1 deletions

135
Makefile Normal file
View 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 ' CR > networkctl'
$(Q)crystal build --release $(CRFLAGS) src/main.cr -o 'networkctl'


networkctl.install: networkctl
@echo ' IN > $(BINDIR)/networkctl'
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
$(Q)install -m0755 networkctl $(DESTDIR)$(BINDIR)/networkctl

networkctl.clean:
@echo ' RM > networkctl'
$(Q)rm -f networkctl

networkctl.uninstall:
@echo ' RM > $(BINDIR)/networkctl'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/networkctl'

$(DESTDIR)$(PREFIX):
@echo ' DIR > $(PREFIX)'
$(Q)mkdir -p $(DESTDIR)$(PREFIX)
$(DESTDIR)$(BINDIR):
@echo ' DIR > $(BINDIR)'
$(Q)mkdir -p $(DESTDIR)$(BINDIR)
$(DESTDIR)$(LIBDIR):
@echo ' DIR > $(LIBDIR)'
$(Q)mkdir -p $(DESTDIR)$(LIBDIR)
$(DESTDIR)$(SHAREDIR):
@echo ' DIR > $(SHAREDIR)'
$(Q)mkdir -p $(DESTDIR)$(SHAREDIR)
$(DESTDIR)$(INCLUDEDIR):
@echo ' DIR > $(INCLUDEDIR)'
$(Q)mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(DESTDIR)$(MANDIR):
@echo ' DIR > $(MANDIR)'
$(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 ' TAR > $(PACKAGE)-$(VERSION).tar.gz'
$(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \
$(PACKAGE)-$(VERSION)/src/main.cr

dist-xz: $(PACKAGE)-$(VERSION).tar.xz
$(PACKAGE)-$(VERSION).tar.xz: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.xz'
$(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \
$(PACKAGE)-$(VERSION)/src/main.cr

dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
$(PACKAGE)-$(VERSION).tar.bz2: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.bz2'
$(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \
$(PACKAGE)-$(VERSION)/src/main.cr

help:
@echo ' :: networkctl-0.0.1'
@echo ''
@echo 'Generic targets:'
@echo ' - help  Prints this help message.'
@echo ' - all  Builds all targets.'
@echo ' - dist  Creates tarballs of the files of the project.'
@echo ' - install  Installs the project.'
@echo ' - clean  Removes compiled files.'
@echo ' - uninstall  Deinstalls the project.'
@echo ''
@echo 'CLI-modifiable variables:'
@echo ' - CC  ${CC}'
@echo ' - CFLAGS  ${CFLAGS}'
@echo ' - LDFLAGS  ${LDFLAGS}'
@echo ' - DESTDIR  ${DESTDIR}'
@echo ' - PREFIX  ${PREFIX}'
@echo ' - BINDIR  ${BINDIR}'
@echo ' - LIBDIR  ${LIBDIR}'
@echo ' - SHAREDIR  ${SHAREDIR}'
@echo ' - INCLUDEDIR  ${INCLUDEDIR}'
@echo ' - MANDIR  ${MANDIR}'
@echo ''
@echo 'Project targets: '
@echo ' - networkctl  crystal'
@echo ''
@echo 'Makefile options:'
@echo ' - gnu: false'
@echo ' - colors: true'
@echo ''
@echo 'Rebuild the Makefile with:'
@echo ' zsh ./build.zsh -c'
.PHONY: all subdirs clean distclean dist install uninstall help

8
project.zsh Normal file
View File

@ -0,0 +1,8 @@

package=networkctl
version=0.0.1

targets=(networkctl)
type[networkctl]=crystal
sources[networkctl]=src/main.cr

View File

@ -1,7 +1,7 @@

file_option : String? = nil

OptionParser.parse! do |parser|
OptionParser.parse do |parser|
parser.on "-s", "--simulation", "Export the network configuration." do
Context.simulation = true
end

13
src/indent.cr Normal file
View 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
View File

@ -0,0 +1,10 @@
require "./indent"

str = "truc
sur
plusieurs
lignes"

indented = indent 2, str

puts indented