# Installation directory PREFIX=/usr/local INSTALL_LIB= $(PREFIX)/lib INSTALL_INC= $(PREFIX)/include INSTALL_MAN= $(PREFIX)/share/man # Compiler ifeq "$(origin CC)" "default" COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) ifeq "$(COLORGCC)" "0" CC = colorgcc endif endif # Other tools AR = ar RANLIB = ranlib # Install/uninstall commands RM = rm -f CP = cp SYMLINK = ln -sf # General variables LIB_CIBLE=libowlps VERSION = 3.0 # Targets to build STATIC=$(LIB_CIBLE).a DYNAMIC=$(LIB_CIBLE).so.$(VERSION) #PROGS= HEADER=owlps.h #HEADERS= # Library components OBJS=$(LIB_CIBLE).o # Flags CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O #CFLAGS += -g -O0 #CFLAGS += -D NDEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC LIBS = #STRIPFLAGS= -Wl,-s #LDFLAGS= ## Standard targets ## .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) $(PICFLAG) -c -o $@ $< # Dynamic library compilation $(DYNAMIC): $(OBJS) $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^ $(SYMLINK) $@ $(LIB_CIBLE).so chmod a-x $@ # Static library compilation $(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) ## Uninstallation ## 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) ## Cleaning ## clean : @$(RM) *~ *.o *.d purge : clean @$(RM) $(DYNAMIC) *.so $(STATIC) $(PROGS) ## Help ## help : @echo "Needed libraries:" @echo " libiw-dev" @echo @echo "Targets:" @echo " all (default target): Builds the library (dynamic & static)." @echo " dynamic: Builds the shared library." @echo " static: Builds the static library." @echo @echo " install: Installs the library (dynamic & static)." @echo " install-dynamic: Installs the shared library." @echo " install-static: Installs the static library." @echo @echo " uninstall: Uninstalls everything." @echo " uninstall-dynamic: Uninstalls the shared library." @echo " uninstall-static: Uninstalls the static library." @echo @echo " clean: Deletes the temporary files." @echo " purge: Deletes the built binaries." @echo @echo "Note: Files are installed under $(PREFIX)." @echo "Tune the PREFIX variable in the Makefile to change that."