From 454110e1b17214b220317704f092bd3587b88a9d Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 9 May 2009 13:08:34 +0200 Subject: Switch to cmake "Works for now..." --- .gitignore | 5 + CMakeLists.txt | 7 ++ INSTALL | 291 +++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.am | 3 - autogen.sh | 19 ---- configure.in | 224 ------------------------------------- etc/Makefile.am | 4 - hotplug/Makefile.am | 7 -- libmpio/.gitignore | 1 + libmpio/CMakeLists.txt | 15 +++ libmpio/Makefile.am | 40 ------- libmpio/debug.h | 2 +- mpiosh/.gitignore | 2 + mpiosh/CMakeLists.txt | 15 +++ mpiosh/Makefile.am | 23 ---- mpiosh/callback.c | 1 + mpiosh/cfg.c | 238 ++++++++++++++++++++++++++++++++++++++++ mpiosh/cfg.h | 56 ++++++++++ mpiosh/config.c | 238 ---------------------------------------- mpiosh/config.h | 55 ---------- mpiosh/config.h.in | 9 ++ mpiosh/global.c | 1 + mpiosh/mpiosh.c | 2 +- tools/Makefile.am | 3 - 24 files changed, 643 insertions(+), 618 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 INSTALL delete mode 100644 Makefile.am delete mode 100755 autogen.sh delete mode 100644 configure.in delete mode 100644 etc/Makefile.am delete mode 100644 hotplug/Makefile.am create mode 100644 libmpio/.gitignore create mode 100644 libmpio/CMakeLists.txt delete mode 100644 libmpio/Makefile.am create mode 100644 mpiosh/.gitignore create mode 100644 mpiosh/CMakeLists.txt delete mode 100644 mpiosh/Makefile.am create mode 100644 mpiosh/cfg.c create mode 100644 mpiosh/cfg.h delete mode 100644 mpiosh/config.c delete mode 100644 mpiosh/config.h create mode 100644 mpiosh/config.h.in delete mode 100644 tools/Makefile.am diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66abe6f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.sw* +CMakeFiles +CMakeCache.txt +cmake_install.cmake +Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4149b10 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.4) + +set (PACKAGE mpiotools) +project (${PACKAGE} C) + +add_subdirectory (libmpio) +add_subdirectory (mpiosh) diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..8b82ade --- /dev/null +++ b/INSTALL @@ -0,0 +1,291 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008 Free Software Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *Note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index c2acfbc..0000000 --- a/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS=@MPIO_KERNEL@ libmpio mpiosh etc tools hotplug - -EXTRA_DIST=mpio.spec diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 4b4074f..0000000 --- a/autogen.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# autogen.sh -# -# Andreas Buesching -# $id$ - -# minimum needed software versions: -# -# * libtoolize (GNU libtool) 1.4.3 -# * aclocal (GNU automake) 1.6.3 -# * autoconf (GNU Autoconf) 2.57 -# * automake (GNU automake) 1.6.3 - -export WANT_AUTOMAKE="1.7" - -libtoolize -c -f && aclocal && autoconf && automake -a -c -f && ./configure $@ - -# end of autogen.sh diff --git a/configure.in b/configure.in deleted file mode 100644 index bd57b8a..0000000 --- a/configure.in +++ /dev/null @@ -1,224 +0,0 @@ -dnl -*- shell-script -*- -dnl Process this file with autoconf to produce a configure script. - -dnl we need autoconf >= 2.50 -AC_PREREQ(2.50) - -AC_INIT(libmpio/src/mpio.c) -dnl AM_CONFIG_HEADER(src/config.h) - -AC_CANONICAL_SYSTEM() -AC_MSG_RESULT(Building for a ${host} host.) - -AM_INIT_AUTOMAKE(mpio, 0.7.1_pre3-1) - -dnl build release variable -RELEASE=`echo $VERSION | cut -d- -f2` -VERSION=`echo $VERSION | cut -d- -f1` -AC_SUBST(RELEASE) - -dnl Checks for programs. - -AC_PROG_MAKE_SET -AC_PROG_CC -AM_PROG_LIBTOOL - -dnl Check for endianess - -AC_LANG_C -AC_C_BIGENDIAN - -dnl Checks for header files. - -AC_CHECK_HEADER(getopt.h,HAVE_GETOPT_H=1,HAVE_GETOPT_H=0) -AC_SUBST(HAVE_GETOPT_H) - -dnl --- checking for readline - -AC_CHECK_HEADER(readline/readline.h,, - AC_ERROR(could not find readline header files)) - -dnl --- include mplib if not disabled manually - -AC_DEFUN([TEST_MPLIB], -[AC_ARG_WITH([mplib], - AC_HELP_STRING([--without-mplib], - [disable use of mplib]), - [ac_cv_use_mplib=$withval], [ac_cv_use_mplib=yes]) -AC_CACHE_CHECK([whether to use mplib], - [ac_cv_use_mplib], [ac_cv_use_mplib=yes])]) -TEST_MPLIB - -if test "$ac_cv_use_mplib" = yes; then - MPLIB_INCLUDE=-Implib - MPLIB_CFLAGS=-DMPLIB -fi - -AC_SUBST(MPLIB_INCLUDE) -AC_SUBST(MPLIB_CFLAGS) - -dnl -- check for libusb -dnl -- this is stolen from libgphoto2 - -AC_PATH_PROG(LIBUSB_CONFIG,libusb-config) -if test -n "${LIBUSB_CONFIG}"; then - CPPFLAGS_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS `$LIBUSB_CONFIG --cflags`" - AC_CHECK_HEADER(usb.h,[ - LDFLAGS_orig="$LDFLAGS" - LDFLAGS="`$LIBUSB_CONFIG --libs`" - AC_CHECK_LIB(usb,usb_busses,[ - usb_msg="yes" - IOLIB_SUBDIRS="$IOLIB_SUBDIRS usb" - USB_LIBS="`$LIBUSB_CONFIG --libs`" - USB_CFLAGS="`$LIBUSB_CONFIG --cflags`" - LIBUSB_VER="`$LIBUSB_CONFIG --version`"],[ - usb_msg="no (available version too old)"]) - LDFLAGS="$LDFLAGS_orig"]) - CPPFLAGS="$CPPFLAGS_save" -fi - -dnl --- blacklist the too old versions -case "$LIBUSB_VER" in - 0.1.[[0123456]]|0.1.[[36]][[ab]]) - AC_MSG_WARN([ -*** You need at least version 0.1.7 of the libusb library for USB support -*** http://sourceforge.net/projects/libusb/ -*** If you cannot find the appropriate version, try CVS - ]) - exit 1 ;; - *);; -esac - -case "$usb_msg" in - yes*) AC_DEFINE(HAVE_USB,1,[Whether you have USB support enabled]);; - *) ;; -esac - -AC_SUBST(USB_CFLAGS) -AC_SUBST(USB_LIBS) - -dnl --- check/set user and permissions for accessing the player - -dnl 1. user - -AC_DEFUN([TEST_USER], -[AC_ARG_WITH([user], - AC_HELP_STRING([--with-user=USER], - [user to access the player]), - [ac_cv_use_user=$withval], [ac_cv_use_user=root]) -AC_CACHE_CHECK([user to access the player], - [ac_cv_use_user], [ac_cv_use_user=root])]) - -TEST_USER -MPIOUSER=$ac_cv_use_user -AC_SUBST(MPIOUSER) - -dnl 2. group - -AC_DEFUN([TEST_GROUP], -[AC_ARG_WITH([group], - AC_HELP_STRING([--with-group=GROUP], - [group to access the player]), - [ac_cv_use_group=$withval], [ac_cv_use_group=root]) -AC_CACHE_CHECK([group to access the player], - [ac_cv_use_group], [ac_cv_use_group=root])]) - -TEST_GROUP -MPIOGROUP=$ac_cv_use_group -AC_SUBST(MPIOGROUP) - -dnl 3. permissions - -AC_DEFUN([TEST_PERM], -[AC_ARG_WITH([perm], - AC_HELP_STRING([--with-perm=PERM], - [permissions for accessing the player]), - [ac_cv_use_perm=$withval], [ac_cv_use_perm=0666]) -AC_CACHE_CHECK([permissions for accessing the player], - [ac_cv_use_perm], [ac_cv_use_perm=0666])]) - -TEST_PERM -MPIOPERM=$ac_cv_use_perm -AC_SUBST(MPIOPERM) - -dnl --- only use deprecated kernel module if requested - -AC_DEFUN([TEST_KERNEL], -[AC_ARG_WITH([kernel-module], - AC_HELP_STRING([--with-kernel-module], - [enable the deprecated kernel module for 2.2.x and 2.4.x]), - [ac_cv_use_kernel=$withval], [ac_cv_use_kernel=no]) -AC_CACHE_CHECK([whether to build the kernel module], - [ac_cv_use_kernel], [ac_cv_use_kernel=no])]) - -TEST_KERNEL - -if test "$ac_cv_use_kernel" = yes; then - MPIO_KERNEL=kernel - -dnl --- check for kernel version -kernel_version=`uname -r 2>&1` -echo -n "checking for kernel version ... " -case "$kernel_version" in - '') kernel_version="?.??"; _k_verc_fail=yes;; - [[0-1]].[[0-9]].[[0-9]]*|2.[[0-1]].[[0-9]]*|2.[[5-9]].[[0-9]]*|3.[[0-9]]*.[[0-9]]*) - _k_verc_fail=yes;; - *) k_ver_fail=no;; -esac -echo $kernel_version -if test "$_k_verc_fail" ; then - echo " Your kernel version does not match." - echo " The kernel module only works for kernel 2.2.x and 2.4.x." - AC_ERROR(wrong kernel version) - unset MPIO_KERNEL -fi - -MODULE_PATH="/lib/modules/${kernel_version}" -if test -d "${MODULE_PATH}/kernel/drivers/usb"; then - MODULE_PATH="${MODULE_PATH}/kernel/drivers/usb" - SPEC_PATH="kernel/drivers/usb" -else - MODULE_PATH="${MODULE_PATH}/misc" - SPEC_PATH="misc" -fi - -AC_MSG_RESULT(Using module path ${MODULE_PATH}.) -AC_SUBST(MODULE_PATH) -AC_SUBST(SPEC_PATH) - -KERNEL_INCLUDE= -if test -d "/lib/modules/${kernel_version}/build/include"; then - KERNEL_INCLUDE="/lib/modules/${kernel_version}/build/include" -elif test -d "/usr/src/linux-2.4/include"; then - KERNEL_INCLUDE="/usr/src/linux-2.4/include" -elif test -d "/usr/include/linux"; then - KERNEL_INCLUDE="/usr/include/linux" -elif test -d "/usr/src/linux/include"; then - KERNEL_INCLUDE="/usr/src/linux/include" -fi - -if test -z ${KERNEL_INCLUDE}; then - AC_ERROR(could not find directory of kernel include files) -else - AC_MSG_RESULT(Using kernel includes from ${KERNEL_INCLUDE}) - AC_DEFINE(USE_KMODULE,1,[Whether you want support for the deprecated kernel module]) -fi -AC_SUBST(KERNEL_INCLUDE) - -fi - -AC_SUBST(MPIO_KERNEL) - -dnl ------------------------------------------------------------ - -AC_OUTPUT( - Makefile - libmpio/Makefile - mpiosh/Makefile - etc/Makefile - tools/Makefile - hotplug/libmpio - hotplug/Makefile - mpio.spec -) diff --git a/etc/Makefile.am b/etc/Makefile.am deleted file mode 100644 index 0c83c3d..0000000 --- a/etc/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -datadir=$(sysconfdir)/mpio - -data_DATA = mpioshrc -EXTRA_DIST = mpioshrc \ No newline at end of file diff --git a/hotplug/Makefile.am b/hotplug/Makefile.am deleted file mode 100644 index f9e122e..0000000 --- a/hotplug/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -datadir=/etc/hotplug/usb -sbindir=/etc/hotplug/usb - -data_DATA = libmpio.usermap -sbin_SCRIPTS = libmpio -EXTRA_DIST = libmpio libmpio.usermap - diff --git a/libmpio/.gitignore b/libmpio/.gitignore new file mode 100644 index 0000000..10301e2 --- /dev/null +++ b/libmpio/.gitignore @@ -0,0 +1 @@ +*.a diff --git a/libmpio/CMakeLists.txt b/libmpio/CMakeLists.txt new file mode 100644 index 0000000..917833d --- /dev/null +++ b/libmpio/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required (VERSION 2.4) + +set (PACKAGE libmpio) +project (${PACKAGE} C) + +set (CMAKE_C_FLAGS -Wall) + +include_directories (${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/mplib) + +add_library (mpio STATIC src/mpio.c src/io.c src/debug.c src/smartmedia.c + src/mmc.c src/directory.c src/fat.c src/ecc.c src/cis.c src/id3.c + mplib/mplib.c mplib/mplib_paas.c mplib/mplib_s.c mplib/xmalloc.c) + +target_link_libraries (mpio -lusb) diff --git a/libmpio/Makefile.am b/libmpio/Makefile.am deleted file mode 100644 index 2b55f7f..0000000 --- a/libmpio/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -INCLUDES=@MPLIB_INCLUDE@ -AM_CFLAGS=@MPLIB_CFLAGS@ @USB_CFLAGS@ -AM_LDFLAGS=-version-info 1:0:0 @USB_LIBS@ - -lib_LTLIBRARIES=libmpio.la - -libmpio_la_SOURCES= \ - src/mpio.c \ - src/io.c \ - src/debug.c \ - src/smartmedia.c \ - src/mmc.c \ - src/directory.c \ - src/fat.c \ - src/ecc.c \ - src/cis.c \ - src/id3.c \ - mplib/mplib.c \ - mplib/mplib_paas.c \ - mplib/mplib_s.c \ - mplib/xmalloc.c - -pkginclude_HEADERS= \ - mpio.h \ - defs.h - -noinst_HEADERS= \ - debug.h \ - src/io.h \ - src/smartmedia.h \ - src/mmc.h \ - src/directory.h \ - src/fat.h \ - src/ecc.h \ - src/cis.h \ - src/id3.h \ - mplib/mplib.h \ - mplib/mplib_s.h \ - mplib/xmalloc.h - diff --git a/libmpio/debug.h b/libmpio/debug.h index c523310..eee3a72 100644 --- a/libmpio/debug.h +++ b/libmpio/debug.h @@ -31,7 +31,7 @@ #ifdef PACKAGE #define DPACKAGE PACKAGE #else -#define DPACKAGE unknown +#define DPACKAGE "unknown" #endif #endif diff --git a/mpiosh/.gitignore b/mpiosh/.gitignore new file mode 100644 index 0000000..2e3941e --- /dev/null +++ b/mpiosh/.gitignore @@ -0,0 +1,2 @@ +mpiosh +config.h diff --git a/mpiosh/CMakeLists.txt b/mpiosh/CMakeLists.txt new file mode 100644 index 0000000..efff2c7 --- /dev/null +++ b/mpiosh/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required (VERSION 2.4) + +set (PACKAGE mpiosh) +project (${PACKAGE} C) + +set (CMAKE_C_FLAGS -Wall) + +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/config.h) + +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_executable (mpiosh mpiosh.c callback.c readline.c command.c global.c + cfgio.c cfg.c) +target_link_libraries (mpiosh mpio -lreadline -lncurses) diff --git a/mpiosh/Makefile.am b/mpiosh/Makefile.am deleted file mode 100644 index ed5843e..0000000 --- a/mpiosh/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -INCLUDES=-I.. - -bin_PROGRAMS=mpiosh - -mpiosh_SOURCES = mpiosh.c \ - callback.c \ - readline.c \ - command.c \ - global.c \ - cfgio.c \ - config.c - -AM_CFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" - -mpiosh_LDADD=../libmpio/libmpio.la -lreadline -lncurses - -noinst_HEADERS = mpiosh.h \ - callback.h \ - readline.h \ - command.h \ - global.h \ - cfgio.h \ - config.h \ No newline at end of file diff --git a/mpiosh/callback.c b/mpiosh/callback.c index ad4a133..10e5a0a 100644 --- a/mpiosh/callback.c +++ b/mpiosh/callback.c @@ -34,6 +34,7 @@ #include "mpiosh.h" #include "command.h" +#include "cfg.h" #include "libmpio/debug.h" diff --git a/mpiosh/cfg.c b/mpiosh/cfg.c new file mode 100644 index 0000000..f8c672f --- /dev/null +++ b/mpiosh/cfg.c @@ -0,0 +1,238 @@ +/* config.c + * + * Author: Andreas Buesching + * + * $Id: config.c,v 1.7 2003/06/27 13:40:23 crunchy Exp $ + * + * Copyright (C) 2001 Andreas Büsching + * + * This program 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. + * + * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "cfg.h" +#include "global.h" + +#include +#include +#include + +struct mpiosh_config_t * +mpiosh_config_new(void) +{ + struct mpiosh_config_t * cfg = malloc(sizeof(struct mpiosh_config_t)); + char *filename, *tmp; + struct stat st; + + cfg->prompt_int = cfg->prompt_ext = NULL; + cfg->default_mem = MPIO_INTERNAL_MEM; + + filename = malloc(strlen(CONFIG_GLOBAL) + strlen(CONFIG_FILE) + 1); + filename[0] = '\0'; + strcat(filename, CONFIG_GLOBAL); + strcat(filename, CONFIG_FILE); + tmp = cfg_resolve_path(filename); + + if (stat(tmp, &st) != -1) + cfg->handle_global = + cfg_handle_new_with_filename(tmp, 1); + else + cfg->handle_global = 0; + + free(tmp), free(filename); + filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_FILE) + 1); + filename[0] = '\0'; + strcat(filename, CONFIG_USER); + strcat(filename, CONFIG_FILE); + tmp = cfg_resolve_path(filename); + + if (stat(tmp, &st) != -1) + cfg->handle_user = + cfg_handle_new_with_filename(tmp, 1); + else + cfg->handle_user = + cfg_handle_new_with_filename(tmp, 0); + + free(tmp), free(filename); + + /* initialise history */ + using_history(); + + filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_HISTORY) + 1); + filename[0] = '\0'; + strcat(filename, CONFIG_USER); + strcat(filename, CONFIG_HISTORY); + tmp = cfg_resolve_path(filename); + + read_history(tmp); + free(tmp), free(filename); + + return cfg; +} + +const char * +mpiosh_config_read_key(struct mpiosh_config_t *config, const char *group, + const char *key) +{ + char *value = NULL; + + if (config->handle_user) + value = (char *)cfg_key_get_value(config->handle_user, + group, key); + else if (config->handle_global) + value = (char *)cfg_key_get_value(config->handle_global, + group, key); + + return value; +} + +void +mpiosh_config_free(struct mpiosh_config_t *config) +{ + if (config->handle_global) + cfg_close(config->handle_global); + + cfg_close(config->handle_user); + free(config->prompt_int); + free(config->prompt_ext); + free(config); +} + +int +mpiosh_config_read(struct mpiosh_config_t *config) +{ + if (config) { + const char *value; + + value = mpiosh_config_read_key(config, "mpiosh", "prompt_int"); + if (value) { + config->prompt_int = strdup(value); + } else { + config->prompt_int = strdup(PROMPT_INT); + } + + value = mpiosh_config_read_key(config, "mpiosh", "prompt_ext"); + if (value) { + config->prompt_ext = strdup(value); + } else { + config->prompt_ext = strdup(PROMPT_EXT); + } + + value = mpiosh_config_read_key(config, "mpiosh", "default_mem"); + if (value) { + if (!strcmp("internal", value)) { + config->default_mem = MPIO_INTERNAL_MEM; + } else if (!strcmp("external", value)) { + config->default_mem = MPIO_EXTERNAL_MEM; + } + } + + value = mpiosh_config_read_key(config, "mpiosh", "charset"); + if (value) { + config->charset = strdup(value); + } else { + config->charset = NULL; + } + + value = mpiosh_config_read_key(config, "mpiosh", "id3_rewriting"); + if (value) { + if (!strcmp("on", value)) { + config->id3_rewriting = 1; + } else { + config->id3_rewriting = 0; + } + } + + value = mpiosh_config_read_key(config, "mpiosh", "id3_format"); + if (value) { + config->id3_format = strdup(value); + } else { + config->id3_format = strdup(MPIO_ID3_FORMAT); + } + + } + + return 1; +} + +char * +mpiosh_config_check_backup_dir( struct mpiosh_config_t *config, int create ) +{ + DIR *dir; + char *path = cfg_resolve_path( CONFIG_BACKUP ); + char *ret = path; + + if ( ( dir = opendir( path ) ) == NULL ) + if ( create ) { + if ( mkdir(path, 0777 ) ) + ret = NULL; + } else + ret = NULL; + else + closedir(dir); + + return ret; +} + +int +mpiosh_config_write( struct mpiosh_config_t *config ) +{ + DIR *dir; + char *path = cfg_resolve_path(CONFIG_USER); + + if ((dir = opendir(path)) == NULL) + mkdir(path, 0777); + else + closedir(dir); + + free(path); + + if (config->handle_user) { + char *tmp, *filename; + + cfg_key_set_value(config->handle_user, + "mpiosh", "prompt_int", config->prompt_int); + cfg_key_set_value(config->handle_user, + "mpiosh", "prompt_ext", config->prompt_ext); + if (config->default_mem == MPIO_EXTERNAL_MEM) + cfg_key_set_value(config->handle_user, + "mpiosh", "default_mem", "external"); + else + cfg_key_set_value(config->handle_user, + "mpiosh", "default_mem", "internal"); + cfg_key_set_value(config->handle_user, + "mpiosh", "id3_rewriting", + (config->id3_rewriting?"on":"off")); + cfg_key_set_value(config->handle_user, + "mpiosh", "id3_format", config->id3_format); + + cfg_save(config->handle_user, 0); + + /* save history */ + filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_HISTORY) + 1); + filename[0] = '\0'; + strcat(filename, CONFIG_USER); + strcat(filename, CONFIG_HISTORY); + tmp = cfg_resolve_path(filename); + + printf("writing history to file %s\n", filename); + write_history(tmp); + free(tmp), free(filename); + } + + return 1; +} + + +/* end of config.c */ diff --git a/mpiosh/cfg.h b/mpiosh/cfg.h new file mode 100644 index 0000000..4157bd6 --- /dev/null +++ b/mpiosh/cfg.h @@ -0,0 +1,56 @@ +/* config.h + * + * Author: Andreas Buesching + * + * $Id: config.h,v 1.5 2003/06/27 13:40:23 crunchy Exp $ + * + * Copyright (C) 2001 Andreas Büsching + * + * This program 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. + * + * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef MPIOSH_CONFIG_HH +#define MPIOSH_CONFIG_HH + +#include "cfgio.h" + +struct mpiosh_config_t { + CfgHandle *handle_global; + CfgHandle *handle_user; + + char *prompt_int; + char *prompt_ext; + char *charset; + unsigned default_mem; + + unsigned id3_rewriting; + char *id3_format; +}; + +struct mpiosh_config_t *mpiosh_config_new(void); +void mpiosh_config_free(struct mpiosh_config_t *config); + +const char *mpiosh_config_read_key(struct mpiosh_config_t *config, + const char *group, const char *key); +int mpiosh_config_read(struct mpiosh_config_t *config); +int mpiosh_config_write(struct mpiosh_config_t *config); + +char * mpiosh_config_check_backup_dir( struct mpiosh_config_t *config, + int create ); + +#endif + +/* end of config.h */ + diff --git a/mpiosh/config.c b/mpiosh/config.c deleted file mode 100644 index 931f785..0000000 --- a/mpiosh/config.c +++ /dev/null @@ -1,238 +0,0 @@ -/* config.c - * - * Author: Andreas Buesching - * - * $Id: config.c,v 1.7 2003/06/27 13:40:23 crunchy Exp $ - * - * Copyright (C) 2001 Andreas Büsching - * - * This program 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. - * - * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "global.h" - -#include -#include -#include - -struct mpiosh_config_t * -mpiosh_config_new(void) -{ - struct mpiosh_config_t * cfg = malloc(sizeof(struct mpiosh_config_t)); - char *filename, *tmp; - struct stat st; - - cfg->prompt_int = cfg->prompt_ext = NULL; - cfg->default_mem = MPIO_INTERNAL_MEM; - - filename = malloc(strlen(CONFIG_GLOBAL) + strlen(CONFIG_FILE) + 1); - filename[0] = '\0'; - strcat(filename, CONFIG_GLOBAL); - strcat(filename, CONFIG_FILE); - tmp = cfg_resolve_path(filename); - - if (stat(tmp, &st) != -1) - cfg->handle_global = - cfg_handle_new_with_filename(tmp, 1); - else - cfg->handle_global = 0; - - free(tmp), free(filename); - filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_FILE) + 1); - filename[0] = '\0'; - strcat(filename, CONFIG_USER); - strcat(filename, CONFIG_FILE); - tmp = cfg_resolve_path(filename); - - if (stat(tmp, &st) != -1) - cfg->handle_user = - cfg_handle_new_with_filename(tmp, 1); - else - cfg->handle_user = - cfg_handle_new_with_filename(tmp, 0); - - free(tmp), free(filename); - - /* initialise history */ - using_history(); - - filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_HISTORY) + 1); - filename[0] = '\0'; - strcat(filename, CONFIG_USER); - strcat(filename, CONFIG_HISTORY); - tmp = cfg_resolve_path(filename); - - read_history(tmp); - free(tmp), free(filename); - - return cfg; -} - -const char * -mpiosh_config_read_key(struct mpiosh_config_t *config, const char *group, - const char *key) -{ - char *value = NULL; - - if (config->handle_user) - value = (char *)cfg_key_get_value(config->handle_user, - group, key); - else if (config->handle_global) - value = (char *)cfg_key_get_value(config->handle_global, - group, key); - - return value; -} - -void -mpiosh_config_free(struct mpiosh_config_t *config) -{ - if (config->handle_global) - cfg_close(config->handle_global); - - cfg_close(config->handle_user); - free(config->prompt_int); - free(config->prompt_ext); - free(config); -} - -int -mpiosh_config_read(struct mpiosh_config_t *config) -{ - if (config) { - const char *value; - - value = mpiosh_config_read_key(config, "mpiosh", "prompt_int"); - if (value) { - config->prompt_int = strdup(value); - } else { - config->prompt_int = strdup(PROMPT_INT); - } - - value = mpiosh_config_read_key(config, "mpiosh", "prompt_ext"); - if (value) { - config->prompt_ext = strdup(value); - } else { - config->prompt_ext = strdup(PROMPT_EXT); - } - - value = mpiosh_config_read_key(config, "mpiosh", "default_mem"); - if (value) { - if (!strcmp("internal", value)) { - config->default_mem = MPIO_INTERNAL_MEM; - } else if (!strcmp("external", value)) { - config->default_mem = MPIO_EXTERNAL_MEM; - } - } - - value = mpiosh_config_read_key(config, "mpiosh", "charset"); - if (value) { - config->charset = strdup(value); - } else { - config->charset = NULL; - } - - value = mpiosh_config_read_key(config, "mpiosh", "id3_rewriting"); - if (value) { - if (!strcmp("on", value)) { - config->id3_rewriting = 1; - } else { - config->id3_rewriting = 0; - } - } - - value = mpiosh_config_read_key(config, "mpiosh", "id3_format"); - if (value) { - config->id3_format = strdup(value); - } else { - config->id3_format = strdup(MPIO_ID3_FORMAT); - } - - } - - return 1; -} - -char * -mpiosh_config_check_backup_dir( struct mpiosh_config_t *config, int create ) -{ - DIR *dir; - char *path = cfg_resolve_path( CONFIG_BACKUP ); - char *ret = path; - - if ( ( dir = opendir( path ) ) == NULL ) - if ( create ) { - if ( mkdir(path, 0777 ) ) - ret = NULL; - } else - ret = NULL; - else - closedir(dir); - - return ret; -} - -int -mpiosh_config_write( struct mpiosh_config_t *config ) -{ - DIR *dir; - char *path = cfg_resolve_path(CONFIG_USER); - - if ((dir = opendir(path)) == NULL) - mkdir(path, 0777); - else - closedir(dir); - - free(path); - - if (config->handle_user) { - char *tmp, *filename; - - cfg_key_set_value(config->handle_user, - "mpiosh", "prompt_int", config->prompt_int); - cfg_key_set_value(config->handle_user, - "mpiosh", "prompt_ext", config->prompt_ext); - if (config->default_mem == MPIO_EXTERNAL_MEM) - cfg_key_set_value(config->handle_user, - "mpiosh", "default_mem", "external"); - else - cfg_key_set_value(config->handle_user, - "mpiosh", "default_mem", "internal"); - cfg_key_set_value(config->handle_user, - "mpiosh", "id3_rewriting", - (config->id3_rewriting?"on":"off")); - cfg_key_set_value(config->handle_user, - "mpiosh", "id3_format", config->id3_format); - - cfg_save(config->handle_user, 0); - - /* save history */ - filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_HISTORY) + 1); - filename[0] = '\0'; - strcat(filename, CONFIG_USER); - strcat(filename, CONFIG_HISTORY); - tmp = cfg_resolve_path(filename); - - printf("writing history to file %s\n", filename); - write_history(tmp); - free(tmp), free(filename); - } - - return 1; -} - - -/* end of config.c */ diff --git a/mpiosh/config.h b/mpiosh/config.h deleted file mode 100644 index 091e61a..0000000 --- a/mpiosh/config.h +++ /dev/null @@ -1,55 +0,0 @@ -/* config.h - * - * Author: Andreas Buesching - * - * $Id: config.h,v 1.5 2003/06/27 13:40:23 crunchy Exp $ - * - * Copyright (C) 2001 Andreas Büsching - * - * This program 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. - * - * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef MPIOSH_CONFIG_HH -#define MPIOSH_CONFIG_HH - -#include "cfgio.h" - -struct mpiosh_config_t { - CfgHandle *handle_global; - CfgHandle *handle_user; - - char *prompt_int; - char *prompt_ext; - char *charset; - unsigned default_mem; - - unsigned id3_rewriting; - char *id3_format; -}; - -struct mpiosh_config_t *mpiosh_config_new(void); -void mpiosh_config_free(struct mpiosh_config_t *config); - -const char *mpiosh_config_read_key(struct mpiosh_config_t *config, - const char *group, const char *key); -int mpiosh_config_read(struct mpiosh_config_t *config); -int mpiosh_config_write(struct mpiosh_config_t *config); - -char * mpiosh_config_check_backup_dir( struct mpiosh_config_t *config, - int create ); - -#endif - -/* end of config.h */ diff --git a/mpiosh/config.h.in b/mpiosh/config.h.in new file mode 100644 index 0000000..bb60f14 --- /dev/null +++ b/mpiosh/config.h.in @@ -0,0 +1,9 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +/* package name */ +#define PACKAGE "${PACKAGE}" +#define VERSION "0.7.1-pre3" +#define SYSCONFDIR "/etc" + +#endif /* _CONFIG_H */ diff --git a/mpiosh/global.c b/mpiosh/global.c index f589114..09a63f3 100644 --- a/mpiosh/global.c +++ b/mpiosh/global.c @@ -24,6 +24,7 @@ #include "callback.h" #include "global.h" #include "readline.h" +#include "cfg.h" /* structure containing current state */ struct mpiosh_t mpiosh; diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c index eb20845..7a5370a 100644 --- a/mpiosh/mpiosh.c +++ b/mpiosh/mpiosh.c @@ -35,7 +35,7 @@ #include "callback.h" #include "command.h" -#include "config.h" +#include "cfg.h" #include "readline.h" #include "mpiosh.h" diff --git a/tools/Makefile.am b/tools/Makefile.am deleted file mode 100644 index 0830a44..0000000 --- a/tools/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -bin_PROGRAMS=mpiologo - -mpiologo_SOURCES=mpiologo.c -- cgit v1.2.3