-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (40 loc) · 832 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
# http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
# includes
IDIR=./include
_DEPS=sos.h
DEPS=$(patsubst %,$(IDIR)/%,$(_DEPS))
# libraries
LDIR=./lib
LIBS=-lcurl
# source
SDIR=./src
# object files
ODIR=$(SDIR)/obj
_OBJ=cmd.o error_filter.o sos.o
OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ))
# compilation
CC=gcc
CFLAGS=-I$(IDIR) -I$(LDIR)
ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG
endif
sos: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(ODIR)/%.o: $(SDIR)/%.c $(DEPS) | $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR):
mkdir -p $@
.PHONY: clean install uninstall test
clean:
rm -f $(ODIR)/*.o sos
# installation
PREFIX=/usr/local/bin
BINARY=sos
CONFIG=.sosrc
install: sos
cp $< $(PREFIX)/$(BINARY)
cp -n $(CONFIG).default $(HOME)/$(CONFIG) || true
uninstall:
rm $(PREFIX)/$(BINARY)
test: install
./tests/run_tests.sh