- Refactored code for readability, and split off archives. Works fine now on Mac-Intel
This commit is contained in:
parent
ad984680ac
commit
7978eb6716
11
src/BuildMacIntel.cmake
Normal file
11
src/BuildMacIntel.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
################################################################
|
||||
# Name: BuildMacIntel.cmake
|
||||
# Purpose: Build MacIntel binary on self
|
||||
# Author: Cas Cremers
|
||||
################################################################
|
||||
|
||||
message (STATUS "Building Apple Mac Intel version")
|
||||
set (scythername "scyther-macintel")
|
||||
add_executable (${scythername} ${Scyther_sources})
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fnested-functions")
|
||||
|
29
src/BuildPlatform.cmake
Normal file
29
src/BuildPlatform.cmake
Normal file
@ -0,0 +1,29 @@
|
||||
################################################################
|
||||
# Name: BuildPlatform.cmake
|
||||
# Purpose: Make platform-dependant decisions
|
||||
# Author: Cas Cremers
|
||||
################################################################
|
||||
|
||||
# Retrieve Source_OS, Destination_OS (from -DTARGET)
|
||||
include (GetOS.cmake)
|
||||
|
||||
# From source_os and destination_os make a new name for the build script
|
||||
if (Source_OS STREQUAL Destination_OS)
|
||||
set (BuildScriptName "Build${Source_OS}.cmake")
|
||||
else (Source_OS STREQUAL Destination_OS)
|
||||
set (BuildScriptName "Build${Source_OS}-${Destination_OS}.cmake")
|
||||
endif (Source_OS STREQUAL Destination_OS)
|
||||
find_file (BuildScriptFile "${BuildScriptName}")
|
||||
if (BuildScriptFile)
|
||||
# Execute the build script
|
||||
include (${BuildScriptFile})
|
||||
else (BuildScriptFile)
|
||||
# Could not find it!
|
||||
message (STATUS "Could not find ${BuildScriptName}")
|
||||
if (Source_OS STREQUAL Destination_OS)
|
||||
message (FATAL_ERROR "Don't know how to build on ${Source_OS}")
|
||||
else (Source_OS STREQUAL Destination_OS)
|
||||
message (FATAL_ERROR "Don't know how to build for ${Destination_OS} on ${Source_OS}")
|
||||
endif (Source_OS STREQUAL Destination_OS)
|
||||
endif (BuildScriptFile)
|
||||
|
15
src/BuildUnix-Win32.cmake
Normal file
15
src/BuildUnix-Win32.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
################################################################
|
||||
# Name: BuildUnix-Win32.cmake
|
||||
# Purpose: Build Win32 binary on Unix
|
||||
# Author: Cas Cremers
|
||||
################################################################
|
||||
|
||||
message (STATUS "Building W32 version")
|
||||
# This should work on win32 platform, but also when the compiler
|
||||
# is available anyway under linux
|
||||
set (CMAKE_C_COMPILER "i586-mingw32msvc-gcc")
|
||||
set (CMAKE_CXX_COMPILER "i586-mingw32msvc-g++")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # to get rid of -rdynamic
|
||||
set (scythername "scyther-w32.exe")
|
||||
add_executable (${scythername} ${Scyther_sources})
|
||||
|
12
src/BuildUnix.cmake
Normal file
12
src/BuildUnix.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
################################################################
|
||||
# Name: BuildUnix.cmake
|
||||
# Purpose: Build Unix binary on self
|
||||
# Author: Cas Cremers
|
||||
################################################################
|
||||
|
||||
# We call it linux, because that is what de-facto is the case.
|
||||
|
||||
message (STATUS "Building Linux version")
|
||||
set (scythername "scyther-linux")
|
||||
add_executable (${scythername} ${Scyther_sources})
|
||||
|
@ -29,60 +29,6 @@ include (SVNVersion.cmake)
|
||||
# Make scanner and parser
|
||||
include (ScannerParser.cmake)
|
||||
|
||||
# By default, we build what we get
|
||||
if (NOT TARGETOS)
|
||||
if (WIN32)
|
||||
set (TARGETOS "WIN32")
|
||||
else (WIN32)
|
||||
if (APPLE)
|
||||
set (TARGETOS "APPLE")
|
||||
else (APPLE)
|
||||
if (UNIX)
|
||||
set (TARGETOS "UNIX")
|
||||
endif (UNIX)
|
||||
endif (APPLE)
|
||||
endif (WIN32)
|
||||
endif (NOT TARGETOS)
|
||||
message (STATUS "Target OS: ${TARGETOS}")
|
||||
|
||||
# Determine name and target from type
|
||||
if ("${TARGETOS}" STREQUAL "UNIX")
|
||||
# Should for now only be done on the unix platform
|
||||
message (STATUS "sjonge met [${TARGETOS}]")
|
||||
if (UNIX)
|
||||
message (STATUS "Building Linux version")
|
||||
set (scythername "scyther-linux")
|
||||
add_executable (${scythername} ${Scyther_sources})
|
||||
endif (UNIX)
|
||||
endif ("${TARGETOS}" STREQUAL "UNIX")
|
||||
|
||||
|
||||
|
||||
if ("${TARGETOS}" STREQUAL "APPLE")
|
||||
if (APPLE)
|
||||
# Should for now only be done on the apple platform
|
||||
message (STATUS "Building Apple version")
|
||||
set (scythername "scyther-mac")
|
||||
add_executable (${scythername} ${Scyther_sources})
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fnested-functions")
|
||||
endif (APPLE)
|
||||
endif ("${TARGETOS}" STREQUAL "APPLE")
|
||||
|
||||
if ("${TARGETOS}" STREQUAL "WIN32")
|
||||
message (STATUS "Building W32 version")
|
||||
# This should work on win32 platform, but also when the compiler
|
||||
# is available anyway under linux
|
||||
set (CMAKE_C_COMPILER "i586-mingw32msvc-gcc")
|
||||
set (CMAKE_CXX_COMPILER "i586-mingw32msvc-g++")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # to get rid of -rdynamic
|
||||
set (scythername "scyther-w32.exe")
|
||||
add_executable (${scythername} ${Scyther_sources})
|
||||
endif ("${TARGETOS}" STREQUAL "WIN32")
|
||||
|
||||
# Make the Scyther linux binary
|
||||
if (NOT scythername)
|
||||
message (FATAL_ERROR "Cannot determine target platform [${TARGETOS}]")
|
||||
endif (NOT scythername)
|
||||
|
||||
|
||||
# Set build target settings according to platform
|
||||
include (BuildPlatform.cmake)
|
||||
|
||||
|
43
src/GetOS.cmake
Normal file
43
src/GetOS.cmake
Normal file
@ -0,0 +1,43 @@
|
||||
################################################################
|
||||
# Name: GetOS.cmake
|
||||
# Purpose: Determine Source_OS and Destination_OS (-DTARGETOS)
|
||||
# Author: Cas Cremers
|
||||
################################################################
|
||||
|
||||
# Supported types:
|
||||
#
|
||||
# Win32
|
||||
# Unix
|
||||
# MacPPC
|
||||
# MacIntel
|
||||
|
||||
# First we find out the current operating system
|
||||
set (Source_OS)
|
||||
if (WIN32)
|
||||
# Windows
|
||||
set (Source_OS "Win32")
|
||||
else (WIN32)
|
||||
# Not windows, is it a mac?
|
||||
if (APPLE)
|
||||
# TODO: A mac, but what architecture?
|
||||
# For now we assume intel (Christoph Sprenger's machine)
|
||||
set (Source_OS "MacIntel")
|
||||
else (APPLE)
|
||||
# Not a mac, not windows
|
||||
if (UNIX)
|
||||
set (Source_OS "Unix")
|
||||
else (UNIX)
|
||||
message (FATAL "Unrecognized source platform.")
|
||||
endif (UNIX)
|
||||
endif (APPLE)
|
||||
endif (WIN32)
|
||||
message (STATUS "Source platform: ${Source_OS}")
|
||||
|
||||
# Destination? If target is unset, we just take the source
|
||||
if (TARGETOS)
|
||||
set (Destination_OS "${TARGETOS}")
|
||||
else (TARGETOS)
|
||||
set (Destination_OS "${Source_OS}")
|
||||
endif (TARGETOS)
|
||||
message (STATUS "Destination platform: ${Destination_OS}")
|
||||
|
@ -14,7 +14,7 @@ if (FLEX_FOUND)
|
||||
COMMAND ${FLEX_EXECUTABLE}
|
||||
# TODO: I should look up from which version the -o
|
||||
# switch works, might not be portable.
|
||||
ARGS -o scanner.c scanner.l
|
||||
ARGS -oscanner.c scanner.l
|
||||
COMMENT "Building scanner.c from scanner.l using flex"
|
||||
)
|
||||
else (FLEX_FOUND)
|
||||
@ -31,7 +31,7 @@ if (BISON_FOUND)
|
||||
COMMAND ${BISON_EXECUTABLE}
|
||||
# TODO: I should look up from which version the -o
|
||||
# switch works, might not be portable.
|
||||
ARGS -o parser.c parser.y
|
||||
ARGS -oparser.c parser.y
|
||||
COMMENT "Building parser.c from parser.y using bison"
|
||||
)
|
||||
else (BISON_FOUND)
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "switches.h"
|
||||
#include "depend.h"
|
||||
#include "error.h"
|
||||
#ifndef OSXHOST
|
||||
#if !defined(__APPLE__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "list.h"
|
||||
#ifndef OSXHOST
|
||||
#if !defined(__APPLE__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
2720
src/parser.c
2720
src/parser.c
File diff suppressed because it is too large
Load Diff
1480
src/scanner.c
1480
src/scanner.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user