Changeset 214fc9d7a7c8ed9ee8fd8b8c51b19287374157e8

Show
Ignore:
Timestamp:
03/03/10 03:10:36 (2 years ago)
Author:
Philip Herron <redbrain@…>
Parents:
f72fb404911ac4d42b7d10d62e462db348645527
Children:
a6d31aec35d85c450d6b3d485dcd9b3ac9070afc
git-committer:
Philip Herron <redbrain@omicron.(none)> / 2010-03-03T03:10:36Z+0000
Message:

basic cmake support

Files:
7 modified
2 moved

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    rf72fb40 r214fc9d  
    22cmake_minimum_required(VERSION 2.6) 
    33add_subdirectory(src) 
    4 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 
    5 set (Crules_VERSION 0.44) 
    64 
     5FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h) 
     6FIND_LIBRARY(READLINE_LIBRARY NAMES readline) 
     7 
     8IF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY) 
     9SET(READLINE_FOUND TRUE) 
     10ENDIF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY) 
     11 
     12IF (READLINE_FOUND) 
     13IF (NOT Readline_FIND_QUIETLY) 
     14MESSAGE(STATUS "Found GNU readline: ${READLINE_LIBRARY}") 
     15ENDIF (NOT Readline_FIND_QUIETLY) 
     16ELSE (READLINE_FOUND) 
     17IF (Readline_FIND_REQUIRED) 
     18MESSAGE(FATAL_ERROR "Could not find GNU readline") 
     19ENDIF (Readline_FIND_REQUIRED) 
     20ENDIF (READLINE_FOUND) 
     21 
     22set(CMAKE_MODULE_PATH "cmake/") 
    723find_package(BISON) 
    824find_package(FLEX) 
    925 
    10 BISON_TARGET(MyParser ss_parser.y src/ss_parser.c) 
    11 FLEX_TARGET(MyScanner ss_lexical.l src/ss_lexical.c) 
     26BISON_TARGET(MyParser src/ss_parser.y src/ss_parser.c) 
     27FLEX_TARGET(MyScanner src/ss_lexical.l src/ss_lexical.c) 
    1228ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser) 
    1329 
     30include_directories (include) 
     31ADD_LIBRARY(parser STATIC  
     32  ${BISON_MyParser_OUTPUTS} 
     33  ${FLEX_MyScanner_OUTPUTS} 
     34  ) 
     35 
     36set (Crules_VERSION 0.44) 
    1437# does this system provide the log and exp functions? 
    1538include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) 
  • configure.ac

    r1bb5963 r214fc9d  
    226226AC_HEADER_STDC 
    227227AC_CHECK_HEADERS([stdlib.h string.h stdarg.h unistd.h \ 
    228                                              stdint.h stdio.h getopt.h \ 
    229                                              assert.h sys/types.h signal.h \ 
    230                                              fcntl.h pthread.h sys/wait.h]) 
     228                  stdint.h stdio.h getopt.h \ 
     229                  assert.h sys/types.h signal.h \ 
     230                  fcntl.h pthread.h sys/wait.h]) 
    231231 
    232232# Checks for typedefs, structures, and compiler characteristics. 
     
    235235AC_TYPE_SIZE_T 
    236236AC_CHECK_FUNCS([popen fopen fclose sprintf fprintf strdup \ 
    237                                   strlen strcpy strcmp getopt_long \ 
    238                                   memcpy calloc system sysconf atoi \ 
    239                                   getpid execl fork wait exit atof \ 
    240                                   vfprintf memcmp getc fgets pipe \ 
    241                                   waitpid fdopen]) 
     237                strlen strcpy strcmp getopt_long \ 
     238                memcpy calloc system sysconf atoi \ 
     239                getpid execl fork wait exit atof \ 
     240                vfprintf memcmp getc fgets pipe \ 
     241                waitpid fdopen]) 
    242242 
    243243# Checks for library functions. 
     
    248248                 include/Makefile 
    249249                 src/Makefile 
    250                              tests/Makefile 
     250                 tests/Makefile 
    251251                 config/pkg-config/crules.pc]) 
    252252AC_OUTPUT 
  • src/CMakeLists.txt

    rf72fb40 r214fc9d  
    11include_directories (../include) 
    2 add_executable( crules mm_crules.c bb_backend.c bb_signals.c builtin_call_table.c builtin_hash_table.c builtin_stack.c gg_garbage.c object_class.c object_list.c object_number.c object_string.c rr_bin_eval.c rr_context.c rr_runtime.c ss_eval.c ) 
     2add_executable( crules 
     3  mm_crules.c 
     4  bb_backend.c 
     5  bb_signals.c 
     6  builtin_call_table.c 
     7  builtin_hash_table.c 
     8  builtin_stack.c 
     9  gg_garbage.c 
     10  object_class.c 
     11  object_list.c 
     12  object_number.c 
     13  object_string.c 
     14  rr_bin_eval.c 
     15  rr_context.c 
     16  rr_runtime.c 
     17  ss_eval.c  
     18) 
     19 
     20TARGET_LINK_LIBRARIES( crules parser ) 
  • src/config.h.in.cmake

    r0608895 r214fc9d  
    11// the configured options and settings for Tutorial 
    2 #define VERSION @Crules_VERSION@ 
     2#define VERSION "@Crules_VERSION@" 
  • src/mm_crules.c

    rf72fb40 r214fc9d  
    7777      //print the header messages :) 
    7878      time_t lt= time( NULL ); 
    79 #ifndef CMAKE 
    8079      fprintf( stdout, "Crules %s - ", VERSION ); 
    8180      fprintf( stdout, "%s", ctime( &lt ) ); 
     81#ifndef CMAKE 
    8282      fprintf( stdout, "[ %s:%s ( %s:%s ) ]\n", CONFIG_CC, 
    8383               CONFIG_CC_VER, SYSTEM_TYPE,  MACHINE_TYPE ); 
    84 #else 
    85       fprintf( stdout, "Crules %f - ", VERSION ); 
    86       fprintf( stdout, "%s", ctime( &lt ) ); 
    8784#endif 
    8885      err= crl_parse( stdin ); 
     
    9996void print_version( void ) 
    10097{ 
    101 #ifndef CMAKE 
    10298  fprintf( crlout, "Crules interpreter version: %s\n", VERSION ); 
    10399  fprintf( crlout, "Copyright (c) Philip Herron 2009-2010\n" ); 
     100#ifndef CMAKE 
    104101  fprintf( crlout, "Compiled for: %s %s\n", SYSTEM_TYPE, MACHINE_TYPE ); 
    105102  fprintf( crlout, "Report suggestions and bugs to: %s\n", PACKAGE_BUGREPORT ); 
    106 #else 
    107   fprintf( stdout, "Crules interpreter version: %f\n", VERSION ); 
    108   fprintf( crlout, "Copyright (c) Philip Herron 2009-2010\n" ); 
    109103#endif 
    110104  fprintf( crlout, "\nThis is free software; see the source for copying conditions.  There is NO\n" ); 
  • src/ss_lexical.l

    r27371b7 r214fc9d  
    3333#ifdef HAVE_CONFIG_H 
    3434# include "config.h" 
    35 #endif 
     35#else 
     36# define CMAKE 1 
     37# include "config.h.cmake" 
     38#endif 
     39 
     40#define LINE_MAX 256 
    3641 
    3742#include <crules/crules.h> 
     
    4146#include <crules/backend.h> 
    4247 
    43 #include "libparser_a-ss_parser.h" 
     48#ifndef CMAKE 
     49# include "libparser_a-ss_parser.h" 
     50#else 
     51# include "ss_parser.h" 
     52#endif 
    4453 
    4554#ifdef HAVE_LIBREADLINE 
     
    216225  if( fin == stdin ) 
    217226    { 
    218       const char *prompt= ">>> "; 
     227      YY_BUFFER_STATE bp; const char * prompt= ">>> "; 
    219228#ifdef HAVE_LIBREADLINE 
    220       char *line; 
    221 #else 
    222       char line[256]; 
    223 #endif 
    224       YY_BUFFER_STATE bp; 
     229      char *line= NULL; 
    225230      while( 1 ) 
    226         { 
    227 #ifdef HAVE_LIBREADLINE 
    228           line= readline( prompt ); 
    229 #else 
    230           fprintf( stdout, "%s", prompt ); 
    231           fgets( line, sizeof(line), stdin ); 
    232 #endif 
    233           crl_lexer_mark_string( line ); 
    234  
    235           if( line == 0 ) 
     231        { 
     232          line= readline( prompt ); 
     233          crl_lexer_mark_string( line ); 
     234           
     235          if( line == 0 ) 
    236236            break; 
    237237          else if( crl_strlen( line ) > 0 ) 
     
    245245              yy_delete_buffer( bp ); 
    246246            } 
    247         } 
     247        } 
     248#else 
     249      char line[LINE_MAX]; 
     250      fprintf( stdout, "%s", prompt ); 
     251      while( fgets(line, LINE_MAX, stdin) != NULL ) 
     252        { 
     253          bp= yy_scan_string( line ); 
     254          yy_switch_to_buffer( bp ); 
     255          err= yyparse( ); 
     256          yy_delete_buffer( bp ); 
     257          fprintf( stdout, "%s", prompt ); 
     258        } 
     259#endif 
    248260    } 
    249261  else 
  • src/ss_parser.y

    r07e348d r214fc9d  
    3232#ifdef HAVE_CONFIG_H 
    3333# include "config.h" 
     34#else 
     35# define CMAKE 1 
     36# include "config.h.cmake" 
    3437#endif 
    3538 
     
    112115%type<symbol> procedure 
    113116%type<stack> parameters 
    114 %type<stack> iterators 
    115117%type<list> list_symbol 
    116118%type<stack> arguments 
     
    490492        ; 
    491493 
    492 iterators: parameters 
    493         ; 
    494  
    495 loop_for: FOR '(' expression expression expression ')' '{' procedure '}' 
     494 
     495loop_for: FOR '(' ')' '{' procedure '}' 
    496496        { 
    497497          $$= NULL;