summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 87d1385763a339b104996db81c2608f1c2fc616c (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
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
-include config.mk

ABI_VERSION := 0
SONAME := libuniso.so.$(ABI_VERSION)

progs-y	+= uniso

INCLUDES := uniso.h
TARGETS := libuniso.a $(progs-y)

CFLAGS ?= -g -Wall -Werror
CFLAGS += -fPIC
CFLAGS += -I.


prefix ?= /usr
libdir = $(prefix)/lib
bindir = $(prefix)/bin
includedir= $(prefix)/include

INSTALLDIR := install -d
INSTALL := install

install-progs-y := $(INSTALLDIR) $(DESTDIR)$(bindir) && \
		   $(INSTALL) $(progs-y) $(DESTDIR)$(bindir)
install-libs-y := $(INSTALLDIR) $(DESTDIR)$(libdir) && \
		  $(INSTALL) libuniso.a $(DESTDIR)$(libdir)

libuniso.a_OBJS = libuniso.o

$(SONAME)_OBJS = $(libuniso.a_OBJS)
$(SONAME)_LDFLAGS = -shared -Wl,-soname,$(SONAME)

uniso_OBJS := uniso.o
uniso_LDFLAGS += -L.

all:	$(TARGETS)

ifneq ($(ENABLE_SHARED),)
shlibs-y += $(SONAME) libuniso.so
install-shlibs-y := $(INSTALLDIR) $(DESTDIR)$(libdir) && \
		    $(INSTALL) $(SONAME) $(DESTDIR)$(libdir) && \
		    ln -sf $(SONAME) $(DESTDIR)$(libdir)/libuniso.so
uniso_LIBS := -luniso
else
uniso_LIBS := libuniso.a
endif
TARGETS += $(shlibs-y)

$(SONAME): $($(SONAME)_OBJS)
libuniso.so: $(SONAME)
	ln -s $< $@

uniso: $(shlib-y)

libuniso.a: $(libuniso.a_OBJS)
	$(AR) rcs $@ $^
	
%.o: %.c
	$(CC) $(CFLAGS) $($@_CFLAGS) -c $^

uniso: $(uniso_OBJS) $(shlibs-y)

uniso $(SONAME):
	$(CC) $(LDFLAGS) $($@_LDFLAGS) -o $@ $($@_OBJS) $($@_LIBS)

clean:
	rm -f $(TARGETS) *.o *.a *.so *.so.$(ABI_VERSION)

shared: $(SONAME)

install: $(TARGETS) $(INCLUDES)
	$(INSTALLDIR) $(DESTDIR)$(includedir)
	$(INSTALL) $(INCLUDES) $(DESTDIR)$(includedir)
	$(install-progs-y)
	$(install-libs-y)
	$(install-shlibs-y)