aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ef1011771521ff4d88a7d11ba1ff798b59dad7f8 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
.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 = tellurian


OBJ_PUBLIC =\
	libtellurian_sea_level.o\
	libtellurian_sea_level_radians.o\
	libtellurian_coarse_distance.o\
	libtellurian_coarse_distance_radians.o\
	libtellurian_distance.o\
	libtellurian_distance_radians.o\
	libtellurian_azimuth.o\
	libtellurian_azimuth_radians.o\
	libtellurian_end_point.o\
	libtellurian_end_point_radians.o\
	libtellurian_normal_gravity.o\
	libtellurian_normal_gravity_radians.o\
	libtellurian_effective_gravity.o\
	libtellurian_effective_gravity_radians.o\
	libtellurian_elevated_gravity.o\
	libtellurian_elevated_gravity_radians.o\
	libtellurian_meridian_radius.o\
	libtellurian_meridian_radius_radians.o\
	libtellurian_transverse_radius.o\
	libtellurian_transverse_radius_radians.o\
	libtellurian_azimuthal_radius.o\
	libtellurian_azimuthal_radius_radians.o\
	libtellurian_gaussian_radius.o\
	libtellurian_gaussian_radius_radians.o

OBJ =\
	$(OBJ_PUBLIC)\
	libtellurian_vincenty_inverse__.o

HDR =\
	libtellurian.h\
	common.h

MAN0 = libtellurian.h.0
MAN3 = $(MAN3_FUNC) $(MAN3_CONST)
MAN7 = libtellurian.7

MAN3_FUNC =\
	$(OBJ_PUBLIC:.o=.3)\
	libtellurian_coarse_distance_radius.3

MAN3_CONST =\
	LIBTELLURIAN_EQUATORIAL_RADIUS.3\
	LIBTELLURIAN_POLAR_RADIUS.3\
	LIBTELLURIAN_MEAN_RADIUS.3\
	LIBTELLURIAN_VOLUMETRIC_RADIUS.3\
	LIBTELLURIAN_AUTHALIC_RADIUS.3\
	LIBTELLURIAN_RECTIFYING_RADIUS.3\
	LIBTELLURIAN_NOMINAL_EQUATORIAL_RADIUS.3\
	LIBTELLURIAN_NOMINAL_POLAR_RADIUS.3\
	LIBTELLURIAN_NOMINAL_RADIUS.3\
	LIBTELLURIAN_EQUATORIAL_CIRCUMFERENCE.3\
	LIBTELLURIAN_POLAR_CIRCUMFERENCE.3\
	LIBTELLURIAN_MEAN_CIRCUMFERENCE.3\
	LIBTELLURIAN_VOLUMETRIC_CIRCUMFERENCE.3\
	LIBTELLURIAN_AUTHALIC_CIRCUMFERENCE.3\
	LIBTELLURIAN_MERIDIONAL_CIRCUMFERENCE.3\
	LIBTELLURIAN_EQUATORIAL_GRAVITY.3\
	LIBTELLURIAN_POLAR_GRAVITY.3\
	LIBTELLURIAN_NORMAL_EQUATORIAL_GRAVITY.3\
	LIBTELLURIAN_NORMAL_POLAR_GRAVITY.3\
	LIBTELLURIAN_MASS_OF_EARTH.3\
	LIBTELLURIAN_ANGULAR_VELOCITY.3\
	LIBTELLURIAN_GEOCENTRIC_GRAVITATIONAL_CONSTANT.3

LOBJ = $(OBJ:.o=.lo)
TOBJ = $(OBJ:.o=.to)
TEST = $(TOBJ:.to=.test)


all: libtellurian.a libtellurian.$(LIBEXT) $(TEST)
$(OBJ): $(HDR)
$(LOBJ): $(HDR)
$(TOBJ): $(HDR)
$(TEST): libtellurian.a

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

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

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

.to.test:
	$(CC) -o $@ $< libtellurian.a $(LDFLAGS)

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

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

check: $(TEST)
	@for t in $(TEST); do\
		printf '%s ' $(CHECK_PREFIX) ./$$t;\
		printf '\n\033[31m';\
		if ! $(CHECK_PREFIX) "./$$t"; then\
			printf '\033[1m%s\n' 'TEST FAILED';\
			fail=y;\
		fi;\
		printf '\033[m';\
	done ; test -z "$$fail"

install: libtellurian.a libtellurian.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man0"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
	cp -- libtellurian.a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- libtellurian.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBMINOREXT)"
	$(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBMINOREXT)"
	ln -sf -- libtellurian.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBMAJOREXT)"
	ln -sf -- libtellurian.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBEXT)"
	cp -- libtellurian.h "$(DESTDIR)$(PREFIX)/include/"
	cp -P -- $(MAN0) "$(DESTDIR)$(MANPREFIX)/man0/"
	cp -P -- $(MAN3_FUNC) "$(DESTDIR)$(MANPREFIX)/man3/"
	set -e && for f in $(MAN3_CONST); do \
		test ! -d "$(DESTDIR)$(MANPREFIX)/man3/$$f";\
		ln -sf -- ../man0/libtellurian.h.0 "$(DESTDIR)$(MANPREFIX)/man3/$$f";\
	done
	cp -P -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7/"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libtellurian.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libtellurian.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libtellurian.h"
	-cd -- "$(DESTDIR)$(MANPREFIX)/man0/" && rm -f -- $(MAN0)
	-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
	-rm -f -- *.gch *.gcov *.gcno *.gcda *.$(LIBEXT)
	-rm -f -- *.to *.test

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

.PHONY: all check install uninstall clean