138 lines
3.6 KiB
Makefile
138 lines
3.6 KiB
Makefile
# Répertoire d'installation
|
|
PREFIX=/usr/local
|
|
INSTALL_LIB= $(PREFIX)/lib
|
|
INSTALL_INC= $(PREFIX)/include
|
|
INSTALL_MAN= $(PREFIX)/share/man
|
|
|
|
# Compilateur
|
|
CC = gcc
|
|
|
|
# Autres outils
|
|
AR = ar
|
|
RANLIB = ranlib
|
|
|
|
# Commandes d'installation et de désinstallation
|
|
RM=rm -fv
|
|
CP=cp -v
|
|
|
|
# Variables générales
|
|
LIB_CIBLE=librtaputil
|
|
VERSION=1.0
|
|
|
|
# Cibles à construire
|
|
STATIC=$(LIB_CIBLE).a
|
|
DYNAMIC=$(LIB_CIBLE).so.$(VERSION)
|
|
#PROGS=
|
|
HEADER=rtaputil.h
|
|
#HEADERS=
|
|
|
|
# Composition de la bibliothèque
|
|
OBJS=$(LIB_CIBLE).o
|
|
|
|
# Flags
|
|
CFLAGS=-O2 -W -Wall -Wstrict-prototypes -O -I.
|
|
DEPFLAGS=-MMD
|
|
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
|
PICFLAG=-fPIC
|
|
LIBS=-liw
|
|
#STRIPFLAGS= -Wl,-s
|
|
|
|
|
|
## Cibles de compilation standard ##
|
|
|
|
.PHONY : all dynamic static install install-dynamic install-static install-header uninstall uninstall-dynamic uninstall-static uninstall-header clean purge help
|
|
|
|
all : dynamic static
|
|
dynamic : $(DYNAMIC)
|
|
static : $(STATIC)
|
|
|
|
% : %.o
|
|
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^
|
|
%.o : %.c $(HEADER)
|
|
$(CC) $(XCFLAGS) -c $<
|
|
%.so : %.c $(HEADER)
|
|
$(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
|
|
|
|
# Compilation de la bibliothèque dynamique
|
|
$(DYNAMIC) : $(OBJS:.o=.so)
|
|
$(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
|
|
|
|
# Compilation de la bibliothèque statique
|
|
$(STATIC) : $(OBJS:.o=.so)
|
|
$(RM) $@
|
|
$(AR) cru $@ $^
|
|
$(RANLIB) $@
|
|
|
|
|
|
## Installation ##
|
|
|
|
install : install-static install-dynamic
|
|
|
|
install-dynamic : install-header $(DYNAMIC)
|
|
@$(CP) $(DYNAMIC) $(INSTALL_LIB) &&\
|
|
chmod 644 $(INSTALL_LIB)/$(DYNAMIC) &&\
|
|
chown root:root $(INSTALL_LIB)/$(DYNAMIC) &&\
|
|
echo -e "\n!!! Installation de la bibliothèque dynamique effectuée avec succès.\n!!! Ajoutez une ligne « $(INSTALL_LIB) » dans le fichier /etc/ld.so.conf\n ou dans un nouveau fichier de /etc/ld.so.conf.d/, si ce n'est déjà fait.\n!!! Exécutez ldconfig ensuite.\n"
|
|
|
|
install-static : install-header $(STATIC)
|
|
@$(CP) $(STATIC) $(INSTALL_LIB) &&\
|
|
chmod 644 $(INSTALL_LIB)/$(STATIC) &&\
|
|
chown root:root $(INSTALL_LIB)/$(STATIC)
|
|
|
|
install-header : $(HEADER)
|
|
@$(CP) $(HEADER) $(INSTALL_INC) &&\
|
|
chmod 644 $(INSTALL_INC)/$(HEADER) &&\
|
|
chown root:root $(INSTALL_INC)/$(HEADER)
|
|
|
|
|
|
## Désinstallation ##
|
|
|
|
uninstall : uninstall-dynamic uninstall-static
|
|
|
|
uninstall-dynamic : uninstall-header
|
|
@$(RM) $(INSTALL_LIB)/$(DYNAMIC)
|
|
ldconfig
|
|
|
|
uninstall-static : uninstall-header
|
|
@$(RM) $(INSTALL_LIB)/$(STATIC)
|
|
|
|
uninstall-header :
|
|
@$(RM) $(INSTALL_INC)/$(HEADER)
|
|
|
|
|
|
## Nettoyage ##
|
|
|
|
clean :
|
|
@$(RM) *~ *.o $(LIB_CIBLE).so *.d
|
|
|
|
purge : clean
|
|
@$(RM) $(DYNAMIC) $(STATIC) $(PROGS)
|
|
|
|
|
|
## Aide ##
|
|
|
|
help :
|
|
@echo "Bibliothèques nécessaires à la compilation :\n\
|
|
libiw-dev\n\
|
|
\n\
|
|
Cibles possibles :\n\
|
|
all (cible par défaut) : Compile la bibliothèque et le programme d'exemple (tx).\n\
|
|
dynamic : Compile la bibilothèque partagée (.so).\n\
|
|
static : Compile la bibliothèque statique (.a).\n\
|
|
tx : Compile le programme d'exemple.\n\
|
|
\n\
|
|
install : Installe la bibliothèque partagée, statique, ainsi que le programme d'exemple.\n\
|
|
install-dynamic : N'installe que la bibliothèque partagée.\n\
|
|
install-static : N'installe que la bibliothèque statique.\n\
|
|
install-tx : N'installe que le programme d'exemple.\n\
|
|
\n\
|
|
uninstall : Désinstalle tout ce qu'il est possible de désinstaller.\n\
|
|
uninstall-dynamic : Désinstalle la bibliothèque partagée.\n\
|
|
uninstall-static : Désinstalle la bibliothèque statique.\n\
|
|
uninstall-tx : Désinstalle le programme d'exemple.\n\
|
|
\n\
|
|
clean : Supprime les fichiers temporaires.\n\
|
|
purge : Supprime le résultat de la compilation.\n\
|
|
\n\
|
|
Note : l'installation se fait dans l'arborescence $(PREFIX). Modifiez la variable PREFIX du Makefile pour changer ce comportement."
|