2012-05-05 03:40:55 +03:00
|
|
|
#
|
|
|
|
# Makefile - Makefile of libpoly2d
|
|
|
|
#
|
2017-01-24 21:34:48 +02:00
|
|
|
# Written 2012, 2013, 2017 by Werner Almesberger
|
|
|
|
# Copyright 2012, 2013, 2017 by Werner Almesberger
|
2012-05-05 03:40:55 +03:00
|
|
|
#
|
2015-01-19 01:43:08 +02:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2012-05-05 03:40:55 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
|
|
|
|
SHELL = /bin/bash
|
|
|
|
|
|
|
|
LIB = libpoly2d.a
|
|
|
|
OBJS = v2d_intersect.o v2d_line_distance.o \
|
|
|
|
p2d_area.o p2d_area_holes.o \
|
|
|
|
p2d_attrib.o p2d_contains_point.o p2d_contains_poly.o \
|
2013-10-14 02:33:05 +03:00
|
|
|
p2d_copy.o p2d_free.o p2d_gnuplot.o p2d_make.o p2d_offset.o \
|
|
|
|
p2d_hsort.o f2d_tri_holes.o f2d_tri.o
|
2012-05-05 03:40:55 +03:00
|
|
|
|
|
|
|
CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \
|
|
|
|
-Wmissing-declarations -Wno-format-zero-length
|
|
|
|
|
2012-05-08 19:14:00 +03:00
|
|
|
CFLAGS = $(CFLAGS_WARN) -g -std=gnu99
|
2012-05-05 03:40:55 +03:00
|
|
|
CXXFLAGS = -Wall -frounding-math
|
|
|
|
LDFLAGS =
|
|
|
|
LDLIBS = -lm
|
|
|
|
|
|
|
|
# ----- Verbosity control -----------------------------------------------------
|
|
|
|
|
|
|
|
CC_normal := $(CC)
|
|
|
|
CXX_normal := $(CXX)
|
|
|
|
AR_normal := $(AR)
|
|
|
|
DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
|
2012-05-08 04:53:45 +03:00
|
|
|
DEPENDXX_normal := $(CPP) $(CXXFLAGS) -MM -MG
|
2012-05-05 03:40:55 +03:00
|
|
|
|
|
|
|
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
|
|
|
CXX_quiet = @echo " CXX " $@ && $(CXX_normal)
|
|
|
|
AR_quiet = @echo " AR " $@ && $(AR_normal)
|
|
|
|
DEPEND_quiet = @$(DEPEND_normal)
|
2012-05-08 04:53:45 +03:00
|
|
|
DEPENDXX_quiet = @$(DEPENDXX_normal)
|
2012-05-05 03:40:55 +03:00
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
CC = $(CC_normal)
|
|
|
|
CXX = $(CXX_normal)
|
|
|
|
AR = $(AR_normal)
|
|
|
|
DEPEND = $(DEPEND_normal)
|
2012-05-08 04:53:45 +03:00
|
|
|
DEPENDXX = $(DEPENDXX_normal)
|
2012-05-05 03:40:55 +03:00
|
|
|
else
|
|
|
|
CC = $(CC_quiet)
|
|
|
|
CXX = $(CXX_quiet)
|
|
|
|
AR = $(AR_quiet)
|
|
|
|
DEPEND = $(DEPEND_quiet)
|
2012-05-08 04:53:45 +03:00
|
|
|
DEPENDXX = $(DEPENDXX_quiet)
|
2012-05-05 03:40:55 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# ----- Rules -----------------------------------------------------------------
|
|
|
|
|
2017-01-24 21:34:48 +02:00
|
|
|
.PHONY: all clean spotless install uninstall
|
2012-05-05 03:40:55 +03:00
|
|
|
.PHONY: test tests valgrind
|
|
|
|
|
|
|
|
all: $(LIB)
|
|
|
|
|
|
|
|
$(LIB): $(OBJS)
|
|
|
|
$(AR) cr $@ $^
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(OBJS) $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
spotless: clean
|
|
|
|
rm -f $(LIB)
|
|
|
|
|
|
|
|
# ----- Install / uninstall ---------------------------------------------------
|
|
|
|
|
|
|
|
install: all
|
|
|
|
mkdir -p $(DESTDIR)/$(PREFIX)/bin/
|
|
|
|
install -m 755 $(MAIN) $(DESTDIR)/$(PREFIX)/bin/
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -f $(DESTDIR)/$(PREFIX)/bin/$(MAIN)
|
|
|
|
|
|
|
|
# ----- Dependencies ----------------------------------------------------------
|
|
|
|
|
|
|
|
# compile and generate dependencies, from fped, based on
|
|
|
|
# http://scottmcpeak.com/autodepend/autodepend.html
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -c $(CFLAGS) $*.c -o $*.o
|
|
|
|
$(DEPEND) $*.c | \
|
|
|
|
sed -e \
|
|
|
|
'/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
|
|
|
|
-e '$${g;p;}' -e d >$*.d; \
|
|
|
|
[ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
|
|
|
|
|
2012-05-08 04:53:45 +03:00
|
|
|
%.o: %.cpp
|
|
|
|
$(CXX) -c $(CXXFLAGS) $*.cpp -o $*.o
|
|
|
|
$(DEPENDXX) $*.cpp | \
|
|
|
|
sed -e \
|
|
|
|
'/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
|
|
|
|
-e '$${g;p;}' -e d >$*.d; \
|
|
|
|
[ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
|
|
|
|
|
2012-05-05 03:40:55 +03:00
|
|
|
-include $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
# ----- Tests -----------------------------------------------------------------
|
|
|
|
|
|
|
|
test tests: all
|
|
|
|
LANG= sh -c \
|
|
|
|
'passed=0 && cd test && \
|
|
|
|
for n in [a-z]*; do \
|
|
|
|
[ $$n != core ] && SCRIPT=$$n . ./$$n; done; \
|
|
|
|
echo "Passed all $$passed tests"'
|
|
|
|
|
|
|
|
valgrind:
|
|
|
|
VALGRIND="valgrind -q" $(MAKE) tests
|