compile_type = release
CC = gcc
AR = ar
RANLIB = ranlib
CCFLAGS = -Wall -Wextra -Wshadow -Wconversion -std=c99 -pedantic -O2 -g
ifeq ($(compile_type), release)
CCFLAGS =
endif
SRCS=$(wildcard src/*.c)
SRCS+=$(wildcard *.c)
OBJS=$(SRCS:%.c=%.o)
INCLUDES=$(wildcard include/*.h)
LIBS=$(wildcard lib/*.a)
DLLS=$(wildcard bin/*.so)
$(OBJS): $(INCLUDES)
libmath.so: $(OBJS)
$(CC) -shared -fPIC $(CCFLAGS) $(SRCS) -o $@
make clean
mathTest.o: $(INCLUDES)
mathTest: mathTest.o $(DLLS)
$(CC) $(CCFLAGS) -o $@ $^
make clean
# libmath.a: $(OBJS)
# $(AR) rcu $@ $^
# $(RANLIB) $@
# make clean
# mathTest.o: $(INCLUDES)
# mathTest: mathTest.o $(LIBS)
# $(CC) $(CCFLAGS) -o $@ $^
# make clean
clean:
rm -rf $(OBJS)
reinstall:
@echo "Please comming soon.";
// math.h
#if !defined(__MATH__)
#define __MATH__
int sum(int value1, int value2);
int sub(int value1, int value2);
int mul(int value1, int value2);
int div(int value1, int value2);
#endif // __MATH__
// math.c
int sum(int value1, int value2) {
return value1 + value2;
}
int sub(int value1, int value2) {
return value1 - value2;
}
int mul(int value1, int value2) {
return value1 * value2;
}
int div(int value1, int value2) {
return value1 / value2;
}
#include <stdio.h>
#include "include/math.h"
int main(int argc, char *argv[]) {
int a = 20;
int b = 10;
printf("sum: %d\n", sum(a, b));
printf("sub: %d\n", sub(a, b));
printf("mul: %d\n", mul(a, b));
printf("div: %d\n", div(a, b));
return 0;
}