Skip to content

Commit

Permalink
[mindheadless] cmakify autoconf config.h
Browse files Browse the repository at this point in the history
let's combine the worst of two worlds, what can go right?
  • Loading branch information
krono committed Sep 16, 2020
1 parent 5ca742c commit 78ac502
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 4 deletions.
61 changes: 61 additions & 0 deletions CMakeLists.txt
Expand Up @@ -275,6 +275,7 @@ include(CheckSymbolExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)

if(NOT WIN32)
include (TestBigEndian)
Expand Down Expand Up @@ -316,9 +317,27 @@ check_include_files(sys/dir.h HAVE_SYS_DIR_H)
check_include_files(sys/filio.h HAVE_SYS_FILIO_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)

check_include_files(execinfo.h HAVE_EXECINFO_H)
check_include_files(fcntl.h HAVE_FCNTL_H)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_include_files(memory.h HAVE_MEMORY_H)
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(string.h HAVE_STRING_H)
check_include_files(sys/file.h HAVE_SYS_FILE_H)
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)

check_include_files(dlfcn.h HAVE_DLFCN_H)
check_library_exists(dl dlopen "" HAVE_LIBDL)
check_library_exists(dyld dlopen "" HAVE_DYLD)
# is for the symbol
check_library_exists(dl dlerror "" HAVE_DLERROR)
check_library_exists(dyld dlerror "" HAVE_DLERROR)

# check_include_files(iconv.h HAVE_ICONV_H)
# check_library_exists(iconv iconv "" HAVE_ICONV)
Expand All @@ -337,6 +356,14 @@ check_function_exists(select HAVE_SELECT)
check_function_exists(epoll_create1 HAVE_EPOLL)
check_function_exists(epoll_pwait HAVE_EPOLL_PWAIT)



check_c_source_compiles("
#include <pthread.h>
int main() {
int i = PTHREAD_PRIO_INHERIT;
return i;}" HAVE_PTHREAD_PRIO_INHERIT)

# Time structures
set(CMAKE_EXTRA_INCLUDE_FILES time.h)
if(HAVE_SYS_TIME_H)
Expand All @@ -354,8 +381,33 @@ int main()
HAVE_TM_GMTOFF
)
check_type_size("struct timezone" HAVE_TIMEZONE)
check_c_source_compiles(
"#include <time.h>
int main() {
static struct tm a;
if (a.tm_zone) return 0;
return 0; }" HAVE_STRUCT_TM_TM_ZONE)
if(HAVE_STRUCT_TM_TM_ZONE)
set(HAVE_TM_ZONE TRUE)
endif()
set(CMAKE_EXTRA_INCLUDE_FILES)

# stat structure
if(HAVE_SYS_STAT_H)
check_c_source_compiles("
#include <sys/stat.h>
int main() {
static struct stat a;
if (a.st_blksize) return 0;
return 0;}" HAVE_STRUCT_STAT_ST_BLKSIZE)
if(HAVE_STRUCT_STAT_ST_BLKSIZE)
set(HAVE_ST_BLKSIZE TRUE)
endif()
else()
set(HAVE_STRUCT_STAT_ST_BLKSIZE FALSE)
set(HAVE_ST_BLKSIZE FALSE)
endif()

# Type sizes
if(BUILD_I386_VERSION OR SQUEAK_PLATFORM_X86_32)
set(SIZEOF_INT 4)
Expand Down Expand Up @@ -413,6 +465,15 @@ if(UUID_LIBRARY AND (HAVE_SYS_UUID_H OR HAVE_UUID_UUID_H OR HAVE_UUID_H) AND (HA
set(HAVE_VALID_UUID_LIBRARY True)
endif()

# misc
check_c_source_runs("
void f(int i){*(double *)i=*(double *)(i+4);}
int main(){char b[12];f(b);return 0;}" NO_DOUBLE_WORD_ALIGNMENT)
if(NOT NO_DOUBLE_WORD_ALIGNMENT)
set(DOUBLE_WORD_ALIGNMENT TRUE)
endif()


# Add the current directory.
include_directories(
.
Expand Down
2 changes: 1 addition & 1 deletion platforms/minheadless/common/sqPlatformSpecificCommon.h
Expand Up @@ -42,7 +42,7 @@ extern void sqErrorPrintf(const char *format, ...);
extern void sqFatalErrorPrintf(const char *format, ...);
extern void sqFatalErrorPrintfNoExit(const char *format, ...);
#ifndef error
extern void sqError(char *errorMessage);
extern void sqError(const char *errorMessage);
#define error sqError
#endif

Expand Down
4 changes: 2 additions & 2 deletions platforms/minheadless/common/sqPrinting.c
Expand Up @@ -34,14 +34,14 @@
#undef error

void
error(char *errorMessage)
error(const char *errorMessage)
{
sqError(errorMessage);
}
#endif

void
sqError(char *errorMessage)
sqError(const char *errorMessage)
{
fprintf(stderr, "%s\n", errorMessage);
abort();
Expand Down
28 changes: 27 additions & 1 deletion platforms/minheadless/config.h.in
Expand Up @@ -89,8 +89,24 @@
#cmakedefine HAVE_GL_GL_H 1
#cmakedefine HAVE_OPENGL_GL_H 1

#cmakedefine HAVE_EXECINFO_H 1
#cmakedefine HAVE_FCNTL_H 1
#cmakedefine HAVE_INTTYPES_H 1
#cmakedefine HAVE_MEMORY_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_FILE_H 1
#cmakedefine HAVE_SYS_PARAM_H 1
#cmakedefine HAVE_SYS_SELECT_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_SYS_TYPES_H 1

#cmakedefine NEED_SUNOS_H 1

#cmakedefine STDC_HEADERS 1

/* system calls/library functions */

#cmakedefine AT_EXIT 1
Expand Down Expand Up @@ -121,6 +137,8 @@

#cmakedefine HAVE_NANOSLEEP 1

#cmakedefine HAVE_DLERROR 1

/* widths of primitive types */

#define SIZEOF_INT @SIZEOF_INT@
Expand All @@ -133,6 +151,11 @@
#cmakedefine HAVE_TM_GMTOFF
#cmakedefine HAVE_TIMEZONE

#cmakedefine HAVE_STRUCT_STAT_ST_BLKSIZE 1
#cmakedefine HAVE_STRUCT_TM_TM_ZONE 1
#cmakedefine HAVE_ST_BLKSIZE 1
#cmakedefine HAVE_TM_ZONE 1

/* window systems */
#cmakedefine SUPPORT_TRADITIONAL_DISPLAY
#cmakedefine HAVE_SDL2
Expand All @@ -159,7 +182,7 @@
#endif

#cmakedefine WORDS_BIGENDIAN
#undef DOUBLE_WORD_ALIGNMENT
#cmakedefine DOUBLE_WORD_ALIGNMENT

/* damage containment */

Expand All @@ -182,6 +205,9 @@

/* other configured variables */

/* who cares */
#define HAVE_LIBDLLOADER 1

#cmakedefine VM_MODULE_PREFIX
#cmakedefine VM_DLSYM_PREFIX
#cmakedefine VM_X11DIR
Expand Down

0 comments on commit 78ac502

Please sign in to comment.