aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 3ee1e781ecd81c2b35280664d0ed68fe8d8c401d (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
65
66
67
68
69
70
71
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

# Change to macos.mk for Mac OS
OSCONFIGFILE = linux.mk
include $(OSCONFIGFILE)


LIB_MAJOR = 2
LIB_MINOR = 0

LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)

MAN3 = libhaiku.7
MAN7 = libhaiku_generic.3 libhaiku_perror.3 libhaiku_perror2.3 libhaiku_strerror.3

OBJ = libhaiku.o
HDR = libhaiku.h

LOBJ = $(OBJ:.o=.lo)


all: libhaiku.a libhaiku.$(LIBEXT)
$(OBJ): $(HDR)
$(LOBJ): $(HDR)

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)

.c.lo:
	$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)

libhaiku.$(LIBEXT): $(LOBJ)
	$(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)

libhaiku.a: $(OBJ)
	-rm -f -- $@
	$(AR) rc $@ $(OBJ)
	$(AR) -s $@

install: libhaiku.$(LIBEXT) libhaiku.a
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
	cp -- libhaiku.a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- libhaiku.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libhaiku.$(LIBMINOREXT)"
	ln -sf -- libhaiku.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libhaiku.$(LIBMAJOREXT)"
	ln -sf -- libhaiku.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libhaiku.$(LIBEXT)"
	cp -- libhaiku.h "$(DESTDIR)$(PREFIX)/include/"
	cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3/"
	cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7/"

uninstall:
	-rm -f "$(DESTDIR)$(PREFIX)/lib/libhaiku.a"
	-rm -f "$(DESTDIR)$(PREFIX)/lib/libhaiku.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libhaiku.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libhaiku.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libhaiku.h"
	-cd -- "$(DESTDIR)$(MANPREFIX)/man3/" && rm -rf -- $(MAN3)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man7/" && rm -rf -- $(MAN7)

clean:
	-rm -f -- *.o *.lo *.a *.su *.$(LIBEXT) *.$(LIBEXT).*

.SUFFIXES:
.SUFFIXES: .lo .o .c

.PHONY: all install uninstall clean