aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-04-06 23:10:40 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-04-06 23:10:40 +0200
commit18c64b5d71ce4570a42a02be1aa31fa98bf23437 (patch)
tree901c5076a14cfa333332edb364be16dd88b88ea0
parent138bfa457867b6192fccf13ad14299437197b408 (diff)
Added the install target in the Makefile.
-rw-r--r--.gitignore1
-rw-r--r--Makefile107
-rwxr-xr-xMakefile.vars23
-rwxr-xr-xconfigure42
-rwxr-xr-xtestclient.sh4
-rwxr-xr-xtools/testclient.sh17
-rwxr-xr-xtools/write-pkg.sh32
7 files changed, 192 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index 0a7fba4..f45ba04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ vgcore.*
common/weshd.h
Makefile.cfg
testclient
+root
diff --git a/Makefile b/Makefile
index b0bdd40..5d6fc6a 100644
--- a/Makefile
+++ b/Makefile
@@ -25,23 +25,16 @@ mrproper: clean
re: clean all
+# Installation de tout.
+
+install: install-daemon install-lib install-client
+
# Une target pour ne rien faire, histoire de tester des choses avec
# des `$(info <contenu>)` principalement.
-.PHONY: all clean mrproper re nothing
-
-# ---
-# Récupération d'informations depuis le Makefile.
-# ---
+ nothing:
- getname:
- @echo $(NAME)
- getversion:
- @echo $(VERSION)
- getmaintainer:
- @echo "$(MAINTAINER)"
-
-.PHONY: getname getversion getmaintainer
+.PHONY: all clean mrproper re nothing
# ---
# Dépendances de vérifications de la configuration.
@@ -66,14 +59,39 @@ re: clean all
.PHONY: check-config check-config-version
# ---
+# Récupération d'informations depuis le Makefile.
+# ---
+
+ getname:
+ @echo $(NAME)
+ getversion:
+ @echo $(VERSION)
+ getmaintainer:
+ @echo "$(MAINTAINER)"
+
+ getlibdir: $(CHECKCFG)
+ @echo "$(OLIBDIR)"
+ getincdir: $(CHECKCFG)
+ @echo "$(OINCDIR)"
+
+.PHONY: getname getversion getmaintainer getlibdir getincdir
+
+# ---
# Création des dossiers.
# ---
+# Dossiers de construction.
# XXX: Temporaire, merci à moi du futur de refaire ça proprement un jour.
- ./build ./build/lib ./build/rpc ./build/daemon ./build/daemon/ \
- ./build/daemon/ip/ ./build/daemon/dummy/ ./build/client:
+ ./build/ ./build/lib/ ./build/rpc/ ./build/daemon/ \
+ ./build/daemon/ip/ ./build/daemon/dummy/ ./build/client/:
$(call bcmd,mkdir,$@,$(MD) "$@")
+# Dossiers d'installation.
+
+ $(IBINDIR) $(ILIBDIR) $(IPKGDIR) \
+ $(sort $(patsubst %,$(IINCDIR)/lib$(LIB)-$(VERSION)/%,$(L_INCp))):
+ $(call qcmd,$(MD) "$@")
+
# ---
# Définition des fichiers générés par `rpcgen`.
# Ces targets ne sont destinées qu'à être mises en dépendances.
@@ -81,34 +99,34 @@ re: clean all
# Copie du fichier dans le dossier de construction.
- $(S_OBJDIR)/$(S_NAME).x: $(S_FROM) | $(S_OBJDIR)
+ $(S_OBJDIR)/$(S_NAME).x: $(S_FROM) | $(S_OBJDIR)/
$(call bcmd,cp,$(S_NAME).x,$(CP) "$<" "$@")
# Création du header et des sources.
- $(S_OBJDIR)/$(S_NAME).h: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)
+ $(S_OBJDIR)/$(S_NAME).h: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)/
$(call bcmd,rpcgen -h,$(S_NAME).h,cd $(S_OBJDIR) \
&& $(RM) $(S_NAME).h \
&& $(RPCGEN) -C -h -o $(S_NAME).h $(S_NAME).x)
- $(S_OBJDIR)/$(S_NAME)_svc.c: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)
+ $(S_OBJDIR)/$(S_NAME)_svc.c: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)/
$(call bcmd,rpcgen -m,$(S_NAME)_svc.c,cd $(S_OBJDIR) \
&& $(RM) $(S_NAME)_svc.c \
&& $(RPCGEN) -C -m -o $(S_NAME)_svc.c $(S_NAME).x)
- $(S_OBJDIR)/$(S_NAME)_xdr.c: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)
+ $(S_OBJDIR)/$(S_NAME)_xdr.c: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)/
$(call bcmd,rpcgen -c,$(S_NAME)_xdr.c,cd $(S_OBJDIR) \
&& $(RM) $(S_NAME)_xdr.c \
&& $(RPCGEN) -C -c -o $(S_NAME)_xdr.c $(S_NAME).x)
- $(S_OBJDIR)/$(S_NAME)_clnt.c: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)
+ $(S_OBJDIR)/$(S_NAME)_clnt.c: $(S_OBJDIR)/$(S_NAME).x | $(S_OBJDIR)/
$(call bcmd,rpcgen -l,$(S_NAME)_clnt.c,cd $(S_OBJDIR) \
&& $(RM) $(S_NAME)_clnt.c \
&& $(RPCGEN) -C -l -o $(S_NAME)_clnt.c $(S_NAME).x)
# Création des objets.
- $(S_OBJDIR)/%.c.o: $(S_OBJDIR)/%.c $(S_OBJDIR)/$(S_NAME).h | $(S_OBJDIR)
+ $(S_OBJDIR)/%.c.o: $(S_OBJDIR)/%.c $(S_OBJDIR)/$(S_NAME).h | $(S_OBJDIR)/
$(call bcmd,cc,$@,$(CC) -c -o $@ $<)
# ---
@@ -128,38 +146,70 @@ endef
$(foreach src,$(basename $(D_SRC)),\
$(eval $(call make-daemon-obj-rule,$(src))))
-.PHONY: all-daemon
+# Installation du démon.
+
+ install-daemon: $(CHECKCFG) | $(IBINDIR)
+ $(call imsg,Installation du démon.)
+ $(call qcmd,$(INST) -m 755 $(D_DEST) $(IBINDIR)/$(notdir $(D_DEST)))
+
+.PHONY: all-daemon install-daemon
# ---
# Définition des targets pour la bibliothèque client.
# ---
# Création de la bibliothèque.
- all-lib: $(CHECKCFG) $(L_DEST)
+ all-lib: $(CHECKCFG) $(L_DEST) $(L_PKG)
$(L_DEST): $(L_DEST).$(MAJOR) | $(dir $(L_DEST))
$(call bcmd,ln,$@,$(LN) $(notdir $(L_DEST).$(MAJOR)) $(L_DEST))
$(L_DEST).$(MAJOR): $(L_OBJ) | $(dir $(L_DEST))
$(call bcmd,ld++,$@,$(LDXX) -o $@ $(L_OBJ) $(L_LDFLAGS))
- $(L_OBJDIR)/%.cpp.o: $(L_SRCDIR)/%.cpp $(L_INC) | $(L_OBJDIR)
+ $(L_OBJDIR)/%.cpp.o: $(L_SRCDIR)/%.cpp $(L_INC) | $(L_OBJDIR)/
$(call bcmd,cxx,$@,$(CXX) -c -o $@ $< $(L_CXXFLAGS))
-.PHONY: all-lib
+ $(L_PKG): | $(dir $(L_PKG))
+ $(call bcmd,write-pkg,$@,tools/write-pkg.sh >"$@")
+
+# Installation de la bibliothèque.
+
+ install-lib: $(CHECKCFG) | $(ILIBDIR) $(IPKGDIR) \
+ $(sort $(patsubst %,$(IINCDIR)/lib$(LIB)-$(VERSION)/%,$(L_INCp)))
+ $(call imsg,Installation de la bibliothèque.)
+ $(call qcmd,$(INST) -m 755 $(L_DEST) \
+ $(ILIBDIR)/$(notdir $(L_DEST).$(MAJOR)))
+ $(call qcmd,$(LN) $(notdir $(L_DEST).$(MAJOR)) \
+ $(ILIBDIR)/$(notdir $(L_DEST)))
+ $(call imsg,Installation du paquet pkg-config.)
+ $(call qcmd,install -m 644 $(L_PKG) $(IPKGDIR)/$(notdir $(L_PKG)))
+ $(call imsg,Installation des headers.)
+ $(foreach i,$(INC),$(call qcmd,$(INST) -m 644 $(INCDIR)/$(i) \
+ "$(IINCDIR)/lib$(LIB)-$(VERSION)/$(i)"$(\n)))
+
+.PHONY: all-lib install-lib
# ---
# Définition des targets pour le client.
# ---
+# Construction du client.
all-client: $(CHECKCFG) $(C_DEST)
$(C_DEST): $(L_DEST) $(C_OBJ) | $(dir $(C_DEST))
$(call bcmd,ld++,$@,$(LDXX) -o $@ $(C_OBJ) $(C_LDFLAGS))
- $(C_OBJDIR)/%.cpp.o: $(C_SRCDIR)/%.cpp $(C_INC) | $(C_OBJDIR)
+ $(C_OBJDIR)/%.cpp.o: $(C_SRCDIR)/%.cpp $(C_INC) | $(C_OBJDIR)/
$(call bcmd,cxx,$@,$(CXX) -c -o $@ $< $(C_CXXFLAGS))
-.PHONY: all-client
+# Installation du client.
+
+ install-client: $(CHECKCFG) | $(IBINDIR)
+ $(call imsg,Installation du client.)
+ $(call qcmd,$(INST) -m 755 $(C_DEST) \
+ $(IBINDIR)/$(notdir $(C_DEST)))
+
+.PHONY: all-client install-client
# ---
# Test du couple client/démon.
@@ -167,7 +217,8 @@ $(eval $(call make-daemon-obj-rule,$(src))))
test: all-daemon all-client
$(call msg,Testing the daemon with the default client.)
- $(call qcmd,LIB=$(L_DEST) DAEMON=$(D_DEST) CLT=$(C_DEST) ./testclient.sh)
+ $(call qcmd,LIB=$(L_DEST) DAEMON=$(D_DEST) CLT=$(C_DEST) \
+ tools/testclient.sh)
.PHONY: test
diff --git a/Makefile.vars b/Makefile.vars
index 3fb565c..139f454 100755
--- a/Makefile.vars
+++ b/Makefile.vars
@@ -51,6 +51,7 @@
CP := cp
LN := ln -sf
MD := mkdir -p
+ INST := install
RPCGEN := rpcgen
@@ -118,6 +119,8 @@
# Dossiers la concernant.
L_DEST := ./build/lib$(LIB).so
+ L_PKG := ./build/lib$(LIB).pc
+
L_SRCDIR := ./lib
L_INCDIR := ./include
L_OBJDIR := ./build/lib
@@ -128,8 +131,10 @@
$(patsubst $(L_SRCDIR)/%,%,$(wildcard $(L_SRCDIR)/*.cpp))
L_OBJ := $(L_SRC:%=$(L_OBJDIR)/%.o) \
$(S_OBJDIR)/$(S_NAME)_xdr.c.o $(S_OBJDIR)/$(S_NAME)_clnt.c.o
- L_INC := $(wildcard $(L_SRCDIR)/*.hpp) $(wildcard $(L_INCDIR)/*.hpp) \
- $(S_OBJDIR)/$(S_NAME).h
+ L_INCp := $(patsubst $(L_INCDIR)/%,%,$(wildcard \
+ $(L_INCDIR)/*.hpp $(L_INCDIR)/**/*.hpp))
+ L_INC := $(L_INCp:%=$(L_INCDIR)) $(S_OBJDIR)/$(S_NAME).h \
+ $(wildcard $(L_SRCDIR)/*.hpp $(L_SRCDIR)/**/*.hpp)
# Dépendances et options.
@@ -167,4 +172,18 @@
C_LIBS := $(foreach x,$(C_DEPS),$(DEP_$(x)_LIBS))
C_LDFLAGS := $(C_LIBS)
+# ---
+# Vérification du DESTDIR (comme préfixe aux racines d'installation).
+# ---
+
+ OINCDIR := $(IINCDIR)
+ OLIBDIR := $(ILIBDIR)
+
+define add-dest-dir
+ $1 = $(DESTDIR)$($1)
+endef
+
+$(if $(DESTDIR),$(foreach idir,IBINDIR IPKGDIR ILIBDIR IINCDIR,\
+$(eval $(call add-dest-dir,$(idir)))))
+
# End of file.
diff --git a/configure b/configure
index 7fec972..57f6fbf 100755
--- a/configure
+++ b/configure
@@ -16,6 +16,13 @@ curlhttpverbose=0
curlftpverbose=0
debugsyms=
+root=''
+prefix='${root}/usr'
+bindir='${prefix}/bin'
+libdir='${prefix}/lib'
+pkgdir='${libdir}/pkgconfig'
+incdir='${prefix}/include'
+
# ---
# Message de version.
# ---
@@ -62,6 +69,16 @@ Build options:
--libcurl-ftp-verbose same as previous for ftp requests using libcurl.
--libcurl-verbose same as previous for all requests using libcurl.
+Installation directories:
+ --root=ROOT root for installation [$root]
+ --prefix=PREFIX main installation prefix [$prefix]
+
+Fine tuning of the installation directories:
+ --bindir=BINDIR target executables [$bindir]
+ --libdir=LIBDIR library files for the linker [$libdir]
+ --pkgdir=PKGDIR pkg-config configurations directory [$pkgdir]
+ --includedir=INCDIR include files for the compiler [$incdir]
+
Report bugs to ${maintainer}.
EOF
exit 0
@@ -99,9 +116,27 @@ for arg ; do case "$arg" in
nologo=1
loglevel=DEBUG
debugsyms=1 ;;
+--root=*)
+ root="${arg#*=}" ;;
+--prefix=*)
+ prefix="${arg#*=}" ;;
+--bindir=*)
+ bindir="${arg#*=}" ;;
+--libdir=*)
+ libdir="${arg#*=}" ;;
+--pkgdir=*)
+ pkgdir="${arg#*=}" ;;
+--includedir=*)
+ incdir="${arg#*=}" ;;
*) echo "'$arg': didn't read" >&2 ;;
esac; done
+# On évalue les variables concernant les chemins.
+
+for var in prefix bindir libdir pkgdir incdir; do
+ eval "${var}"=$(eval echo '$'"${var}")
+done
+
# ---
# Création de la configuration.
# ---
@@ -128,6 +163,13 @@ cat <<EOF
CURL_HTTP_VERBOSE := ${curlhttpverbose}
CURL_FTP_VERBOSE := ${curlftpverbose}
+# Dossiers d'installation.
+
+ IBINDIR := ${bindir}
+ IPKGDIR := ${pkgdir}
+ ILIBDIR := ${libdir}
+ IINCDIR := ${incdir}
+
# End of file.
EOF
exec 1>&3 3>&-
diff --git a/testclient.sh b/testclient.sh
deleted file mode 100755
index 557ed50..0000000
--- a/testclient.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-${DAEMON} & WESHD_PID=$!
-LD_PRELOAD=${LIB} ${CLT}
-kill -9 $WESHD_PID
diff --git a/tools/testclient.sh b/tools/testclient.sh
new file mode 100755
index 0000000..780dcb6
--- /dev/null
+++ b/tools/testclient.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+cd "$(dirname $0)"
+cd ..
+
+# Lancement du démon et récupération du PID.
+
+${DAEMON} & WESHD_PID=$!
+
+# Lancement du client en synchrone.
+
+LD_PRELOAD=${LIB} ${CLT}
+
+# Arrêt du démon.
+
+kill -9 $WESHD_PID
+
+# End of file.
diff --git a/tools/write-pkg.sh b/tools/write-pkg.sh
new file mode 100755
index 0000000..e9f4d74
--- /dev/null
+++ b/tools/write-pkg.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+cd "$(dirname "$0")"
+
+# ---
+# Variables à utiliser.
+# ---
+
+name="wesh"
+description="library for interacting with the WES handling daemon"
+version="$(make -s -C .. getversion)"
+
+libdir="$(make -s -C .. getlibdir)"
+[ $? -eq 0 ] || exit 1
+incdir="$(make -s -C .. getincdir)/lib${name}-${version}"
+[ $? -eq 0 ] || exit 1
+
+# ---
+# Écriture du résultat.
+# ---
+
+cat <<EOF
+includedir=${incdir}
+libdir=${libdir}
+
+Name: lib${name}
+Description: ${description}
+Version: ${version}
+Libs: -L\${libdir} -l${name}
+Cflags: -I\${includedir}
+EOF
+
+# End of file.