aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 094eb7ba2d9624cde21491e423d83a5c8190822b (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

OS = linux
# linux = Linux
# macos = Mac OS
include $(OS).mk

LIB_MAJOR = 1
LIB_MINOR = 0
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)


HDR =\
	liberror-libc.h\
	internal.h

OBJ =\
	abs.o\
	calloc.o\
	chdir.o\
	check_kernel_version.o\
	imaxabs.o\
	labs.o\
	llabs.o\
	lseek.o\
	malloc.o\
	pipe.o\
	putenv.o\
	raise.o\
	realloc.o\
	recv.o\
	send.o\
	set_error_one_file.o\
	setenv.o\
	shutdown.o\
	sockatmark.o\
	strdup.o\
	unsetenv.o

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


all: liberror-libc.a liberror-libc.$(LIBEXT)
$(OBJ): $(@:.o=.c) $(HDR)
$(LOBJ): $(@:.lo=.c) $(HDR)

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

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

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

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

install: liberror-libc.a liberror-libc.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/liberror-libc"
	cp -- liberror-libc.a "$(DESTDIR)$(PREFIX)/lib"
	cp -- liberror-libc.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/liberror-libc.$(LIBMINOREXT)"
	ln -sf -- liberror-libc.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/liberror-libc.$(LIBMAJOREXT)"
	ln -sf -- liberror-libc.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/liberror-libc.$(LIBEXT)"
	cp -- liberror-libc.h "$(DESTDIR)$(PREFIX)/include"
	cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/liberror-libc"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/liberror-libc."*
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/liberror-libc.h"
	-rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/liberror-libc"

clean:
	-rm -f -- *.o *.lo *.a *.so *.so.* *.su *.test

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

.PHONY: all install uninstall clean