summaryrefslogtreecommitdiff
blob: b992d401d3fa66200f5d41bf8009517b7753e3a1 (plain)
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
--- makefile.orig	2013-05-22 20:51:58.398491342 +0000
+++ makefile	2013-05-22 21:05:52.055466710 +0000
@@ -49,7 +49,7 @@
 
 # Specify the installation home directory.
 
-INSTALL_DIR = $(HOME)
+INSTALL_DIR = $(DESTDIR)/usr
 
 # Specify the installation directory for the library.
 
@@ -63,9 +63,10 @@
 # of your preferred C compiler (CCOMPC) and compilation flags (CFLAGF
 # for functions, CFLAGX for executables) here.
 
-CCOMPC = gcc
-CFLAGF = -c -pedantic -Wall -W -O
-CFLAGX = -pedantic -Wall -W -O
+CCOMPC = $(CC)
+CFLAGF = -c -pedantic -Wall -W -fPIC $(CFLAGS)
+CFLAGX = -pedantic -Wall -W $(CFLAGS)
+
 
 #----YOU SHOULDN'T HAVE TO MODIFY ANYTHING BELOW THIS LINE---------
 
@@ -80,6 +81,12 @@
 SOFA_LIB_NAME = libsofa_c.a
 SOFA_LIB = $(SOFA_LIB_DIR)$(SOFA_LIB_NAME)
 
+ 
+# Name the SOFA/C library in its source and target locations.
+
+SOFA_SHLIB_NAME = libsofa_c.so
+SOFA_SHLIB = $(SOFA_LIB_DIR)$(SOFA_SHLIB_NAME)
+
 # Name the SOFA/C testbed in its source and target locations.
 
 SOFA_TEST_NAME = t_sofa_c.c
@@ -88,7 +95,7 @@
 # Name the SOFA/C includes in their source and target locations.
 
 SOFA_INC_NAMES = sofa.h sofam.h
-SOFA_INC = $(SOFA_INC_DIR)sofa.h $(SOFA_INC_DIR)sofam.h
+SOFA_INC = $(SOFA_INC_NAMES:%=$(SOFA_INC_DIR)%)
 
 # The list of SOFA/C library object files.
 SOFA_OBS = iauA2af.o \
@@ -285,29 +292,32 @@
 #-----------------------------------------------------------------------
 
 # Build (but do not install) the library.
-all : $(SOFA_LIB_NAME)
+all : $(SOFA_SHLIB_NAME)
 	-@ echo ""
 	-@ echo "*** Now type 'make test'" \
                 " to install the library and run tests ***"
 	-@ echo ""
 
 # Install the library and header files.
-install $(SOFA_LIB) : $(INSTALL_DIRS) $(SOFA_LIB_NAME) $(SOFA_INC)
-	cp $(SOFA_LIB_NAME) $(SOFA_LIB_DIR)
+install: $(INSTALL_DIRS) $(SOFA_SHLIB_NAME) $(SOFA_INC)
+	cp $(SOFA_SHLIB_NAME).0.0 $(SOFA_LIB_DIR)
+	ln -s $(SOFA_SHLIB_NAME).0.0 $(SOFA_SHLIB).0
+	ln -s $(SOFA_SHLIB_NAME).0 $(SOFA_SHLIB)
 
 # Deinstall the library and header files.
 deinstall:
-	rm -f $(SOFA_LIB) $(SOFA_INC)
+	rm -f $(SOFA_LIB) $(SOFA_SHLIB)* $(SOFA_INC)
 
 # Test the build.
 check: $(SOFA_TEST_NAME) $(SOFA_INC_NAMES) $(SOFA_LIB_NAME)
-	$(CCOMPC) $(CFLAGX) $(SOFA_TEST_NAME) $(SOFA_LIB_NAME) \
+	$(CCOMPC) $(CFLAGX) $(SOFA_TEST_NAME) $(SOFA_SHLIB_NAME).0.0 \
         -lm -o $(SOFA_TEST)
-	./$(SOFA_TEST)
-	rm -f $(SOFA_TEST)
+	ln -s $(SOFA_SHLIB_NAME).0.0 $(SOFA_SHLIB_NAME).0
+	LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):." ./$(SOFA_TEST)
+	rm -f $(SOFA_TEST) $(SOFA_SHLIB_NAME).0
 
 # Test the installed library.
-installcheck test: $(SOFA_TEST_NAME) $(SOFA_INC) $(SOFA_LIB)
+installcheck: $(SOFA_TEST_NAME) $(SOFA_INC) $(SOFA_LIB)
 	$(CCOMPC) $(CFLAGX) $(SOFA_TEST_NAME) -I$(SOFA_INC_DIR) \
         -L$(SOFA_LIB_DIR) -lsofa_c -lm -o $(SOFA_TEST)
 	./$(SOFA_TEST)
@@ -315,11 +325,11 @@
 
 # Local clean up.
 clean realclean:
-	rm -f $(SOFA_OBS) $(SOFA_LIB_NAME)
+	rm -f $(SOFA_OBS) $(SOFA_LIB_NAME) $(SOFA_SHLIB_NAME)
 
 # Clean up and deinstall.
 distclean:
-	rm -f $(SOFA_OBS) $(SOFA_LIB_NAME) $(SOFA_INC) $(SOFA_LIB)
+	rm -f $(SOFA_OBS) $(SOFA_LIB_NAME) $(SOFA_INC) $(SOFA_LIB) $(SOFA_SHLIB_NAME)
 
 # Create the installation directories if not already present.
 $(INSTALL_DIRS):
@@ -329,6 +339,10 @@
 $(SOFA_LIB_NAME): $(SOFA_OBS)
 	ar ru $(SOFA_LIB_NAME) $?
 
+$(SOFA_SHLIB_NAME): $(SOFA_OBS)
+	$(CC) $(LDFLAGS) -shared -Wl,-soname,$(SOFA_SHLIB_NAME).0 -lm -o $(SOFA_SHLIB_NAME).0.0 $? 
+
+
 # Install the header files.
 $(SOFA_INC) : $(INSTALL_DIRS) $(SOFA_INC_NAMES)
 	cp $(SOFA_INC_NAMES) $(SOFA_INC_DIR)