summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2007-11-13 19:26:37 +0100
committerThomas Schwinge <tschwinge@gnu.org>2007-11-13 19:26:37 +0100
commita002f1d48f323ccffefb2918d321e1e5b05bc560 (patch)
tree4d449bd77f9d47cba808457df0d2ab030e9ad046
parent0f51b6c555647b2f44621e60988414dd66ce9a46 (diff)
Use proper ikiwiki syntax.
-rw-r--r--hurdlibraryhowto.mdwn238
1 files changed, 110 insertions, 128 deletions
diff --git a/hurdlibraryhowto.mdwn b/hurdlibraryhowto.mdwn
index ddc0d7a9..d5df45e3 100644
--- a/hurdlibraryhowto.mdwn
+++ b/hurdlibraryhowto.mdwn
@@ -10,7 +10,7 @@ is included in the section entitled
Build the Hurd sources:
------------------------
-
+
Refer to this [[hurd/building/example]].
Create the library files:
@@ -20,164 +20,146 @@ Create a directory, say, libhello in the Hurd sources directory.
Create a lhello.h header file:
-<pre>
-/* lhello.h - Example library header file.
- Copyright (C) 2006 Free Software Foundation, Inc.
- Written by Shakthi Kannan <shaks@shakthimaan.com>.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- The GNU Hurd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the GNU Hurd; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _HURD_HELLO_H
-#define _HURD_HELLO_H 1
-
-struct hello
-{
- int x;
-};
-
-#endif /* _HURD_HELLO_H */
-</pre>
+ /* lhello.h - Example library header file.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ Written by Shakthi Kannan <shaks@shakthimaan.com>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ #ifndef _HURD_HELLO_H
+ #define _HURD_HELLO_H 1
+
+ struct hello
+ {
+ int x;
+ };
+
+ #endif /* _HURD_HELLO_H */
Replace filename, year, author name and e-mail address appropriately.
Create a lhello.c file:
-<pre>
-/* lhello.c - Example library .c file.
- Copyright (C) 2006
- Free Software Foundation, Inc.
- Written by Shakthi Kannan <shaks@shakthimaan.com>.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The GNU Hurd is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the GNU Hurd; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "lhello.h"
-
-void
-print_hello (void)
-{
- struct hello example;
- example.x = 2;
- printf ("foo and bar are %d words!\n", example.x);
-}
-</pre>
+ /* lhello.c - Example library .c file.
+ Copyright (C) 2006
+ Free Software Foundation, Inc.
+ Written by Shakthi Kannan <shaks@shakthimaan.com>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd; see the file COPYING. If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ #include "lhello.h"
+
+ void
+ print_hello (void)
+ {
+ struct hello example;
+ example.x = 2;
+ printf ("foo and bar are %d words!\n", example.x);
+ }
Replace header file year, author name and e-mail address appropriately.
Create a Makefile
-<pre>
-#
-# Copyright (C) 2006 Free Software Foundation, Inc.
-#
-# This file is part of the GNU Hurd.
-#
-# The GNU Hurd is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2, or (at
-# your option) any later version.
-#
-# The GNU Hurd is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-dir := libhello
-makemode := library
-
-libname := libhello
-SRCS = lhello.c
-installhdrs = lhello.h
-LCLHDRS = $(installhdrs)
-
-OBJS = $(SRCS:.c=.o)
-
-include ../Makeconf
-</pre>
+ #
+ # Copyright (C) 2006 Free Software Foundation, Inc.
+ #
+ # This file is part of the GNU Hurd.
+ #
+ # The GNU Hurd is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License as
+ # published by the Free Software Foundation; either version 2, or (at
+ # your option) any later version.
+ #
+ # The GNU Hurd is distributed in the hope that it will be useful, but
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ # General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ dir := libhello
+ makemode := library
+
+ libname := libhello
+ SRCS = lhello.c
+ installhdrs = lhello.h
+ LCLHDRS = $(installhdrs)
+
+ OBJS = $(SRCS:.c=.o)
+
+ include ../Makeconf
Update the Makeconf file:
-Add libhello to lib-subdirs target in the top-level Makefile in the Hurd sources.
+Add libhello to lib-subdirs target in the top-level Makefile in the Hurd
+sources.
-<pre>
-cd build
-../configure
-make
-</pre>
+ cd build
+ ../configure
+ make
Testing the library
-------------------
Write a file, say, foo.c:
-<pre>
-/* foo.c */
-
-#define _GNU_SOURCE
-
-int
-main (int argc, char *argv[])
-{
- print_hello();
- return 0;
-}
-</pre>
+ /* foo.c */
+
+ #define _GNU_SOURCE
+
+ int
+ main (int argc, char *argv[])
+ {
+ print_hello();
+ return 0;
+ }
Static compilation and linking method:
-<pre>
-gcc -g -o foo foo.c -L/path/to/libhello -lhello -static
-</pre>
+ gcc -g -o foo foo.c -L/path/to/libhello -lhello -static
Run the example:
-<pre>
-./foo
-</pre>
+ ./foo
Compilation and dynamic linking method:
-<pre>
-LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libhello
-gcc -g -o foo foo.c -L/path/to/libhello -lhello
-</pre>
+ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libhello
+ gcc -g -o foo foo.c -L/path/to/libhello -lhello
where /path/to/libhello = /path/to/hurd/build/libhello
Run the example:
-<pre>
-./foo
-</pre>
--- ShakthiKannan - 30 Nov 2006 \ No newline at end of file
+ ./foo