From 7af9f1d9e3f8d6e893e93645cbf75081e507daf0 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 13 Nov 2007 19:29:55 +0100 Subject: Move to a suitable place. --- howtos.mdwn | 2 +- hurd/libhello_example.mdwn | 165 +++++++++++++++++++++++++++++++++++++++++++++ hurdlibraryhowto.mdwn | 165 --------------------------------------------- 3 files changed, 166 insertions(+), 166 deletions(-) create mode 100644 hurd/libhello_example.mdwn delete mode 100644 hurdlibraryhowto.mdwn diff --git a/howtos.mdwn b/howtos.mdwn index 1398bcd2..8cd3ed2c 100644 --- a/howtos.mdwn +++ b/howtos.mdwn @@ -18,7 +18,7 @@ is included in the section entitled * [[QemuFileSharingWithHost]] File sharing between GNU on Qemu and the Host OS * [[Setupcvsfs]]Setting up cvsfs from HurdExtras * [[HurdTranslatorExample]] Hurd translator example - * [[HurdLibraryHOWTO]] Hurd Library HOWTO + * [[hurd/libhello_example]] -- Hurd library example ## Compilation diff --git a/hurd/libhello_example.mdwn b/hurd/libhello_example.mdwn new file mode 100644 index 00000000..d5df45e3 --- /dev/null +++ b/hurd/libhello_example.mdwn @@ -0,0 +1,165 @@ +[[meta copyright="Copyright © 2007 Free Software Foundation, Inc."]] +[[meta license="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU_Free_Documentation_License|/fdl]]."]] + +## Howto write a Hurd library + +Build the Hurd sources: +------------------------ + +Refer to this [[hurd/building/example]]. + +Create the library files: +---------------------- + +Create a directory, say, libhello in the Hurd sources directory. + +Create a lhello.h header file: + + /* lhello.h - Example library header file. + Copyright (C) 2006 Free Software Foundation, Inc. + Written by Shakthi Kannan . + + 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: + + /* lhello.c - Example library .c file. + Copyright (C) 2006 + Free Software Foundation, Inc. + Written by Shakthi Kannan . + + 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 + + # + # 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. + + cd build + ../configure + make + +Testing the library +------------------- + +Write a file, say, foo.c: + + /* foo.c */ + + #define _GNU_SOURCE + + int + main (int argc, char *argv[]) + { + print_hello(); + return 0; + } + +Static compilation and linking method: + + gcc -g -o foo foo.c -L/path/to/libhello -lhello -static + +Run the example: + + ./foo + +Compilation and dynamic linking method: + + 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: + + ./foo diff --git a/hurdlibraryhowto.mdwn b/hurdlibraryhowto.mdwn deleted file mode 100644 index d5df45e3..00000000 --- a/hurdlibraryhowto.mdwn +++ /dev/null @@ -1,165 +0,0 @@ -[[meta copyright="Copyright © 2007 Free Software Foundation, Inc."]] -[[meta license="Permission is granted to copy, distribute and/or modify this -document under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with no Invariant -Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license -is included in the section entitled -[[GNU_Free_Documentation_License|/fdl]]."]] - -## Howto write a Hurd library - -Build the Hurd sources: ------------------------- - -Refer to this [[hurd/building/example]]. - -Create the library files: ----------------------- - -Create a directory, say, libhello in the Hurd sources directory. - -Create a lhello.h header file: - - /* lhello.h - Example library header file. - Copyright (C) 2006 Free Software Foundation, Inc. - Written by Shakthi Kannan . - - 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: - - /* lhello.c - Example library .c file. - Copyright (C) 2006 - Free Software Foundation, Inc. - Written by Shakthi Kannan . - - 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 - - # - # 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. - - cd build - ../configure - make - -Testing the library -------------------- - -Write a file, say, foo.c: - - /* foo.c */ - - #define _GNU_SOURCE - - int - main (int argc, char *argv[]) - { - print_hello(); - return 0; - } - -Static compilation and linking method: - - gcc -g -o foo foo.c -L/path/to/libhello -lhello -static - -Run the example: - - ./foo - -Compilation and dynamic linking method: - - 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: - - ./foo -- cgit v1.2.3