2010-07-02 12:34:43 +02:00
|
|
|
# Emplacement de la suite de cross-compilation
|
|
|
|
TOOLCHAIN = $$HOME/openwrt/atheros/8.09/staging_dir
|
|
|
|
|
|
|
|
# Répertoire d'installation
|
|
|
|
PREFIX=/usr/local
|
|
|
|
INSTALL_LIB= $(PREFIX)/lib
|
|
|
|
INSTALL_INC= $(PREFIX)/include
|
|
|
|
INSTALL_MAN= $(PREFIX)/share/man
|
|
|
|
|
|
|
|
# Compilateur
|
|
|
|
CC = $(TOOLCHAIN)/toolchain-mips_gcc4.1.2/bin/mips-linux-gcc
|
|
|
|
|
|
|
|
# Autres outils
|
|
|
|
AR = ar
|
|
|
|
RANLIB = ranlib
|
|
|
|
|
|
|
|
# Commandes d'installation et de désinstallation
|
|
|
|
RM=rm -fv
|
|
|
|
CP=cp -v
|
|
|
|
SYMLINK=ln -svf
|
|
|
|
|
|
|
|
# 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 -W -Wall -Wstrict-prototypes -O -I.
|
|
|
|
DEPFLAGS=-MMD
|
|
|
|
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
|
|
|
PICFLAG=-fPIC
|
|
|
|
LIBS=-liw
|
|
|
|
#STRIPFLAGS= -Wl,-s
|
|
|
|
#LDFLAGS=
|
|
|
|
LATHEROS=-L$(TOOLCHAIN)/mips/usr/lib/
|
|
|
|
IATHEROS=-I$(TOOLCHAIN)/mips/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)
|
|
|
|
|
2010-03-18 12:14:36 +01:00
|
|
|
%.o: %.c $(HEADER)
|
2010-07-02 12:34:43 +02:00
|
|
|
$(CC) $(XCFLAGS) $(IATHEROS) $(PICFLAG) -c -o $@ $<
|
|
|
|
|
|
|
|
# Compilation de la bibliothèque dynamique
|
2010-03-18 12:14:36 +01:00
|
|
|
$(DYNAMIC): $(OBJS)
|
2010-07-02 12:34:43 +02:00
|
|
|
$(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) $(IATHEROS) $(LATHEROS) -lc $^
|
2010-03-18 12:14:36 +01:00
|
|
|
$(SYMLINK) $@ $(LIB_CIBLE).so
|
|
|
|
chmod a-x $@
|
2010-07-02 12:34:43 +02:00
|
|
|
|
|
|
|
# Compilation de la bibliothèque statique
|
2010-03-18 12:14:36 +01:00
|
|
|
$(STATIC): $(OBJS)
|
2010-07-02 12:34:43 +02:00
|
|
|
$(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 :
|
2010-03-18 12:14:36 +01:00
|
|
|
@$(RM) *~ *.o *.d
|
2010-07-02 12:34:43 +02:00
|
|
|
|
|
|
|
purge : clean
|
2010-03-18 12:14:36 +01:00
|
|
|
@$(RM) $(DYNAMIC) *.so $(STATIC) $(PROGS)
|
2010-07-02 12:34:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
## 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\
|
2010-03-18 12:14:36 +01:00
|
|
|
install : Installe la bibliothèque partagée et statique.\n\
|
2010-07-02 12:34:43 +02:00
|
|
|
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."
|