aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 132e8d536b491cf1f4f1cc10c3c633a2f3d5c18c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

OS = linux
# Linux:   linux
# Mac OS:  macos
# Windows: windows
include mk/$(OS).mk


LIB_MAJOR = 1
LIB_MINOR = 0
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
LIB_NAME = rifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket


# OBJ is sorted in testing order
OBJ =\
	equations.o\
	sorting.o\
	rtgrpblib_create_raster.o\
	rtgrpblib_reset_raster.o\
	rtgrpblib_set_draftness.o\
	draw_linear_bezier_reference.o\
	lines.o\
	rtgrpblib_draw_circular_arc.o\
	rtgrpblib_draw_linear_bezier.o\
	rtgrpblib_draw_quadratic_bezier.o\
	rtgrpblib_draw_cubic_bezier.o\
	rtgrpblib_fill_shapes.o

HDR =\
	lib$(LIB_NAME).h\
	common.h

LOBJ = $(OBJ:.o=.lo)
TESTS = $(OBJ:.o=.test)

MAN3 =\
	rtgrpblib_create_raster.3\
	rtgrpblib_reset_raster.3\
	rtgrpblib_set_draftness.3\
	rtgrpblib_draw_circular_arc.3\
	rtgrpblib_draw_linear_bezier.3\
	rtgrpblib_draw_quadratic_bezier.3\
	rtgrpblib_draw_cubic_bezier.3\
	rtgrpblib_fill_shapes.3

MAN7 = lib$(LIB_NAME).7


all: lib$(LIB_NAME).a lib$(LIB_NAME).$(LIBEXT) $(TESTS)
$(OBJ): $(HDR)
$(LOBJ): $(HDR)
$(TESTS): $(HDR) lib$(LIB_NAME).a

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)

.c.lo:
	$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)

.c.test:
	$(CC) -o $@ $< lib$(LIB_NAME).a $(CFLAGS) $(CPPFLAGS) -DTEST $(LDFLAGS)

lib$(LIB_NAME).a: $(OBJ)
	@rm -f -- $@
	$(AR) rc $@ $(OBJ)
	$(AR) ts $@ > /dev/null

lib$(LIB_NAME).$(LIBEXT): $(LOBJ)
	$(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)

check: $(TESTS)
	@for t in $(TESTS); do printf './%s\n' $$t; ./$$t || exit 1; done

install: lib$(LIB_NAME).a lib$(LIB_NAME).$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	cp -- lib$(LIB_NAME).a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- lib$(LIB_NAME).$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBMINOREXT)"
	$(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBMINOREXT)"
	ln -sf -- lib$(LIB_NAME).$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBMAJOREXT)"
	ln -sf -- lib$(LIB_NAME).$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBEXT)"
	cp -- lib$(LIB_NAME).h "$(DESTDIR)$(PREFIX)/include/"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3/"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7/"
	cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3/"
	cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7/"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/lib$(LIB_NAME).$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/lib$(LIB_NAME).h"
	-cd -- "$(DESTDIR)$(MANPREFIX)/man3/" && rm -f -- $(MAN3)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man7/" && rm -f -- $(MAN7)

clean:
	-rm -f -- *.o *.a *.lo *.su *.so *.so.* *.dll *.dylib *.test
	-rm -f -- *.gch *.gcov *.gcno *.gcda *.$(LIBEXT)

.SUFFIXES:
.SUFFIXES: .lo .o .c .test

.PHONY: all check install uninstall clean