aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 202fdce49181220dc27c77b9ee85621af524fc66 (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
.POSIX:

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


CONFIGFILE = config.mk
include $(CONFIGFILE)

OS = linux
# Linux:   linux
# Mac OS:  macos
# Windows: windows
include mk/$(OS).mk



OBJ =\
	libsecauth_client_hash.o\
	libsecauth_format_spec.o\
	libsecauth_parse_spec.o\
	libsecauth_server_hash.o

HDR =\
	libsecauth.h

BIN =\
	demo-setup\
	demo-login

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


all: libsecauth.a libsecauth.$(LIBEXT) $(BIN)
$(OBJ): $($@:.o=.c) $(HDR)
demo-setup.o: demo-setup.c $(HDR)
demo-login.o: demo-login.c $(HDR)

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

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

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

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

demo-setup: demo-setup.o libsecauth.a
	$(CC) -o $@ demo-setup.o libsecauth.a $(LDFLAGS)

demo-login: demo-login.o libsecauth.a
	$(CC) -o $@ demo-login.o libsecauth.a $(LDFLAGS)

install: libsecauth.a libsecauth.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	cp -- libsecauth.a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- libsecauth.h "$(DESTDIR)$(PREFIX)/include/"
	cp -- libsecauth.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libsecauth.$(LIBMINOREXT)"
	ln -sf -- libsecauth.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libsecauth.$(LIBMAJOREXT)"
	ln -sf -- libsecauth.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libsecauth.$(LIBEXT)"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsecauth.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsecauth.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsecauth.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsecauth.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libsecauth.h"

clean:
	-rm -rf -- *.o *.a *.so *.lo *.su *.dll *.dylib democonfig $(BIN)

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

.PHONY: all install uninstall clean