aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: a35381c6ba238d43a5013fa00d37290dee1f1f2f (plain)
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
CC     ?= cc
CFLAGS ?= -O2 -g
PREFIX ?= /usr/local

__CFLAGS := -I./include/ -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra
VERSION  := $(shell git tag | tail -n 1 | tr -d v)

all: libuconfig.a test/uconfig_test

libuconfig.a: src/uconfig.o
	ar rcs $@ $^

src/uconfig.o: src/uconfig.c include/uconfig.h
	$(CC) $(__CFLAGS) -c -fPIC $(CFLAGS) -o $@ $<

test/uconfig_test: test/uconfig_test.o libuconfig.a
	$(CC) -o $@ $^

test/uconfig_test.o: test/uconfig_test.c include/uconfig.h
	$(CC) $(__CFLAGS) -c -o $@ $<

check: all
	./test/uconfig_test

clean:
	rm -f libuconfig.a src/uconfig.o

dist:
	git archive --output="uconfig-$(VERSION).tar.gz" \
	            --prefix="uconfig-$(VERSION)/" \
	            "v$(VERSION)"

install: libuconfig.a
	mkdir -p $(PREFIX)/lib $(PREFIX)/include
	install --mode=0644 libuconfig.a      $(PREFIX)/lib/
	install --mode=0644 include/uconfig.h $(PREFIX)/include/

uninstall:
	rm -f $(PREFIX)/lib/libuconfig.a $(PREFIX)/include/uconfig.h

.PHONY: all check clean dist install uninstall