~ubuntu-branches/ubuntu/raring/apparmor/raring

« back to all changes in this revision

Viewing changes to changehat/libapparmor/Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-03-23 16:42:01 UTC
  • Revision ID: james.westby@ubuntu.com-20070323164201-jkax6f0oku087b7l
Tags: upstream-2.0.1+510.dfsg
ImportĀ upstreamĀ versionĀ 2.0.1+510.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: Makefile 199 2006-11-04 21:34:47Z steve-beattie $
 
2
# ----------------------------------------------------------------------
 
3
#    Copyright (c) 2004, 2005, 2006 NOVELL (All rights reserved)
 
4
#
 
5
#   This program is free software; you can redistribute it and/or
 
6
#   modify it under the terms of version 2.1 of the GNU Lesser
 
7
#   General Public License published by the Free Software Foundation.
 
8
#
 
9
#   This program is distributed in the hope that it will be useful,
 
10
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
#   GNU General Public License for more details.
 
13
#
 
14
#   You should have received a copy of the GNU Lesser General Public
 
15
#   License along with this program; if not, contact Novell, Inc.
 
16
# ----------------------------------------------------------------------
 
17
NAME := libapparmor
 
18
all:
 
19
COMMONDIR:=$(strip $(shell if [ -d "../common/" ] ; then \
 
20
                     echo "../common/" ; \
 
21
             elif [ -d "../../common/" ] ; then \
 
22
                     echo "../../common/" ; \
 
23
             else \
 
24
                     echo "/common_dir_not_found" ; \
 
25
             fi))
 
26
 
 
27
include common/Make.rules
 
28
 
 
29
COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
 
30
ifeq ($(COMMONDIR_EXISTS), true)
 
31
common/Make.rules: $(COMMONDIR)/Make.rules
 
32
        ln -sf $(COMMONDIR) .
 
33
endif
 
34
 
 
35
SO_VERS         = 1
 
36
DESTDIR         = 
 
37
LIB             = lib/
 
38
LIBDIR          = /usr/${LIB}
 
39
 
 
40
TARGET=libapparmor
 
41
TARGETS=${TARGET}.so ${TARGET}.a
 
42
 
 
43
OLDTARGET=libimmunix.so.1
 
44
 
 
45
OBJECTS=change_hat.o
 
46
TESTS=tst-sgdh tst-cdh tst-sgkey tst-sgdh-static tst-cdh-static tst-sgkey-static
 
47
 
 
48
CFLAGS=-g -O2 -Wall -Wstrict-prototypes -pipe
 
49
EXTRA_CFLAGS=$(CFLAGS) -fpic -D_REENTRANT
 
50
ARFLAGS=-rcs
 
51
 
 
52
TEST_CFLAGS=$(CFLAGS) $(CANARY_FLAG) $(FORMATGUARD_FLAG)
 
53
TEST_LDFLAGS= -L. -limmunix
 
54
 
 
55
all: ${TARGETS} ${OLDTARGET}
 
56
 
 
57
%.o: %.c
 
58
        $(CC) ${EXTRA_CFLAGS} -c -shared -o $@ $<
 
59
 
 
60
${TARGET}.so: ${OBJECTS}
 
61
        ${CC} ${EXTRA_CFLAGS} -o $@.$(SO_VERS) -Wl,-soname,$@.$(SO_VERS) -Wl,--version-script=${TARGET}.map -W,-z,defs -shared -dynamic  $^
 
62
        ln -fs $@.$(SO_VERS) $@
 
63
 
 
64
${OLDTARGET}: ${OBJECTS} libimmunix_warning.o
 
65
        ${CC} ${EXTRA_CFLAGS} -o $@ -Wl,-soname,$@ -Wl,--version-script=${TARGET}.map -W,-z,defs -shared -dynamic $^
 
66
 
 
67
${TARGET}.a: ${OBJECTS}
 
68
        ar ${ARFLAGS} $@ $^
 
69
 
 
70
${POSTINSTALLBIN}: ${POSTINSTALLBIN}.c
 
71
        $(CC) -static -Os -o $@ $(CANARY_FLAG) $(FORMATGUARD_FLAG) $^
 
72
 
 
73
# Ugh, dunno how to do an auto rule for the TESTS
 
74
tst-sgdh: tst-sgdh.c ${TARGET}.so
 
75
        $(CC) ${TEST_CFLAGS} -o $@ $< ${TEST_LDFLAGS}
 
76
 
 
77
tst-cdh: tst-cdh.c ${TARGET}.so
 
78
        $(CC) ${TEST_CFLAGS} -o $@ $< ${TEST_LDFLAGS}
 
79
 
 
80
tst-sgkey: tst-sgkey.c ${TARGET}.so
 
81
        $(CC) ${TEST_CFLAGS} -o $@ $< ${TEST_LDFLAGS}
 
82
 
 
83
tst-sgdh-static: tst-sgdh.c ${TARGET}.a
 
84
        $(CC) -static ${TEST_CFLAGS} -o $@ $< ${TEST_LDFLAGS}
 
85
 
 
86
tst-cdh-static: tst-cdh.c ${TARGET}.a
 
87
        $(CC) -static ${TEST_CFLAGS} -o $@ $< ${TEST_LDFLAGS}
 
88
 
 
89
tst-sgkey-static: tst-sgkey.c ${TARGET}.a
 
90
        $(CC) -static ${TEST_CFLAGS} -o $@ $< ${TEST_LDFLAGS}
 
91
 
 
92
check: $(TESTS)
 
93
        -LD_LIBRARY_PATH=. ./tst-sgdh
 
94
        -LD_LIBRARY_PATH=. ./tst-cdh
 
95
        -LD_LIBRARY_PATH=. ./tst-sgkey
 
96
        -./tst-sgdh-static
 
97
        -./tst-cdh-static
 
98
        -./tst-sgkey-static
 
99
 
 
100
.PHONY: install
 
101
install: $(SPECFILE) $(TARGETS) $(OLDTARGET)
 
102
        install -d $(DESTDIR)/${LIB} $(DESTDIR)${LIBDIR}
 
103
        install -d ${DESTDIR}/usr/include/sys
 
104
        mv -f $(TARGET).so.$(SO_VERS) $(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS)
 
105
        install -m 755 $(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS) ${DESTDIR}/${LIB}
 
106
        ${LDCONFIG} -n ${DESTDIR}/${LIB}
 
107
        install -m 755 $(TARGET).a ${DESTDIR}${LIBDIR}
 
108
        install -m 644 apparmor.h ${DESTDIR}/usr/include/sys
 
109
        ln -sf /${LIB}/$(TARGET).so.$(SO_VERS) ${DESTDIR}${LIBDIR}/$(TARGET).so
 
110
        # compatability with old libimmunix
 
111
        install -m 755 $(OLDTARGET) ${DESTDIR}/${LIB}
 
112
        ln -sf apparmor.h ${DESTDIR}/usr/include/sys/immunix.h
 
113
 
 
114
.PHONY: clean
 
115
clean:
 
116
        rm -f *.o $(TARGET)*.so* ${TARGETS} ${OLDTARGET} Make.rules
 
117
        rm -f ${NAME}-${VERSION}*.tar.gz ${TESTS} $(NAME)-*.tgz ${SPECFILE}