aboutsummaryrefslogblamecommitdiffstats
path: root/Makefile
blob: ef1011771521ff4d88a7d11ba1ff798b59dad7f8 (plain) (tree)






























                                               

                                                 

                                                

                                               














                                                 



                                 


                                             
























                                                        
                    

                        

 
                                                  

               

                       






                                                     





                                                      







                                                  










                                                            


                                                 


                                                 





                                                                                                   






                                                                                      






                                                                       


                                                                 



                                                             
                             

          
                              
 
                                         
.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