wiki:Projects/OpenLDAP
Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Version 17 (modified by C Rempel, on 06/21/12 at 22:55:25) (diff)

/* examples/openldap/Makefile */

OpenLDAP

Status: Current status of project.

Introduce the main concepts around the project: Theoretical preliminaries, preexisting RTEMS capabilities used or augmented (if any), important concepts, problems/needs the project will try to solve/satisfy.

Goal

Concise statement of the overall goal of the project. Refine this initial statement to include: project deliverables (code, docs, testing), required/suggested methodology, standards of quality, possible goal extensions beyond the main objective.

Requirements

List the requirements and level of expertise you estimate are required by the developer tackling this project will have to have: Required level of programming language(s), specific areas of RTEMS or tools, level of familiarity with RTEMS, cross-development, GNU/Linux, etx., development/documentation/testing tools, mathematical/algorithmic background, other desirable skills.

Resources

Current RTEMS developers, papers, etc that may help you in this project.

C Rempel is willing to help

Other sections

If you have more to say about the project that doesn't fit in the proposed sections of this template, feel free to add other sections at will.

Acknowledgements

  • who helped add did work

Miscellaneous Sections

A first stab at building Open LDAP

As the project progresses, you will need to add build instructions, etc and this page will evolve from a project description into a HOWTO.

I am building this package because it is simpler than the Apache Runtime, and so is a good way to gain needed experience. I started with using the RTEMS Addon Packages. How to use the RTEMS Addon Packages is outlined http://www.rtems.com/wiki/index.php/RTEMS_Add-On_Packages.

Makefile.openldap

I put the following in rtems-addon-packages/Makefile.openldap

# # Declare supported terminal types. # This value can be augmented/overridden by the site-configuration file #

include ../RTEMS_Makefiles/Makefile.common

# # The following will work only if you have the latest ncurses version # of infocmp installed before trying to build for an RTEMS target. # The cf_cv_type_of_bool hack works around a bug when configuring # for a cross-target. # all:

ac_cv_member_struct_msghdr_msg_control=no \ ac_cv_func_memcmp_working=yes \ ac_cv_func_initgroups=yes \ ac_cv_func_setuid=no \ ./configure \

--host=$(RTEMS_CPU)-rtems4.11 \ --prefix=$(exec_prefix) \ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include \ --without-tls \ --with-yielding_select=yes \ --disable-mdb \ --disable-hdb \ --disable-cleartext \ --disable-overlays \ --enable-proctitle \ --enable-debug \ --disable-shared

make make install

Next:

$ cd ~/rtems-addon-packages $ git clone git://git.openldap.org/openldap.git openldap $ cd openldap $ make -f RTEMS_Makefiles/Makefile.openldap

Note: Very insecure! But builds OK.

examples/openldap/BuildTests.sh

To perform a very basic "smoke" test on the build I modified the BuildTest?.sh and Makefile to build the programs needed to run the tests, not the tests themselves. I learned I how to link convenience libraries, and how to use BuildTests?.sh, Makefile.leaf and change leaf.cfg.

Interestingly, I found it necessary to symbolically link the slapd-common header and source to each test, as well as the libutil library.

### examples/openldap/BuildTests.sh ### #!/bin/sh

set -x rm -f rtems-grub.cfg

SRCDIR=../../openldap/tests/progs

Make the common source and header files available to all the test programs

ln -s $SRCDIR/slapd-common.h . ln -s $SRCDIR/slapd-common.c .

Make the lutility convenience library available to all the test programs

ln -s $SRCDIR/../../libraries/liblutil/liblutil.a .

For every test, delete the old link, make a new link, make the test, delete the link and the object file.

for TEST in \

slapd-tester \ slapd-search \ slapd-read \ slapd-addel \ slapd-modrdn \ slapd-modify \ slapd-bind \ slapd-mtread \ ldif-filter

do

rm -f $TEST.c ln -s $SRCDIR/$TEST.c . make TEST=$TEST SRCDIR=$SRCDIR rm -f $TEST.c $TEST.o

done

After making the test programs, remove the links to the common header, source, and lutility library.

rm -f slapd-common.h rm -f slapd-common.c rm -f liblutil.a

(Optional) Next, to make it easier for the end-user, automate building rtems-grub.cfg

# Generate rtems-grub.cfg

