-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
58 lines (42 loc) · 928 Bytes
/
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
CC=gcc
CFLAGS=-W -Wall -ansi -pedantic -g
LDFLAGS=
EXEC=mm
OBJDIR=obj
SRCDIR=src
LIBDIR=lib
LIBNAME=libmm
ifdef DEBUG
CFLAGS+= -g
endif
ifdef DYNAMIC
CFLAGS+= -fPIC
endif
INCLUDES=-I./include
SOURCES=$(wildcard $(SRCDIR)/*.c)
OBJ=$(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SOURCES))
all: before $(EXEC) lib
before:
@echo Objects: $(OBJ)
ifdef DYNAMIC
lib: dynlib
else
lib: staticlib
endif
after:
staticlib: $(OBJ)
@echo '###### Making Static library ######'
ar rcs $(LIBDIR)/$(LIBNAME).a $(OBJ)
dynlib:
@echo '###### Making Dynamic library ######'
$(CC) -shared -Wl,-soname,$(LIBNAME).so.1 -o $(LIBDIR)/$(LIBNAME).so.1.0.1 $(OBJ)
clean:
rm -f obj/*.o
rm -f $(EXEC).exe
rm -f $(LIBDIR)/*
# no tuning after that
$(EXEC): $(OBJ)
$(CC) $(CFLAGS) -o $(EXEC) main.c $(OBJ) $(INCLUDES)
.PHONY: before $(EXEC) after staticlib dynlib lib
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -o $@ -c $< $(INCLUDES)