2011-06-15 10:36:47 +02:00
|
|
|
# Emplacement de la suite de cross-compilation
|
2011-07-18 23:34:06 +02:00
|
|
|
TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03/staging_dir
|
|
|
|
TOOLCHAIN1 = $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1
|
|
|
|
TOOLCHAIN2 = $(TOOLCHAIN_PREFIX)/target-mips_uClibc-0.9.30.1
|
|
|
|
TOOLCHAIN_BIN = $(TOOLCHAIN1)/usr/bin
|
2011-06-15 10:36:47 +02:00
|
|
|
|
|
|
|
# Répertoire d'installation
|
|
|
|
PREFIX=/usr/local
|
|
|
|
INSTALL_LIB= $(PREFIX)/lib
|
|
|
|
INSTALL_INC= $(PREFIX)/include
|
|
|
|
INSTALL_MAN= $(PREFIX)/share/man
|
|
|
|
|
|
|
|
# Compilateur
|
|
|
|
CC = $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc
|
|
|
|
|
|
|
|
# Autres outils
|
|
|
|
AR = ar
|
|
|
|
RANLIB = ranlib
|
|
|
|
|
|
|
|
# Commandes d'installation et de désinstallation
|
2011-06-23 12:49:41 +02:00
|
|
|
RM = rm -f
|
|
|
|
CP = cp
|
|
|
|
SYMLINK = ln -sf
|
2011-06-15 10:36:47 +02:00
|
|
|
|
|
|
|
# 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
|
2011-07-24 18:58:21 +02:00
|
|
|
#CFLAGS += -D NDEBUG
|
2011-06-15 10:36:47 +02:00
|
|
|
DEPFLAGS=-MMD
|
|
|
|
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
|
|
|
PICFLAG=-fPIC
|
|
|
|
#STRIPFLAGS= -Wl,-s
|
|
|
|
#LDFLAGS=
|
2011-07-18 23:34:06 +02:00
|
|
|
LATHEROS = -L$(TOOLCHAIN1)/lib -L$(TOOLCHAIN1)/usr/lib -L$(TOOLCHAIN2)/usr/lib
|
|
|
|
IATHEROS = -I$(TOOLCHAIN1)/usr/include -I$(TOOLCHAIN2)/usr/include
|
2011-06-15 10:36:47 +02:00
|
|
|
|
|
|
|
## 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)
|
2011-07-18 23:34:06 +02:00
|
|
|
$(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(IATHEROS) $(LATHEROS) $^
|
2011-06-15 10:36:47 +02:00
|
|
|
$(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 :
|
2011-06-23 13:12:29 +02:00
|
|
|
@make help
|