Changeset 20

Show
Ignore:
Timestamp:
04/16/08 15:52:23 (8 months ago)
Author:
jtang
Message:

New build system for libsipc, before binary-mq branch is merged.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libsipc/Makefile

    r3 r20  
    1 # Subdirectories which contain targets 
    2 SUBDIRS=src tests examples bindings/java 
    3  
    41# Installation directories 
    5 export PREFIX ?= $(DESTDIR)/usr 
    6 export LIBDIR ?= $(PREFIX)/lib 
    7 export SHLIBDIR ?= $(DESTDIR)/lib 
    8 export MANDIR ?= $(DESTDIR)/usr/share/man/man3 
    9 export EXAMPLESDIR ?= $(DESTDIR)/usr/share/sipc 
    10  
    11 export CFLAGS ?= -O3 -Wall -Wundef -Wmissing-noreturn -D_GNU_SOURCE 
    12 override CFLAGS += -L../src -I../include 
     2PREFIX ?= $(DESTDIR)/usr/local 
     3INCLUDEDIR ?= $(PREFIX)/include 
     4LIBDIR ?= $(PREFIX)/lib 
     5DATAROOTDIR ?= $(PREFIX)/share 
     6MANDIR ?= $(DATAROOTDIR)/man 
    137 
    148ifeq ($(DEBUG), 1) 
    15 export CFLAGS += -g3 -gdwarf-2 
     9  CFLAGS ?= -O0 -g3 -gdwarf-2 
     10  LDFLAGS ?= -g 
     11else 
     12  CFLAGS ?= -O3 
    1613endif 
    1714 
    18 all: $(SUBDIRS) 
    19         for i in $? ; do \ 
    20                 ($(MAKE) -C $$i);\ 
     15override CFLAGS += -Wall -Wundef -Wmissing-noreturn -D_GNU_SOURCE -fpic 
     16INCLUDEDIRS := -I$(shell pwd)/include 
     17LIBDIRS := -L$(shell pwd)/src 
     18 
     19export PREFIX INCLUDEDIR LIBDIR DATAROOTDIR MANDIR \ 
     20        CFLAGS LDFLAGS INCLUDEDIRS LIBDIRS 
     21 
     22# Subdirectories which contain targets 
     23SUBDIRS = src include bindings/java examples man tests 
     24 
     25all: 
     26        for i in $(SUBDIRS) ; do \ 
     27                ($(MAKE) -C $$i all) || exit 1;\ 
    2128        done 
    2229 
    2330example: 
    24         $(MAKE) -C examples 
     31        $(MAKE) -C examples $@ 
    2532 
    2633test: 
    27         $(MAKE) -C tests 
     34        $(MAKE) -C tests $@ 
    2835 
    29 binding: install-bindings 
     36binding: 
     37        $(MAKE) -C bindings/java $@ 
    3038 
    3139install: 
    32         $(MAKE) -C src install 
    33         $(MAKE) -C include install 
    34         $(MAKE) -C man install 
    35         $(MAKE) -C examples install 
    36 #       $(MAKE) -C bindings install 
     40        for i in $(SUBDIRS) ; do \ 
     41                ($(MAKE) -C $$i install) || exit 1;\ 
     42        done 
    3743 
    38 install-policy
    39         $(MAKE) -C examples/policy $@ 
     44install-example
     45        $(MAKE) -C examples $@ 
    4046 
    41 install-bindings
    42         $(MAKE) -C bindings 
     47install-binding
     48        $(MAKE) -C bindings/java $@ 
    4349 
    4450javadoc: 
     
    4652 
    4753clean: 
    48         $(MAKE) -C src clean 
    49         $(MAKE) -C examples clean 
    50         $(MAKE) -C tests clean 
     54        for i in $(SUBDIRS) ; do \ 
     55                ($(MAKE) -C $$i clean);\ 
     56        done 
     57 
     58.phony: all example test binding install install-policy javadoc clean 
  • trunk/libsipc/bindings/java/Makefile

    r3 r20  
    1 INSTDIR=$(EXAMPLESDIR)/bindings/java 
     1BINDINGSDIR = $(DATAROOTDIR)/sipc/bindings/java 
     2JARDIR = $(DATAROOTDIR)/java 
    23 
    3 all: install 
     4SRC = com/tresys/sipc/BadKeyException.java \ 
     5        com/tresys/sipc/ConnectionException.java \ 
     6        com/tresys/sipc/libsipc.java \ 
     7        com/tresys/sipc/Sipc.java \ 
     8        com/tresys/sipc/SipcMqueue.java \ 
     9        com/tresys/sipc/SipcShm.java 
     10 
     11CLASSES = $(patsubst %.java,%.class,$(SRC)) 
     12JAVAC ?= javac 
     13JAR ?= jar 
     14 
     15# Change the following values to be appropriate for your system: 
     16
     17# JNI_CFLAGS:   Location of JNI include files. 
     18#               Only set this value if JNI's include files 
     19#               are installed outside of the compiler's search path. 
     20 
     21#JNI_CFLAGS=-I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux 
     22JNI_CFLAGS=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fno-strict-aliasing 
     23 
     24LIBVERSION = 0.1 
     25TARGET = libsipcwrapper.so 
     26LIBSO = $(TARGET).$(LIBVERSION) 
     27OBJS = sipc_wrap.o 
     28 
     29all: 
     30 
     31binding: libsipc.jar $(LIBSO) 
     32 
     33install-binding: 
     34        test -d $(BINDINGSDIR) || install -m 755 -d $(BINDINGSDIR) 
     35        test -d $(BINDINGSDIR)/examples || install -m 755 -d $(BINDINGSDIR)/examples 
     36        install -m 644 README $(BINDINGSDIR) 
     37        install -m 644 examples/* $(BINDINGSDIR)/examples 
     38        install -m 644 libsipc.jar $(BINDINGSDIR) 
     39        test -d $(JARDIR) || install -m 755 -d $(JARDIR) 
     40        cd $(JARDIR) && ln -sf $(BINDINGSDIR)/libsipc.jar libsipc.jar 
     41        test -d $(LIBDIR) || install -m 755 -d $(LIBDIR) 
     42        install -m 755 $(LIBSO) $(LIBDIR) 
     43        cd $(LIBDIR) && ln -sf $(LIBSO) $(TARGET) 
     44 
     45libsipc.jar: $(CLASSES) 
     46        $(JAR) cf libsipc.jar $(CLASSES) 
     47 
     48%.class: %.java 
     49        $(JAVAC) $(JFLAGS) $< 
     50 
     51$(LIBSO): $(OBJS) 
     52        $(CC) $(LDFLAGS) $(LIBDIRS) -lsipc -shared -o $@ $< 
     53        ln -sf $@ $(TARGET) 
     54 
     55%.o: %.c 
     56        $(CC) $(CFLAGS) $(INCLUDEDIRS) $(JNI_CFLAGS) -c -o $@ $< 
     57 
    458install: 
    5         test -d $(EXAMPLESDIR)/bindings || install -m 755 -d $(EXAMPLESDIR)/bindings 
    6         test -d $(INSTDIR) || install -m 755 -d $(INSTDIR) 
    7         test -d $(INSTDIR)/sipc_java_wrapper || install -m 755 -d $(INSTDIR)/sipc_java_wrapper 
    8         test -d $(INSTDIR)/examples || install -m 755 -d $(INSTDIR)/examples 
    9         install -m 644 README $(INSTDIR) 
    10         install -m 644 examples/* $(INSTDIR)/examples 
    11         install -m 644 sipc_java_wrapper/* $(INSTDIR)/sipc_java_wrapper 
    12         cp -a com $(INSTDIR) 
    1359 
    1460javadoc: 
    1561        javadoc -d javadoc com.tresys.sipc 
     62 
     63clean: 
     64        -rm -f $(CLASSES) libsipc.jar $(TARGET) $(LIBSO) $(OBJS) 
     65 
     66.phony: all install clean javadoc 
  • trunk/libsipc/bindings/java/README

    r1 r20  
    22============ 
    33 
    4 This directory contains Java bindings to libsipc and example applications using these bindings. 
    5 To install the bindings, a few settings need to be adjusted.   
     4This directory contains Java bindings to libsipc and example 
     5applications using these bindings.  There is also C source code that 
     6is eventually compiled into a shared library. 
    67 
    7 The sipc_java_wrapper directory contains C source code that is eventually compiled into a shared library.   
    8 This shared library is necessary for the Java bindings to libsipc to be functional.  The Makefile.example found 
    9 in this directory needs to be modified so that the build process can locate the system's JNI include files. 
    10 Modify the Makefile.example found in sipc_java_wrapper as appropriate, then run 'make install' in that directory. 
     8To install the bindings, a few settings may need to be adjusted.  The 
     9Makefile in this directory may need to be modified so that the build 
     10process can locate the system's JNI include files. 
    1111 
    12 Note that the directory into which the shared library is installed must be in the dynamic linker's 
    13 search path.   
     12Note that the directory into which the shared library is installed 
     13must be in the dynamic linker's search path. 
    1414 
  • trunk/libsipc/examples/Makefile

    r1 r20  
    1818#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
    1919 
    20 OBJS=mq_creator mq_destroyer mq_sender mq_reader shm_creator shm_destroyer shm_sender shm_reader 
    21 LDFLAGS=-L../src -lsipc -Wl,-rpath,$(SHLIBDIR) 
    22 SUBDIRS=policy 
     20BINS = mq_creator mq_destroyer mq_sender mq_reader \ 
     21        shm_creator shm_destroyer shm_sender shm_reader 
     22EXAMPLESDIR = $(DATAROOTDIR)/sipc 
    2323 
    24 all: $(OBJS) 
     24SUBDIRS = policy 
     25 
     26all: $(BINS) 
     27        @for subdir in $(SUBDIRS); do \ 
     28                (cd $$subdir && $(MAKE) $@) || exit 1;\ 
     29        done 
     30 
     31install: 
     32        @for subdir in $(SUBDIRS); do \ 
     33                (cd $$subdir && $(MAKE) $@) || exit 1;\ 
     34        done 
     35 
     36mq_creator: mq_creator.o 
     37        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     38 
     39mq_destroyer: mq_destroyer.o 
     40        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     41 
     42mq_sender: mq_sender.o 
     43        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     44 
     45mq_reader: mq_reader.o 
     46        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     47 
     48shm_creator: shm_creator.o 
     49        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     50 
     51shm_destroyer: shm_destroyer.o 
     52        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     53 
     54shm_sender: shm_sender.o 
     55        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
     56 
     57shm_reader: shm_reader.o 
     58        $(CC) $(LDFLAGS) -lsipc $(LIBDIRS) -o $@ $^ 
    2559 
    2660%.o: %.c 
    27         $(CC) $(CFLAGS) $(LDFLAGS) -c $*.c -o $*.o 
     61        $(CC) $(CFLAGS) $(INCLUDEDIRS) -c -o $@ $< 
    2862 
    29 install: all 
     63install-example: $(BINS) 
    3064        test -d $(EXAMPLESDIR) || install -m 755 -d $(EXAMPLESDIR) 
    3165        install -m 644 *.c $(EXAMPLESDIR) 
    3266        install -m 755 *.sh $(EXAMPLESDIR) 
    33         install -m 755 $(OBJS) $(EXAMPLESDIR) 
     67        install -m 755 $(BINS) $(EXAMPLESDIR) 
    3468        install -m 644 data.txt $(EXAMPLESDIR) 
    3569        install -m 644 Makefile $(EXAMPLESDIR)           
     
    4074 
    4175clean: 
    42         rm -f $(OBJS) *.o *~ *# 
     76        -rm -f $(BINS) *.o 
    4377        @for subdir in $(SUBDIRS); do \ 
    4478                (cd $$subdir && $(MAKE) $@) || exit 1;\ 
    4579        done 
     80 
     81.phony: all install clean examples 
  • trunk/libsipc/examples/policy/Makefile

    r3 r20  
    11AWK ?= gawk 
    22 
     3EXAMPLESDIR = $(DATAROOTDIR)/sipc 
    34FC_ENTRIES := $(shell $(AWK) '/^\/.*/{ print $$1 }' *.fc ) 
    45FC_ENTRY = $(shell $(AWK) '/^\/.*/{ print $$1 }' $(@:.pp=.fc) ) 
     
    67UID = $(shell id -u) 
    78 
    8 all: install-policy 
     9all: 
     10 
     11install: 
     12 
     13install-example: 
     14        test -d $(EXAMPLESDIR)/policy || install -m 755 -d $(EXAMPLESDIR)/policy 
     15        install -m 644 *.te $(EXAMPLESDIR)/policy 
     16        install -m 644 *.fc $(EXAMPLESDIR)/policy 
     17        install -m 644 *.if $(EXAMPLESDIR)/policy 
     18        install -m 644 *.spt $(EXAMPLESDIR)/policy 
     19        install -m 644 Makefile $(EXAMPLESDIR)/policy 
     20        install -m 644 README $(EXAMPLESDIR)/policy 
    921 
    1022setup:  
     
    1426        @cp /usr/share/selinux/devel/include/system/unconfined.if unconfined.if.bak && \ 
    1527        cp unconfined.spt /usr/share/selinux/devel/include/system/unconfined.if  
    16  
    17 install: 
    18         test -d $(EXAMPLESDIR)/policy || install -m 755 -d $(EXAMPLESDIR)/policy 
    19         install -m 644 *.te $(EXAMPLESDIR)/policy 
    20         install -m 644 *.fc $(EXAMPLESDIR)/policy 
    21         install -m 644 *.if $(EXAMPLESDIR)/policy 
    22         install -m 644 *.spt $(EXAMPLESDIR)/policy 
    23         install -m 644 Makefile $(EXAMPLESDIR)/policy 
    24         install -m 644 README $(EXAMPLESDIR)/policy 
    2528 
    2629install-policy: setup 
     
    3437        @echo "Labeling files..." 
    3538        @for file in $(FC_ENTRIES); do \ 
    36               /usr/sbin/setfiles -v /etc/selinux/targeted/contexts/files/file_contexts $$file 1>/dev/null; \ 
    37         done 
     39              /usr/sbin/setfiles -v /etc/selinux/targeted/contexts/files/file_contexts $$file 1>/dev/null; \ 
     40       done 
    3841 
    3942%.pp: setup %.te %.if %.fc 
     
    4144        /usr/sbin/semodule -i $@ 
    4245        for file in $(FC_ENTRY); do \ 
    43               /usr/sbin/setfiles -v /etc/selinux/targeted/contexts/files/file_contexts $$file; \ 
    44         done 
     46              /usr/sbin/setfiles -v /etc/selinux/targeted/contexts/files/file_contexts $$file; \ 
     47       done 
    4548 
    46 remove-policy: clean 
     49remove-policy: 
    4750ifneq ($(UID),0) 
    4851        @echo "make $@" must be run as root since this target manipulates policy && false 
     
    5255        @echo "Resetting file labels..." 
    5356        @for file in $(FC_ENTRIES); do \ 
    54               /usr/sbin/setfiles -v /etc/selinux/targeted/contexts/files/file_contexts $$file 2>&1 1>/dev/null; \ 
    55         done  
     57              /usr/sbin/setfiles -v /etc/selinux/targeted/contexts/files/file_contexts $$file 2>&1 1>/dev/null; \ 
     58       done  
    5659        echo "Finishing clean up..." 
    5760        @[ -f unconfined.if.bak ] && \ 
     
    6063 
    6164clean: 
    62         @if [ -f /usr/share/selinux/devel/include/Makefile ]; then \ 
    63                 @$(MAKE) -f /usr/share/selinux/devel/include/Makefile clean; \ 
    64         fi 
    6565 
    66 .PHONY: setup install clean remove-policy install-policy 
     66.PHONY: all install clean setup remove-policy install-policy 
  • trunk/libsipc/include/Makefile

    r1 r20  
    1 PREFIX ?= $(DESTDIR)/usr 
    2 INCDIR ?= $(PREFIX)/include/sipc 
     1all: 
    32 
    43install: 
    5         test -d $(INCDIR) || install -m 755 -d $(INCDIR) 
    6         install -m 644 $(wildcard sipc/*.h) $(INCDIR) 
    7          
     4        test -d $(INCLUDEDIR)/sipc || install -m 755 -d $(INCLUDEDIR)/sipc 
     5        install -m 644 $(wildcard sipc/*.h) $(INCLUDEDIR)/sipc 
     6 
     7clean: 
     8 
     9.phony: all install clean 
  • trunk/libsipc/man/Makefile

    r1 r20  
    1 MANDIR = $(DESTDIR)/usr/share/man/man3 
     1all: 
    22 
    33install: 
    4         mkdir -p $(MANDIR) 
    5         install -m 644 man3/*.3 $(MANDIR) 
     4        test -d $(MANDIR)/man3 || mkdir -m 755 -p $(MANDIR)/man3 
     5        install -m 644 $(wildcard man3/*.3) $(MANDIR)/man3 
     6 
     7clean: 
     8 
     9.phony: all install clean 
  • trunk/libsipc/src/Makefile

    r1 r20  
    55 
    66OBJS=$(patsubst %.c,%.o,$(wildcard *.c)) 
    7 LOBJS=$(patsubst %.c,%.lo,$(wildcard *.c)) 
    87 
    98all: $(LIBSO) 
    109 
    11 $(LIBSO): $(LOBJS) 
    12         $(CC) $(LDFLAGS) -shared -o $@ $^ -Wl,-soname,$(LIBSO),--version-script=libsipc.map,-z,defs 
     10$(LIBSO): $(OBJS) 
     11        $(CC) $(LDFLAGS) -shared -o $@ $^ -Wl,-soname,$(LIBSO),--version-script=libsipc.map,-z,defs $(LIBDIRS) 
    1312        ln -sf $@ $(TARGET) 
    1413 
    15 %.o: %.c 
    16         $(CC) $(CFLAGS) -c -o $@ $< 
     14%.o: %.c 
     15        $(CC) $(CFLAGS) $(INCLUDEDIRS) -c -o $@ $< 
    1716 
    18 %.lo:  %.c 
    19         $(CC) $(CFLAGS) -fpic -DSHARED -c -o $@ $< 
    20  
    21 install: all 
     17install: $(LIBSO) 
    2218        test -d $(LIBDIR) || install -m 755 -d $(LIBDIR) 
    23         test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR) 
    24         install -m 755 $(LIBSO) $(SHLIBDIR) 
    25         cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET) 
     19        install -m 755 $(LIBSO) $(LIBDIR) 
     20        cd $(LIBDIR) && ln -sf $(LIBSO) $(TARGET) 
    2621 
    2722clean: 
    28         -rm -f $(OBJS) $(LOBJS) $(LIBSO) $(TARGET) 
     23        -rm -f $(OBJS) $(LIBSO) $(TARGET) 
     24 
     25.phony: all install clean 
  • trunk/libsipc/tests/Makefile

    r3 r20  
    1 OBJS = test_ipc ipc_creator ipc_destroyer 
    2 LDFLAGS += -lsipc -lcunit -Wl,-rpath,$(DESTDIR)/usr/lib 
    3 EXE = test_ipc 
     1TESTS = test_ipc ipc_creator ipc_destroyer 
     2override LDFLAGS += -lsipc -lcunit -Wl,-rpath,$(LIBDIRS) 
    43 
    5 all: $(OBJS) 
     4all: 
     5 
     6install: 
     7 
     8test: $(TESTS) 
    69 
    710test_ipc: test_ipc.c shm.h shm.c mqueue.h mqueue.c 
    8         $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ 
     11        $(CC) $(CFLAGS) $(INCLUDEDIRS) $^ $(LDFLAGS) -o $@ 
    912 
    1013ipc_creator: ipc_creator.c 
    11         $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 
     14        $(CC) $(CFLAGS) $(INLCUDEDIRS) $(LDFLAGS) $^ -o $@ 
    1215 
    1316ipc_destroyer: ipc_destroyer.c 
    14         $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 
    15  
    16 libsipc.a: 
    17         $(MAKE) -C ../src 
     17        $(CC) $(CFLAGS) $(INCLUDEDIRS) $(LDFLAGS) $^ -o $@ 
    1818 
    1919clean: 
    20         rm -rf $(OBJS) $(EXE) *~ *.o 
     20        -rm -rf $(TESTS) 
    2121 
     22.phony: all install test clean