-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
38 lines (26 loc) · 798 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
INCDIR = ./inc
SRCDIR = ./src
OBJDIR = ./obj
OUTDIR = ./bin
SRCS = $(wildcard $(SRCDIR)/*.c $(SRCDIR)/**/*.c)
CC = gcc
CCFLAGS = -I$(INCDIR) -Wall -Wextra -Wpedantic -ansi -g
AR = ar
ARFLAGS = rvs
all: libstacker.so libstacker.a
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c -o $@ $< $(CCFLAGS)
$(OBJDIR)/%.po: $(SRCDIR)/%.c
$(CC) -fPIC -c -o $@ $< $(CCFLAGS)
OBJS := $(patsubst %.c, %.o, $(SRCS))
OBJS := $(patsubst $(SRCDIR)%, $(OBJDIR)%, $(OBJS))
POBJS := $(patsubst %.c, %.po, $(SRCS))
POBJS := $(patsubst $(SRCDIR)%, $(OBJDIR)%, $(POBJS))
libstacker.so: $(POBJS)
$(CC) -shared -Wl,-soname,$@ -o $(OUTDIR)/$@ $^ $(CCFLAGS)
libstacker.a: $(OBJS)
$(AR) $(ARFLAGS) $(OUTDIR)/$@ $^
.PHONY: clean
clean:
rm -f $(OUTDIR)/* $(OBJDIR)/*.o $(OBJDIR)/*.po \
$(OBJDIR)/**/*.o $(OBJDIR)/**/*.po