- Refactored code for readability, and split off archives. Works fine now on Mac-Intel

This commit is contained in:
ccremers 2007-01-08 13:24:37 +00:00
parent ad984680ac
commit 7978eb6716
11 changed files with 1803 additions and 2661 deletions

11
src/BuildMacIntel.cmake Normal file
View 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
View 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
View 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
View 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})

View File

@ -29,60 +29,6 @@ include (SVNVersion.cmake)
# Make scanner and parser # Make scanner and parser
include (ScannerParser.cmake) include (ScannerParser.cmake)
# By default, we build what we get # Set build target settings according to platform
if (NOT TARGETOS) include (BuildPlatform.cmake)
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)

43
src/GetOS.cmake Normal file
View 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}")

View File

@ -14,7 +14,7 @@ if (FLEX_FOUND)
COMMAND ${FLEX_EXECUTABLE} COMMAND ${FLEX_EXECUTABLE}
# TODO: I should look up from which version the -o # TODO: I should look up from which version the -o
# switch works, might not be portable. # 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" COMMENT "Building scanner.c from scanner.l using flex"
) )
else (FLEX_FOUND) else (FLEX_FOUND)
@ -31,7 +31,7 @@ if (BISON_FOUND)
COMMAND ${BISON_EXECUTABLE} COMMAND ${BISON_EXECUTABLE}
# TODO: I should look up from which version the -o # TODO: I should look up from which version the -o
# switch works, might not be portable. # 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" COMMENT "Building parser.c from parser.y using bison"
) )
else (BISON_FOUND) else (BISON_FOUND)

View File

@ -15,7 +15,7 @@
#include "switches.h" #include "switches.h"
#include "depend.h" #include "depend.h"
#include "error.h" #include "error.h"
#ifndef OSXHOST #if !defined(__APPLE__)
#include <malloc.h> #include <malloc.h>
#endif #endif

View File

@ -6,7 +6,7 @@
*/ */
#include "list.h" #include "list.h"
#ifndef OSXHOST #if !defined(__APPLE__)
#include <malloc.h> #include <malloc.h>
#endif #endif
#include <stdlib.h> #include <stdlib.h>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff