From 0bb13ddf57c968db37a997851650d768641b3528 Mon Sep 17 00:00:00 2001 From: cyberbotx Date: Mon, 29 Dec 2008 09:32:05 +0000 Subject: Really fix the reverting back to r1870. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1874 5417fbe8-f217-4b02-8779-1006273d7864 --- src/CMakeLists.txt | 79 +++++++++++++++++++++++++++ src/bin/CMakeLists.txt | 2 +- src/bin/anoperc.cmake | 141 +++++++++++++++++++++++++++++++++++++++++++++++++ src/bin/anoperc.in | 141 ------------------------------------------------- 4 files changed, 221 insertions(+), 142 deletions(-) create mode 100644 src/CMakeLists.txt create mode 100644 src/bin/anoperc.cmake delete mode 100644 src/bin/anoperc.in (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..2a8c01d0e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,79 @@ +# Find all the *.c and *.cpp files within the current source directory, and sort the list +file(GLOB SRC_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") +file(GLOB SRC_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") +set(SRC_SRCS ${SRC_SRCS_C} ${SRC_SRCS_CPP}) +# If not using Visual Studio, don't include win32_memory.cpp, it's only required by Visual Studio to override it's override of the new/delete operators +if(NOT MSVC) + list(REMOVE_ITEM SRC_SRCS win32_memory.cpp) +endif(NOT MSVC) +if(CMAKE244_OR_BETTER) + list(SORT SRC_SRCS) +endif(CMAKE244_OR_BETTER) + +# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though) +set_source_files_properties(${SRC_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") + +# Iterate through all the source files +foreach(SRC ${SRC_SRCS}) + # Calculate the header file dependencies for the given source file + calculate_depends(${SRC}) +endforeach(SRC) + +# Under Windows, we also include a resource file to the build +if(WIN32) + # Make sure that the resource file is seen as an RC file to be compiled with a resource compiler, not a C++ compiler + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc LANGUAGE RC) + # Add the resource file to the list of sources + append_to_list(SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32.rc) + # For MinGW, we have to change the compile flags + if(MINGW) + set(RC_CFLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include") + # If any sort of debugging is being enabled, add a _DEBUG define to the flags for the resource compiler + if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") + set(RC_CFLAGS "${RC_CFLAGS} -D_DEBUG") + endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "${RC_CFLAGS}") + # For anything else, assumingly Visual Studio at this point, use a different set of compile flags + else(MINGW) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"") + endif(MINGW) + if(IN_SOURCE) + # Add the resource file to the list of files for CPack to ignore + add_to_cpack_ignored_files("win32.rc$" TRUE) + endif(IN_SOURCE) +endif(WIN32) + +# Generate the Anope executable and set it's linker flags, also set it to export it's symbols even though it's not a module +add_executable(${PROGRAM_NAME} ${SRC_SRCS}) +set_target_properties(${PROGRAM_NAME} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}" ENABLE_EXPORTS ON) +# On Windows, also link Anope to the wsock32 library, as well as set the version +if(WIN32) + target_link_libraries(${PROGRAM_NAME} wsock32) + set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}") +endif(WIN32) +# Building the Anope executable requires the language files to be compiled first as well as the version.h header to be generated +add_dependencies(${PROGRAM_NAME} language headers) + +# Get the filename of the Anope executable as it is in on this system +get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION) +get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME) +set(SERVICES_BIN "${SERVICES_BINARY}") +if(IN_SOURCE) + # Add the Anope executable to the list of files for CPack to ignore + add_to_cpack_ignored_files("${SERVICES_BINARY}$" TRUE) +endif(IN_SOURCE) + +# Generate sysconf.h from the earlier configuration +configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/include/sysconf.h) + +# Go into the following directories and run their CMakeLists.txt as well +add_subdirectory(bin) +add_subdirectory(core) +add_subdirectory(modules) +add_subdirectory(protocol) +add_subdirectory(tools) + +# Set Anope to be installed to the bin directory +install(TARGETS ${PROGRAM_NAME} + DESTINATION . +) diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt index e6aea4ec4..34044ddf9 100644 --- a/src/bin/CMakeLists.txt +++ b/src/bin/CMakeLists.txt @@ -1,6 +1,6 @@ # If not on Windows, generate anoperc and install it along with mydbgen if(NOT WIN32) - configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.in ${Anope_BINARY_DIR}/src/bin/anoperc) + configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_BINARY_DIR}/src/bin/anoperc) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc DESTINATION . ) diff --git a/src/bin/anoperc.cmake b/src/bin/anoperc.cmake new file mode 100644 index 000000000..02c5bf18e --- /dev/null +++ b/src/bin/anoperc.cmake @@ -0,0 +1,141 @@ +#!/bin/sh +# +# Configuration script for Services +# +# (C) 2003-2008 Anope Team +# Contact us at info@anope.org +# +# Please read COPYING and README for further details. +# +# Based on the original code of Epona by Lara. +# Based on the original code of Services by Andy Church. +# +# $Id$ +# + + + +ANOPEPID="@DATADIR@/services.pid" +ANOPROG="@BINDIR@/services" +LOG="@DATADIR@/logs/" +ARCVERSION="1.2" + +isAnopeRunning () { +if [ ! -f $ANOPEPID ] ; then + echo "Warning: Anope is not currently running" + exit 1 +fi + +PID=`cat $ANOPEPID` + +if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then + echo "Warning: Anope is not currently running" + exit 1 +fi +} + +if [ ! -f $ANOPROG ] ; then + echo "Error: $ANOPROG cannot be accessed" + exit 1 +fi + + +if [ "$UID" = "0" ] ; then + echo "######################################"; + echo "# Warning: Do NOT run Anope as root! #"; + echo "######################################"; + exit 1 +fi + +if [ "$1" = "start" ] ; then + +if [ -f $ANOPEPID ] ; then + PID=`cat $ANOPEPID` + if [ `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` = 1 ] ; then + echo "Warning! Anope is already running" + exit 1 + fi +fi + echo "Starting Anope" + shift + $ANOPROG $* + sleep 1 + if [ ! -f $ANOPEPID ] ; then + echo "Unfortunately it seems Anope did not start successfully" + echo "This error has been logged in your Anope Log file" + echo "Located in "$LOG"" + echo "This may help you diagnose the problem" + echo "Further help may be available from http://www.anope.org/" + exit 1 + fi + PID=`cat $ANOPEPID` + if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then + echo "Unfortunately it seems Anope did not start successfully" + echo "This error has been logged in your Anope Log file" + echo "Located in "$LOG"" + echo "This may help you diagnose the problem" + echo "Further help may be available from http://www.anope.org/" + exit 1 + fi + +elif [ "$1" = "stop" ] ; then + isAnopeRunning + echo "Terminating Anope" + kill -15 `cat $ANOPEPID` + +elif [ "$1" = "status" ] ; then + if [ -f $ANOPEPID ] ; then + PID=`cat $ANOPEPID` + if [ `ps auxw | grep $PID | grep -v -c grep` = 1 ] ; then + echo "Anope is currently running" + exit 1 + fi + fi + + echo "Anope is not currently running" + +## :/ SIGUSR2 is ignored after the first restart so we stop / start Anope for now ## +elif [ "$1" = "restart" ] ; then + isAnopeRunning + echo "Restarting Anope" + kill -15 `cat $ANOPEPID` + sleep 1 + shift + $ANOPROG $* + +elif [ "$1" = "rehash" ] ; then + isAnopeRunning + echo "Saving Databases and Rehashing Configuration" + kill -12 `cat $ANOPEPID` + +elif [ "$1" = "version" ] ; then + $ANOPROG -version + +elif [ "$1" = "help" ] ; then + if [ "$2" = "paramlist" ] ; then + $ANOPROG -help + else + echo "AnopeRC is a remote control script for easy" + echo "controlling of Anope from the command console" + echo "$0 start Start Anope" + echo " Additional parameters may be passed" + echo " (e.g. $0 start -nofork)" + echo " For a list type $0 $1 paramlist" + echo "$0 stop Shutdown Anope" + echo "$0 status Show Anope's Status" + echo "$0 restart Restart Anope (Databases will be saved)" + echo " Additional parameters may be passed" + echo " (e.g. $0 restart -logchan)" + echo " For a list type $0 $1 paramlist" + echo "$0 rehash Rehash Configuration and Save Databases" + echo "$0 version Return Anope Version and Build Information" + echo "$0 help Show this help menu" + echo "If you need further help please check the /docs/" + echo "folder or make use of our extensive online support at" + echo "http://www.anope.org/" + fi + +else + echo "Anope Remote Control ($ARCVERSION)" + echo "Usage: $0 [start|stop|status|restart|rehash|version|help]" +fi diff --git a/src/bin/anoperc.in b/src/bin/anoperc.in deleted file mode 100644 index 02c5bf18e..000000000 --- a/src/bin/anoperc.in +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -# -# Configuration script for Services -# -# (C) 2003-2008 Anope Team -# Contact us at info@anope.org -# -# Please read COPYING and README for further details. -# -# Based on the original code of Epona by Lara. -# Based on the original code of Services by Andy Church. -# -# $Id$ -# - - - -ANOPEPID="@DATADIR@/services.pid" -ANOPROG="@BINDIR@/services" -LOG="@DATADIR@/logs/" -ARCVERSION="1.2" - -isAnopeRunning () { -if [ ! -f $ANOPEPID ] ; then - echo "Warning: Anope is not currently running" - exit 1 -fi - -PID=`cat $ANOPEPID` - -if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then - echo "Warning: Anope is not currently running" - exit 1 -fi -} - -if [ ! -f $ANOPROG ] ; then - echo "Error: $ANOPROG cannot be accessed" - exit 1 -fi - - -if [ "$UID" = "0" ] ; then - echo "######################################"; - echo "# Warning: Do NOT run Anope as root! #"; - echo "######################################"; - exit 1 -fi - -if [ "$1" = "start" ] ; then - -if [ -f $ANOPEPID ] ; then - PID=`cat $ANOPEPID` - if [ `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` = 1 ] ; then - echo "Warning! Anope is already running" - exit 1 - fi -fi - echo "Starting Anope" - shift - $ANOPROG $* - sleep 1 - if [ ! -f $ANOPEPID ] ; then - echo "Unfortunately it seems Anope did not start successfully" - echo "This error has been logged in your Anope Log file" - echo "Located in "$LOG"" - echo "This may help you diagnose the problem" - echo "Further help may be available from http://www.anope.org/" - exit 1 - fi - PID=`cat $ANOPEPID` - if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then - echo "Unfortunately it seems Anope did not start successfully" - echo "This error has been logged in your Anope Log file" - echo "Located in "$LOG"" - echo "This may help you diagnose the problem" - echo "Further help may be available from http://www.anope.org/" - exit 1 - fi - -elif [ "$1" = "stop" ] ; then - isAnopeRunning - echo "Terminating Anope" - kill -15 `cat $ANOPEPID` - -elif [ "$1" = "status" ] ; then - if [ -f $ANOPEPID ] ; then - PID=`cat $ANOPEPID` - if [ `ps auxw | grep $PID | grep -v -c grep` = 1 ] ; then - echo "Anope is currently running" - exit 1 - fi - fi - - echo "Anope is not currently running" - -## :/ SIGUSR2 is ignored after the first restart so we stop / start Anope for now ## -elif [ "$1" = "restart" ] ; then - isAnopeRunning - echo "Restarting Anope" - kill -15 `cat $ANOPEPID` - sleep 1 - shift - $ANOPROG $* - -elif [ "$1" = "rehash" ] ; then - isAnopeRunning - echo "Saving Databases and Rehashing Configuration" - kill -12 `cat $ANOPEPID` - -elif [ "$1" = "version" ] ; then - $ANOPROG -version - -elif [ "$1" = "help" ] ; then - if [ "$2" = "paramlist" ] ; then - $ANOPROG -help - else - echo "AnopeRC is a remote control script for easy" - echo "controlling of Anope from the command console" - echo "$0 start Start Anope" - echo " Additional parameters may be passed" - echo " (e.g. $0 start -nofork)" - echo " For a list type $0 $1 paramlist" - echo "$0 stop Shutdown Anope" - echo "$0 status Show Anope's Status" - echo "$0 restart Restart Anope (Databases will be saved)" - echo " Additional parameters may be passed" - echo " (e.g. $0 restart -logchan)" - echo " For a list type $0 $1 paramlist" - echo "$0 rehash Rehash Configuration and Save Databases" - echo "$0 version Return Anope Version and Build Information" - echo "$0 help Show this help menu" - echo "If you need further help please check the /docs/" - echo "folder or make use of our extensive online support at" - echo "http://www.anope.org/" - fi - -else - echo "Anope Remote Control ($ARCVERSION)" - echo "Usage: $0 [start|stop|status|restart|rehash|version|help]" -fi -- cgit