owlps/libowlps/Makefile_drone

149 lines
3.8 KiB
Plaintext

TOOLCHAIN_PREFIX = /arm
TOOLCHAIN_BIN = $(TOOLCHAIN_PREFIX)/bin
TOOLCHAIN_USR = $(TOOLCHAIN_PREFIX)/arm-none-linux-gnueabi/libc/usr
TOOLCHAIN_USR_2 = $(TOOLCHAIN_PREFIX)/arm-none-linux-gnueabi/libc
# Répertoire d'installation
PREFIX_CC=/arm/arm-none-linux-gnueabi
PREFIX=/usr/local
INSTALL_LIB= $(PREFIX)/lib
INSTALL_INC= $(PREFIX_CC)/include
INSTALL_MAN= $(PREFIX)/share/man
# Compilateur
CC = $(TOOLCHAIN_BIN)/arm-none-linux-gnueabi-gcc
# Autres outils
AR = ar
RANLIB = ranlib
# Commandes d'installation et de désinstallation
RM = rm -f
CP = cp
SYMLINK = ln -sf
# Variables générales
LIB_CIBLE=libowlps
VERSION=1.0
# Cibles à construire
STATIC=$(LIB_CIBLE).a
DYNAMIC=$(LIB_CIBLE).so.$(VERSION)
#PROGS=
HEADER=owlps.h
#HEADERS=
# Composition de la bibliothèque
OBJS=$(LIB_CIBLE).o
# Flags
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I.
DEPFLAGS=-MMD
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
PICFLAG=-fPIC
LIBS = -liw -lrt
#STRIPFLAGS= -Wl,-s
#LDFLAGS=
LATHEROS=-L$(TOOLCHAIN_USR_2)/lib/
IATHEROS=-I$(TOOLCHAIN_USR)/include/
## 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: %.c $(HEADER)
$(CC) $(XCFLAGS) $(IATHEROS) $(PICFLAG) -c -o $@ $<
# Compilation de la bibliothèque dynamique
$(DYNAMIC): $(OBJS)
$(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) $(IATHEROS) $(LATHEROS) -lc $^
$(SYMLINK) $@ $(LIB_CIBLE).so
chmod a-x $@
# Compilation de la bibliothèque statique
$(STATIC): $(OBJS)
$(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) &&\
cd $(INSTALL_LIB) && $(SYMLINK) $(DYNAMIC) $(LIB_CIBLE).so &&\
echo "Reconstruction du cache pour ld.so : ldconfig $(INSTALL_LIB)" ; ldconfig $(INSTALL_LIB)
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) $(INSTALL_LIB)/$(LIB_CIBLE).so
@echo "Reconstruction du cache pour ld.so : ldconfig" ; ldconfig
uninstall-static : uninstall-header
@$(RM) $(INSTALL_LIB)/$(STATIC)
uninstall-header :
@$(RM) $(INSTALL_INC)/$(HEADER)
## Nettoyage ##
clean :
@$(RM) *~ *.o *.d
purge : clean
@$(RM) $(DYNAMIC) *.so $(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\
\n\
install : Installe la bibliothèque partagée et statique.\n\
install-dynamic : N'installe que la bibliothèque partagée.\n\
install-static : N'installe que la bibliothèque statique.\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\
\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."
# Local Variables: *
# mode: makefile-gmake *
# End: *