owlps/owlps-udp-to-http/Makefile

93 lines
2.1 KiB
Makefile

include ../common.mk
# 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."