owlps/owlps-udp-to-http/Makefile

115 lines
2.6 KiB
Makefile

# Source version
ifndef OWLPS_VERSION
OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION')
endif
# Installation directory
PREFIX=/usr/local
INSTALL_DIR= $(PREFIX)/bin
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
# Install/uninstall commands
RM = rm -f
CP = cp
# Target
TARGET = owlps-udp-to-http
HEADER =
# Flags
LIBOWLPS_DIR = ../libowlps
LIBOWLPSRESULTREADER_DIR = ../libowlps-resultreader
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes \
-I$(LIBOWLPS_DIR) -I$(LIBOWLPSRESULTREADER_DIR)
#CFLAGS += -g -O0
DEPFLAGS = -MMD
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
PICFLAG = -fPIC
OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\"
OWLPSFLAGS += -D DEBUG
LIBS = -pthread -L$(LIBOWLPS_DIR) -lowlps \
-L$(LIBOWLPSRESULTREADER_DIR) -lowlps-resultreader
OS := $(shell uname)
ifeq "$(OS)" "Linux"
LIBS += -lrt
endif
ifeq "$(OS)" "GNU/kFreeBSD"
LIBS += -lrt
endif
STATIC_LIBS =
## Standard targets ##
.PHONY : all dynamic static install uninstall clean purge help
dynamic : $(TARGET)
static : $(TARGET).static
all : dynamic static
# Cancel implicit make rule
%: %.c
%: %.o
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
%.static: %.o
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ \
$(LDFLAGS) $(LIBS) $(STATIC_LIBS) -static
%.o: %.c $(HEADER)
$(CC) $(XCFLAGS) $(OWLPSFLAGS) -c $<
## Installation / uninstallation ##
install : $(TARGET)
@$(CP) $(TARGET) $(INSTALL_DIR)
@cd $(INSTALL_DIR) ; chown root:root $(TARGET) ; chmod 755 $(TARGET)
install-static : $(TARGET).static
@$(CP) $(TARGET).static $(INSTALL_DIR)
@cd $(INSTALL_DIR) ; chown root:root $(TARGET).static ; chmod 755 $(TARGET).static
uninstall :
@$(RM) $(INSTALL_DIR)/{$(TARGET),$(TARGET).static}
## Cleaning ##
clean :
@$(RM) *~ *.o *.d
purge : clean
@$(RM) $(TARGET) $(TARGET).static
## Help ##
help :
@echo "Needed libraries:"
@echo " libowlps-dev"
@echo " libowlps-resultreader-dev"
@echo
@echo "Targets:"
@echo " $(TARGET) (default target): Builds the program $(TARGET)."
@echo " $(TARGET).static : Builds the program $(TARGET).static \
(statically linked version)."
@echo " install: Installs the program $(TARGET)."
@echo " uninstall: Uninstalls the program $(TARGET)."
@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."