summary refs log tree commit diff stats
path: root/Makefile
blob: e4ff5b790a5e86bb21a26ec6de2720670eeaf3bd (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
AR = ar
CC = cc
CFLAGS = -g -O0 -Wall -Wextra -Wno-discarded-qualifiers
TARGET_LIB_DYNAMIC = libyuri.so
TARGET_LIB_STATIC = libyuri.a

PREFIX = /usr

OBJS = yuri.o decode.o encode.o normalize.o strlcpy.o strlcat.o
MANPAGES = man/uri.3 man/uri_get.3 man/uri_set.3 man/uri_unset.3

all: $(TARGET_LIB_STATIC) $(TARGET_LIB_DYNAMIC)

$(TARGET_LIB_STATIC): $(OBJS)
	$(AR) rcs $@ $(OBJS)

$(TARGET_LIB_DYNAMIC): $(OBJS)
	$(CC) -shared -o $@ $(OBJS)

test: $(TARGET_LIB_STATIC)
	$(CC) -O0 -g -o $@ test.c $(TARGET_LIB_STATIC)

install: all
	mkdir -p $(PREFIX)/lib
	cp $(TARGET_LIB_STATIC) $(PREFIX)/lib
	cp $(TARGET_LIB_DYNAMIC) $(PREFIX)/lib
	ldconfig -n $(PREFIX)/lib
	mkdir -p $(PREFIX)/include
	cp yuri.h $(PREFIX)/include
	mkdir -p $(PREFIX)/share/man/man3
	cp $(MANPAGES) $(PREFIX)/share/man/man3

clean:
	rm -f $(TARGET_LIB_STATIC) $(TARGET_LIB_DYNAMIC) $(OBJS) test

.PHONY: all clean