1# $OpenLDAP$
2# Copyright 2015 Howard Chu <hyc@symas.com>
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted only as authorized by the OpenLDAP
7# Public License.
8#
9# A copy of this license is available in the file LICENSE in the
10# top-level directory of the distribution or, alternatively, at
11# <http://www.OpenLDAP.org/license.html>.
12
13LDAP_SRC = ../../..
14LDAP_BUILD = $(LDAP_SRC)
15LDAP_INC = -I$(LDAP_BUILD)/include -I$(LDAP_SRC)/include -I$(LDAP_SRC)/servers/slapd
16LDAP_LIB = $(LDAP_BUILD)/libraries/libldap/libldap.la \
17	$(LDAP_BUILD)/libraries/liblber/liblber.la
18
19LIBTOOL = $(LDAP_BUILD)/libtool
20INSTALL = /usr/bin/install
21CC = cc
22OPT = -pipe -O2 -isystem /usr/local/include -fno-strict-aliasing
23DEFS = -DSLAPD_OVER_ADREMAP=SLAPD_MOD_DYNAMIC
24INCS = $(LDAP_INC)
25LIBS = $(LDAP_LIB)
26
27PROGRAMS = adremap.la
28MANPAGES = slapo-adremap.5
29LTVER = 0:0:0
30
31prefix=/usr/local
32exec_prefix=$(prefix)
33ldap_subdir=/openldap
34
35libdir=$(exec_prefix)/lib
36libexecdir=$(exec_prefix)/libexec
37moduledir = $(libexecdir)$(ldap_subdir)
38mandir = $(exec_prefix)/share/man
39man5dir = $(mandir)/man5
40
41.SUFFIXES: .c .o .lo
42
43.c.lo:
44	$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(OPT) $(CPPFLAGS) $(DEFS) $(INCS) -c $<
45
46all: $(PROGRAMS)
47
48adremap.la: adremap.lo
49	$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -version-info $(LTVER) \
50	-rpath $(moduledir) -module -o $@ $? $(LIBS)
51
52clean:
53	rm -rf *.o *.lo *.la .libs
54
55install: install-lib install-man FORCE
56
57install-lib: $(PROGRAMS)
58	mkdir -p $(DESTDIR)$(moduledir)
59	for p in $(PROGRAMS) ; do \
60		$(LIBTOOL) --mode=install cp $$p $(DESTDIR)$(moduledir) ; \
61	done
62
63install-man: $(MANPAGES)
64	mkdir -p  $(DESTDIR)$(man5dir)
65	$(INSTALL) -m 644 $(MANPAGES) $(DESTDIR)$(man5dir)
66
67FORCE:
68
69