-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
174 lines (135 loc) · 4.64 KB
/
Makefile
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
166
167
168
169
170
171
172
173
174
# C compiler
CC=/usr/bin/gcc
# Output Path
OUT=./Bin
# Prefix Path
PREFIX=/usr/local
# Software Name
NAME=numC
NAME_TEST=${NAME}_TEST
# Compiler Flags:
# -O3 => Maximum Optimisation Level
# -finline_functions => Consider All Functions For Inlining
# -findirect-inlining =>
# -fexpensive-optimizations => Add More Minor TIme Consuming Optimisations
# -g => Adds Debug Informations To The Executable File
# -Wall => Turns On Most Of Compiler Warnings
CFLAGS=-O3 -finline-functions -findirect-inlining -fexpensive-optimizations -fopenmp
DEBUG=-g -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
LIB=-shared
LIB_LOAD = -L ${OUT} -l :${NAME}.so
# Add Math Library
MATH=-lm
# Headers Path
HEADERS=./Combinatory/combinatory.h \
./Integrals/integrals.h \
./Matrices/matrix.h \
./NumberTheory/number_theory.h \
./Roots/roots.h \
./StatisticDescriptive/statistic_descriptive.h \
./Vectors/vector.h
HEADERS_TEST =./Test/test.h \
${OUT}/${NAME}.h
# Source Code Files
COMBINATORY=./Combinatory/bynomial_factor.c \
./Combinatory/combination_simple.c \
./Combinatory/combination_rep.c \
./Combinatory/disposition_simple.c \
./Combinatory/disposition_rep.c \
./Combinatory/permutation_simple.c \
./Combinatory/permutation_rep.c
INTEGRALS=./Integrals/integ_rect.c \
./Integrals/integ_trap.c \
./Integrals/integ_cav_simpson.c
MATRICES=./Matrices/determinant.c \
./Matrices/matrix_print.c \
./Matrices/submatrix.c \
./Matrices/swap.c
NUMBER_THEORY=./NumberTheory/factorial.c \
./NumberTheory/perfect.c \
./NumberTheory/prime.c
ROOTS=./Roots/dicotomic.c \
./Roots/cords.c \
./Roots/newton.c
STATISTIC_DESCRIPTIVE=./StatisticDescriptive/central_tendency.c \
./StatisticDescriptive/dispersion.c
TEST=./Test/test.c \
./Test/test_matrix.c \
./Test/test_statistic_descriptive.c
VECTORS=./Vectors/vector_el_div.c \
./Vectors/vector_el_mult.c \
./Vectors/vector_el_sub.c \
./Vectors/vector_el_sum.c \
./Vectors/vector_num_div.c \
./Vectors/vector_num_mult.c \
./Vectors/vector_num_sub.c \
./Vectors/vector_num_sum.c \
./Vectors/vector_reverse.c \
./Vectors/vector_square_power.c \
./Vectors/vector_vector_div.c \
./Vectors/vector_vector_inner.c \
./Vectors/vector_vector_mult.c \
./Vectors/vector_vector_sub.c \
./Vectors/vector_vector_sum.c
SOURCE=${COMBINATORY} ${INTEGRALS} ${MATRICES} ${NUMBER_THEORY} ${ROOTS} ${STATISTIC_DESCRIPTIVE} ${VECTORS}
SOURCE_TEST= ${TEST}
# Make
all:
# Make Clean
make clean
# GCC Compiler -> Library Compilation
${CC} -o ${OUT}/${NAME}.so ${SOURCE} ${HEADERS} ${CFLAGS} ${MATH} ${LIB}
# Creating The Library Header File
echo "#ifndef _NUMC_H" >> ${OUT}/${NAME}.h
echo "#define _NUMC_H" >> ${OUT}/${NAME}.h
echo "" >> ${OUT}/${NAME}.h
# Add standard libraries headers
echo "#include \"stdio.h"\" >> ${OUT}/${NAME}.h
echo "#include \"stdlib.h"\" >> ${OUT}/${NAME}.h
echo "#include \"math.h"\" >> ${OUT}/${NAME}.h
echo "" >> ${OUT}/${NAME}.h
# Remove #include, #ifndef and #endif lines from the original headers
cat ${HEADERS} | sed '/#include/ d' | sed '/#ifndef/ d' | sed '/#endif/ d' | sed '/#define _/ d' >> ${OUT}/${NAME}.h
echo "" >> ${OUT}/${NAME}.h
echo "#endif\n" >> ${OUT}/${NAME}.h
# Copy Files In Main Directory
cp ${OUT}/${NAME}.so ${NAME}.so
cp ${OUT}/${NAME}.h ${NAME}.h
debug:
# Make Clean
make clean
# GCC Compiler -> Library Compilation (With Debug Enabled)
${CC} -o ${OUT}/${NAME} ${SOURCE} ${HEADERS} ${CFLAGS} ${DEBUG} ${MATH} ${LIB}
# Creating The Library Header File
echo "#ifndef _NUMC_H" >> ${OUT}/${NAME}.h
echo "#define _NUMC_H" >> ${OUT}/${NAME}.h
echo "" >> ${OUT}/${NAME}.h
# Add standard libraries headers
echo "#include \"stdio.h"\" >> ${OUT}/${NAME}.h
echo "#include \"stdlib.h"\" >> ${OUT}/${NAME}.h
echo "#include \"math.h"\" >> ${OUT}/${NAME}.h
echo "" >> ${OUT}/${NAME}.h
# Remove #include, #ifndef and #endif lines from the original headers
cat ${HEADERS} | sed '/#include/ d' | sed '/#ifndef/ d' | sed '/#endif/ d' | sed '/#define _/ d' >> ${OUT}/${NAME}.h
echo "" >> ${OUT}/${NAME}.h
echo "#endif\n" >> ${OUT}/${NAME}.h
# Copy Files In Main Directory
cp ${OUT}/${NAME}.so ${NAME}.so
cp ${OUT}/${NAME}.h ${NAME}.h
test:
#make all
${CC} -o ${OUT}/${NAME_TEST} ${SOURCE_TEST} ${HEADERS_TEST} ${CFLAGS} ${MATH} ${LIB_LOAD}
cp ${OUT}/${NAME_TEST} ${NAME_TEST}
clean:
-rm -f ${NAME}
-rm -f ${OUT}/${NAME}
-rm -f ${NAME}.so
-rm -f ${OUT}/${NAME}.so
-rm -f ${NAME}.h
-rm -f ${OUT}/${NAME}.h
-rm -f ${NAME_TEST}
-rm -f ${OUT}/${NAME_TEST}
install:
install -s ${OUT}/${NAME}.so ${PREFIX}/lib
uninstall:
-rm -f ${PREFIX}/bin/${NAME}