forked from laserswald/todoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (58 loc) · 1.57 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
# Skeleton Medium-sized Makefile for C programs.
#
# by Ben Davenport-Ray
BINNAME=todoc
VERSION=0.2.5
CC=gcc
BINDIR=bin
LIBNAME=lib$(BINNAME)
DYNLIB=$(BINNAME).dll
STATLIB=$(LIBNAME).a
TESTPRG=$(BINNAME)_test
EXECUTABLE=$(BINNAME)
SONAME=$(LIBNAME).so.$(VERSION)
PKGNAME=$(BINNAME)-$(VERSION)
MODULES=
# Source file gathering.
SOURCE=*.c
SRCDIR=src
SRCS:=$(wildcard $(SRCDIR)/$(SOURCE))
INCLUDE=include
OBJECT=$(SRCS:.c=.o)
OBJDIR=obj
OBJS:=$(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(OBJECT))
LIBOBJS:=$(filter-out obj/todo.o,$(OBJS))
CFLAGS= -Wall -I$(INCLUDE) -g
LDFLAGS= -g -lm -L. -ltodoc #removed -static flag so including math.h would work in task.c
LFLAGS= -shared -Wl,-soname,$(SONAME)
TESTDIR=test
TESTSRC:=$(wildcard $(TESTDIR)/$(SOURCE))
TESTFLAGS=
all: build check
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(DYNLIB): $(LIBOBJS)
$(CC) $(LFLAGS) $^ -o $(DYNLIB)
$(STATLIB): $(LIBOBJS)
ar rcs $@ $^
$(TESTPRG): $(TESTSRC)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
$(EXECUTABLE): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
build: setup $(STATLIB) $(EXECUTABLE) $(TESTPRG)
rebuild: clean build
clean:
rm -r $(OBJDIR)
rm $(STATLIB)
rm $(TESTPRG)
rm $(EXECUTABLE)
dist:
tar -cvaf $(PKGNAME).tar.gz $(SRCS) $(INCLUDE)/*.h $(TESTSRC) test/*.h README.mkdn Makefile
distexec:
$(ZIP) $(PKGNAME)-win32.zip README.md $(EXECUTABLE)
check: $(TESTPRG)
./$(TESTPRG)
setup:
mkdir -p $(BINDIR)
mkdir -p $(OBJDIR)
.PHONY: all build rebuild clean dist distexec check install setup