mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
poly2d/: Yet another 2D polygon library (WIP)
This commit is contained in:
105
poly2d/Makefile
Normal file
105
poly2d/Makefile
Normal file
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# Makefile - Makefile of libpoly2d
|
||||
#
|
||||
# Written 2012 by Werner Almesberger
|
||||
# Copyright 2012 by Werner Almesberger
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
||||
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 \
|
||||
p2d_copy.o p2d_free.o p2d_gnuplot.o p2d_make.o p2d_offset.o p2d_hsort.o
|
||||
|
||||
CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \
|
||||
-Wmissing-declarations -Wno-format-zero-length
|
||||
|
||||
CFLAGS = $(CFLAGS_WARN) -g
|
||||
CXXFLAGS = -Wall -frounding-math
|
||||
LDFLAGS =
|
||||
LDLIBS = -lm
|
||||
|
||||
# ----- Verbosity control -----------------------------------------------------
|
||||
|
||||
CC_normal := $(CC)
|
||||
CXX_normal := $(CXX)
|
||||
AR_normal := $(AR)
|
||||
DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
|
||||
|
||||
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
||||
CXX_quiet = @echo " CXX " $@ && $(CXX_normal)
|
||||
AR_quiet = @echo " AR " $@ && $(AR_normal)
|
||||
DEPEND_quiet = @$(DEPEND_normal)
|
||||
|
||||
ifeq ($(V),1)
|
||||
CC = $(CC_normal)
|
||||
CXX = $(CXX_normal)
|
||||
AR = $(AR_normal)
|
||||
DEPEND = $(DEPEND_normal)
|
||||
else
|
||||
CC = $(CC_quiet)
|
||||
CXX = $(CXX_quiet)
|
||||
AR = $(AR_quiet)
|
||||
DEPEND = $(DEPEND_quiet)
|
||||
endif
|
||||
|
||||
# ----- Rules -----------------------------------------------------------------
|
||||
|
||||
.PHONY: all clean spotless
|
||||
.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; }
|
||||
|
||||
-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
|
||||
Reference in New Issue
Block a user