aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
blob: 6ac73b0b823b49229f3e65d5e01f75c3b9e7f39b (plain) (blame)
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
VERSION = \"$(shell git describe --tags --dirty)\"

CC=gcc

IFLAGS = -I.
LFLAGS = -lm

CFLAGS = -Wall -Werror --std=c99 -pedantic $(IFLAGS) -D_DEFAULT_SOURCE -DVERSION=${VERSION}
LDFLAGS = $(LFLAGS)

PREFIX = /usr/local

OBJ_BIN = src/opendeco.o src/opendeco-cli.o src/opendeco-conf.o src/deco.o src/output.o src/schedule.o toml/toml.o
OBJ_LIB = src/deco.o src/output.o src/schedule.o
OBJ_TST = test/opendeco_test.o test/deco_test.o src/deco.o minunit/minunit.o

DEPS = $(shell find -type f -name "*.dep")

all: opendeco opendeco_test libopendeco.a

run: opendeco
	./opendeco -d 30 -t 120 -g EAN32 --decogasses EAN50

test: opendeco_test
	./opendeco_test

lib: libopendeco.a

install: opendeco
	mkdir -p ${DESTDIR}${PREFIX}/bin
	cp -f opendeco ${DESTDIR}${PREFIX}/bin
	chmod 755 ${DESTDIR}${PREFIX}/bin/opendeco

uninstall:
	rm -f ${DESTDIR}${PREFIX}/bin/opendeco

opendeco: $(OBJ_BIN)
	@echo "  LD      $@"
	@$(CC) -o opendeco $(OBJ_BIN) $(LDFLAGS)

opendeco_test: $(OBJ_TST)
	@echo "  LD      $@"
	@$(CC) -o opendeco_test $(OBJ_TST) $(LDFLAGS)

libopendeco.a: $(OBJ_LIB)
	@ar rs libopendeco.a $(OBJ_LIB)

%.o: %.c
	@echo "  CC      $@"
	@mkdir -p .dep/$(dir $@)
	@$(CC) $(CFLAGS) -MD -MF .dep/$@.dep -o $@ -c $<

clean:
	rm -f $(OBJ_BIN)
	rm -f $(OBJ_LIB)
	rm -f $(OBJ_TST)
	rm -f opendeco
	rm -f opendeco_test
	rm -f libopendeco.a
	rm -rf .dep

-include $(DEPS)

.PHONY: all run test lib install uninstall clean