Add a comment of what grub is configured to load $(basename $PWD) prints the name of the directory.

echo \# RTEMS Grub configuration for $(basename $PWD) >> rtems-grub.cfg

This part was rather interesting... I've never used a pipe inside of a shell-script call before... list everything in o-optimize, that ends with .exe and count them.

# The number of executables

echo set default = $(ls o-optimize | \ grep '\.'exe | wc -l) >> rtems-grub.cfg

Used the & to use the name of the executable more than once. Note that sed"s/[a-zA-Z\-] has to be all on one line

# The menuentries ls o-optimize | \ grep '\.'exe | \ sed "s/[a-zA-Z\-]/menuentry \"RTEMS \-\" \{\n

set root=(hd1,1)\n multiboot (hd1,1)\/o-optimize\/&/" | \

sed "s/\.exe/\.exe\n\}\n/" >> rtems-grub.cfg

List everything in o-optimize... that is an executable... select text composed of letters and format it ... add a line a right brace, and another line after any .exe ...

examples/openldap/Makefile

I modified the rtems-addon-packages/examples/ncurses/Makefile to turn openldap programs used to test openldap into stand-alone executables.

I had to add slapd-common.c to the C_PIECES, and slapd-common.h to the headers.

Also, to link the liblutil.a convienience library, I had to add liblutil.a to C_O_FILES (it's an object file after-all :), I linked the ldap libraries using LD_LIBS, and increased the HeapSize? by a factor of ten (because it said networking required more -- online research is needed to get an exact size required).

Finally, it's worth noting the $(TEST) parameter is used to identify which test to build, and PGMS stands for programs.

# # $Id$ # # Templates/Makefile?.leaf # Template leaf node Makefile # SRCDIR=../../openldap/tests/progs

# C source names, if any, go here -- minus the .c C_PIECES=slapd-common $(TEST)

C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) liblutil.a

# C++ source names, if any, go here -- minus the .cc CC_PIECES=

CC_FILES=$(CC_PIECES:%=%.cc) CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)

H_FILES= slapd-common.h

# Assembly source names, if any, go here -- minus the .s S_PIECES=

S_FILES=$(S_PIECES:%=%.s) S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)

SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES) OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)

PGMS=${ARCH}/$(TEST)

# # RTEMS managers go here # MANAGERS=io event message semaphore

include $(RTEMS_MAKEFILE_PATH)/Makefile.inc include $(RTEMS_CUSTOM) include $(PROJECT_ROOT)/make/leaf.cfg

# # (OPTIONAL) Add local stuff here using +=

#

DEFINES +=

CPPFLAGS += -I$(SRCDIR)/../../include CFLAGS +=

LD_PATHS +=

LD_LIBS += -lldap -llber -lldap_r CFLAGS_LD += -Wl,--defsym -Wl,HeapSize?=0x200000 # network needs more space CFLAGS_DEBUG_V +=

# # Add your list of files to delete here. The config files # already know how to delete some stuff, so you may want # to just run 'make clean' first to see what gets missed. # 'make clobber' already includes 'make clean' #

CLEAN_ADDITIONS += CLOBBER_ADDITIONS +=

all: ${ARCH} $(SRCS) $(PGMS)

${ARCH}/$(TEST): ${OBJS} ${LINK_FILES}

$(make-exe)

# Install the program(s), appending _g or _p as appropriate. # for include files, just use $(INSTALL) install: all

$(INSTALL_VARIANT) -m 555 ${PGMS} /usr/local/tftpboot/bootfiles/m68360/

leaf.cfg

To build the executables without errors, I had to change some lines in /opt/rtems-4.11/make/leaf.cfg. nm and size work on object files, with the below changes the build process not only gives fewer errors, but generates .bin and .ralf files in examples/openldap/o-optimize!

define default-bsp-post-link

  • $(NM) -g -n $@ > $(basename $@).num
  • $(SIZE) $@ endef

Because Makefile builds .o object files, the .o extension was needed...

define default-bsp-post-link + $(NM) -g -n $@.o > $(basename $@).num + $(SIZE) $@.o endef

Then, I ran BuildTests?.sh

~/rtems-addon-packages/examples/openldap$ ./BuildTests?.sh

Again this only built the programs used to run the tests as stand-alone executables...

Currently looking at how to build the tests -- they're in shell script :)... Hope this helps!

References