94 lines
1.6 KiB
Makefile
94 lines
1.6 KiB
Makefile
# 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
|
|
RM = rm -f
|
|
|
|
# General variables
|
|
LIB_CIBLE = libowlps-resultreader
|
|
VERSION = 1.0
|
|
|
|
# Targets to build
|
|
STATIC = $(LIB_CIBLE).a
|
|
HEADER = owlps-resultreader.h
|
|
EXAMPLE = owlps-resultreader-udp
|
|
|
|
# Library components
|
|
OBJS = $(LIB_CIBLE).o
|
|
|
|
# Flags
|
|
LIBOWLPS_DIR = ../libowlps
|
|
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I$(LIBOWLPS_DIR)
|
|
#CFLAGS += -g -O0
|
|
CFLAGS += -D DEBUG
|
|
DEPFLAGS = -MMD
|
|
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
|
PICFLAG = -fPIC
|
|
#STRIPFLAGS = -Wl,-s
|
|
#LDFLAGS =
|
|
|
|
LIBS = -L$(LIBOWLPS_DIR) -lowlps
|
|
OS := $(shell uname)
|
|
ifeq "$(OS)" "Linux"
|
|
LIBS += -lrt
|
|
endif
|
|
ifeq "$(OS)" "GNU/kFreeBSD"
|
|
LIBS += -lrt
|
|
endif
|
|
|
|
|
|
## Standard targets ##
|
|
|
|
.PHONY : all static clean purge help
|
|
|
|
all : static example
|
|
static : $(STATIC)
|
|
example : $(EXAMPLE)
|
|
|
|
# Cancel implicit make rule
|
|
%: %.c
|
|
|
|
%.o : %.c $(HEADER)
|
|
$(CC) $(XCFLAGS) -c $<
|
|
|
|
% : %.o $(HEADER) $(STATIC)
|
|
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $< \
|
|
$(STATIC) $(LIBS)
|
|
|
|
# Static library compilation
|
|
$(STATIC) : $(OBJS)
|
|
$(RM) $@
|
|
$(AR) cru $@ $^
|
|
$(RANLIB) $@
|
|
|
|
|
|
## Cleaning ##
|
|
|
|
clean :
|
|
@$(RM) *~ *.o *.d
|
|
|
|
purge : clean
|
|
@$(RM) $(STATIC) $(EXAMPLE)
|
|
|
|
|
|
## Help ##
|
|
|
|
help :
|
|
@echo "Needed libraries:"
|
|
@echo " libowlps-dev"
|
|
@echo
|
|
@echo "Targets:"
|
|
@echo " all (default): Builds the library and the sample program."
|
|
@echo " static: Builds the static library."
|
|
@echo " example: Builds the sample program."
|
|
@echo
|
|
@echo " clean: Deletes the temporary files."
|
|
@echo " purge: Deletes the built binaries."
|