-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
59 lines (44 loc) · 1.28 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
CC = gcc
AR = ar
MAIN_OBJECT = main.o
OBJECTS_LOOP = basicClassification.o advancedClassificationLoop.o
OBJECTS_REC = basicClassification.o advancedClassificationRecursion.o
DEPS = NumClass.h
CFLAGS =-Wall
LIB_LOOP_S = libclassloops.a
LIB_REC_S = libclassrec.a
LIB_LOOP_D = libclassloops.so
LIB_REC_D = libclassrec.so
# Declare them as non-files
.PHONY: all clean loops recursives recursived loopd
# All makes
all: mains maindloop maindrec loops recursives recursived loopd
loops: $(LIB_LOOP_S)
recursives: $(LIB_REC_S)
recursived: $(LIB_REC_D)
loopd: $(LIB_LOOP_D)
# Programs
mains: $(MAIN_OBJECT) $(LIB_REC_S)
$(CC) -o $@ $< $(CFLAGS) ./$(LIB_REC_S) -L.
maindloop: $(MAIN_OBJECT) $(LIB_LOOP_D)
$(CC) -o $@ $< $(CFLAGS) ./$(LIB_LOOP_D) -L.
maindrec: $(MAIN_OBJECT) $(LIB_REC_D)
$(CC) -o $@ $< $(CFLAGS) ./$(LIB_REC_D) -L.
# Creates all the object files including main.o
$(MAIN_OBJECT): main.c $(DEPS)
$(CC) -c $^ $(CFLAGS)
%.o: %.c $(DEPS)
$(CC) -c $^ $(CFLAGS) -fPIC
# Make libraries:
$(LIB_LOOP_S): $(OBJECTS_LOOP)
$(AR) rcs $@ $^
# ranlib $@
$(LIB_REC_S): $(OBJECTS_REC)
$(AR) rcs $@ $^
# ranlib $@
$(LIB_LOOP_D): $(OBJECTS_LOOP)
$(CC) -shared $^ -Wall -o $@
$(LIB_REC_D): $(OBJECTS_REC)
$(CC) -shared $^ -Wall -o $@
clean:
rm -f *.o *.a *.so mains maindloop maindrec *.gch