fix build on Solaris 10

Solaris 10 is too old for POSIX.2008, thus wcsdup() is missing
This commit is contained in:
Georg Sauthoff 2016-08-23 21:13:46 +02:00
parent 1888f89375
commit d648e92188
10 changed files with 73 additions and 2 deletions

View file

@ -1,8 +1,12 @@
# 2016, Georg Sauthoff <mail@georg.so>
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
project(somake C CXX)
include(CheckFunctionExists)
check_function_exists(wcsdup HAVE_WCSDUP)
configure_file(config.h.in config.h)
add_library(mksh STATIC
lib/mksh/dosys.cc lib/mksh/globals.cc lib/mksh/i18n.cc lib/mksh/macro.cc
lib/mksh/misc.cc lib/mksh/mksh.cc lib/mksh/read.cc
@ -25,12 +29,14 @@ add_executable(${PROJECT_NAME}
bin/main.cc bin/misc.cc bin/nse_printdep.cc bin/parallel.cc
bin/pmake.cc bin/read.cc bin/read2.cc bin/rep.cc
bin/state.cc
comp/progname.c
lib/bsd/bsd.cc
comp/progname.c comp/wcsdup.c
)
set_property(TARGET ${PROJECT_NAME} mksh vroot PROPERTY INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}

View file

@ -267,6 +267,11 @@ Although those changes target Linux, they aren't really Linux
specific. That means that the ported make should also compile on
other modern [POSIXy][posix] operating systems.
So far, the port was successfully tested under:
- Fedora 23/x86-64
- Solaris 10/SPARC
## Naming
@ -306,6 +311,14 @@ differently, e.g.:
-- Installing: dest/usr/bin/somake
[..]
### Tweaks
If you are compiling on a legacy platform with ancient libraries
you may need to tweak the cmake call a little bit. For example,
to compile with GCC on a Solaris 10 system:
$ CC=gcc CXX=g++ LDFLAGS='-lnsl /opt/csw/lib/libintl.so.8' \
cmake -DCMAKE_BUILD_TYPE=Release ../somake
### Manual Installation
@ -329,6 +342,7 @@ the following order:
5. `/usr/share/lib/make/make.rules`
6. `/etc/default/make.rules`
## License
Perhaps not required by the CDDL, but I license my changes

View file

@ -44,6 +44,7 @@
#include <libintl.h>
#include <comp/progname.h>
#include <comp/wcsdup.h>
/*
* typedefs & structs

View file

@ -40,6 +40,7 @@
#include <libintl.h>
#include <comp/progname.h>
#include <comp/wcsdup.h>
/*
* Defined macros

View file

@ -36,6 +36,8 @@
#include <mksh/misc.h> /* retmem() */
#include <vroot/report.h> /* NSE_DEPINFO */
#include <comp/wcsdup.h>
/*
* Static variables
*/

16
comp/wcsdup.c Normal file
View file

@ -0,0 +1,16 @@
// 2016, Georg Sauthoff <mail@georg.so>, CDDL and WTFPL
#include "wcsdup.h"
#ifndef HAVE_WCSDUP
#include <stdlib.h>
// this function is part of POSIX.2008
wchar_t * wcsdup(const wchar_t *s)
{
size_t n = wcslen(s) + 1;
wchar_t r = malloc(n * sizeof(wchar_t));
return r ? return wmemcpy(r, s, n) : 0;
}
#endif

19
comp/wcsdup.h Normal file
View file

@ -0,0 +1,19 @@
// 2016, Georg Sauthoff <mail@georg.so>, CDDL
#ifndef COMPAT_WCSDUP_H
#define COMPAT_WCSDUP_H
#include <wchar.h>
#include "config.h"
#ifndef HAVE_WCSDUP
#if defined(__cplusplus)
extern "C" {
#endif
wchar_t * wcsdup (const wchar_t *s);
#if defined(__cplusplus)
}
#endif
#endif
#endif

7
config.h.in Normal file
View file

@ -0,0 +1,7 @@
// 2016, Georg Sauthoff <mail@georg.so>, CDDL and WTFPL
#ifndef SOMAKE_CONFIG_H
#define SOMAKE_CONFIG_H
#cmakedefine HAVE_WCSDUP 1
#endif

View file

@ -23,6 +23,7 @@
* Use is subject to license terms.
*/
#if defined(__sun)
#include <signal.h>
@ -71,3 +72,5 @@ bsd_signals (void)
return;
}
#endif

View file

@ -41,6 +41,8 @@
#include <libintl.h>
#include <comp/wcsdup.h>
/*
* File table of contents
*/