diff options
| author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-12-17 20:16:25 +0000 |
|---|---|---|
| committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-12-17 20:16:25 +0000 |
| commit | 1cd73b4dadb8e618a0ec56289408922be42aac8a (patch) | |
| tree | b437cb421d0ed2da6eca57ec4925a8b740aa00d1 /lang | |
| parent | 1fca479d8eb793bf6473226ff248cfe7b814a3e8 (diff) | |
Implemented CMake build system to replace the old autoconf-based build system.
(Note: Although each Makefile was changed, they will be removed later as CMake reconstructs them.)
Also fixed generation of language files and version.h to not rely on the current directory they are in.
Edited Config to send parameters to cmake, but it is no longer a requirement.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1835 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'lang')
| -rw-r--r-- | lang/CMakeLists.txt | 84 | ||||
| -rw-r--r-- | lang/Makefile | 304 | ||||
| -rw-r--r-- | lang/langcomp.c | 21 |
3 files changed, 318 insertions, 91 deletions
diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt new file mode 100644 index 000000000..e4d75bf0d --- /dev/null +++ b/lang/CMakeLists.txt @@ -0,0 +1,84 @@ +if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) + set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) +else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) + file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR}) +endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) + +#add_custom_command(OUTPUT ${BUILD_DIR}/langcomp +# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} langcomp.c -o ${BUILD_DIR}/langcomp +# MAIN_DEPENDENCY langcomp.c +#) +#add_custom_target(lang_langcomp DEPENDS ${BUILD_DIR}/langcomp) +set_source_files_properties(langcomp.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") +#add_executable(${BUILD_DIR}/langcomp langcomp.c) +add_executable(langcomp langcomp.c) +#set_target_properties(langcomp PROPERTIES COMPILE_FLAGS ${CXXFLAGS}) +#set_target_properties(${BUILD_DIR}/langcomp PROPERTIES LINKER_LANGUAGE CXX) + +#add_custom_command(OUTPUT ${BUILD_DIR}/index +# COMMAND ${GREP} '^[A-Z]' en_us.l > ${BUILD_DIR}/index +# MAIN_DEPENDENCY en_us.l +#) +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index + COMMAND ${GREP} '^[A-Z]' ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l > ${CMAKE_CURRENT_BINARY_DIR}/index + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l +) +#add_custom_target(lang_index DEPENDS ${BUILD_DIR}/index) + +#add_custom_target(language) + +set(LANG_SRCS cat.l de.l en_us.l es.l fr.l gr.l hun.l it.l nl.l pl.l pt.l ru.l tr.l) +list(SORT LANG_SRCS) + +foreach(LANG_L ${LANG_SRCS}) + STRING(REGEX REPLACE "\\.l$" "" LANG ${LANG_L}) + #set(LANGS ${LANGS} ${BUILD_DIR}/${LANG}) + set(LANGS ${LANGS} ${CMAKE_CURRENT_BINARY_DIR}/${LANG}) + #add_custom_command(OUTPUT ${BUILD_DIR}/${LANG} + # COMMAND langcomp ${LANG_L} + # MAIN_DEPENDENCY ${LANG_L} DEPENDS langcomp ${BUILD_DIR}/index + #) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG} + #CMMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/ + COMMAND langcomp ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/${LANG} + #COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/${LANG_L} + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} DEPENDS langcomp ${CMAKE_CURRENT_BINARY_DIR}/index + ) + #add_custom_target(lang_${LANG} ALL DEPENDS ${BUILD_DIR}/${LANG}) + #add_custom_target(lang_${LANG} DEPENDS ${BUILD_DIR}/${LANG}) + #add_dependencies(language lang_${LANG}) + #add_dependencies(language ${BUILD_DIR}/${LANG}) +endforeach(LANG_L) + +#add_custom_command(OUTPUT ${BUILD_DIR}/language.h +# COMMAND ${PERL} -e < ${BUILD_DIR}/index > ${BUILD_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;' +# COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/language.h ${Anope_SOURCE_DIR}/include/ +# MAIN_DEPENDENCY ${BUILD_DIR}/index +#) +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h + COMMAND ${PERL} -e < ${CMAKE_CURRENT_BINARY_DIR}/index > ${CMAKE_CURRENT_BINARY_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;' + #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/language.h ${Anope_SOURCE_DIR}/include/ + MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index +) +#add_custom_target(lang_language_h DEPENDS ${BUILD_DIR}/language.h) +#add_dependencies(language lang_language_h) +#add_dependencies(language ${BUILD_DIR}/language.h) +#add_custom_target(language DEPENDS ${LANGS} ${BUILD_DIR}/language.h) +add_custom_target(language DEPENDS ${LANGS} ${CMAKE_CURRENT_BINARY_DIR}/language.h) + +if(RUNGROUP) + set(PERMS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) +else(RUNGROUP) + set(PERMS OWNER_READ OWNER_WRITE) +endif(RUNGROUP) +install(FILES ${LANGS} + DESTINATION "${DATADIR}/languages" + PERMISSIONS ${PERMS} +) +if(RUNGROUP) + #install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}/languages\")") + install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/languages\")") +else(RUNGROUP) + install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"${DATADIR}/languages\")") +endif(RUNGROUP) diff --git a/lang/Makefile b/lang/Makefile index 2a012be32..baf5838e0 100644 --- a/lang/Makefile +++ b/lang/Makefile @@ -1,82 +1,224 @@ -# Makefile for language module - -MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ - 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \ - 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \ - 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \ - 'RUNGROUP=${RUNGROUP}' 'MAKEBIN=${MAKEBIN}' - -LANGOBJS = cat de en_us es fr gr hun it nl pl pt ru tr -LANGSRCS = cat.l de.l en_us.l es.l fr.l gr.l hun.l it.l nl.l pl.l pt.l ru.l tr.l - -LANGCOMP = ./langcomp -#LANGCOMP = ./langcomp -w - - -all: $(LANGOBJS) - -distclean: clean spotless - -install: all - test -d $(DATDEST)/languages || mkdir $(DATDEST)/languages - @if [ "$(RUNGROUP)" ] ; then \ - echo chgrp -R $(RUNGROUP) $(DATDEST)/languages ; \ - chgrp -R $(RUNGROUP) $(DATDEST)/languages ; \ - echo chmod -R g+rw $(DATDEST)/languages ; \ - chmod -R g+rw $(DATDEST)/languages ; \ - $(CP) $(LANGOBJS) $(DATDEST)/languages ; \ - echo chgrp -R $(RUNGROUP) $(DATDEST)/languages ; \ - chgrp -R $(RUNGROUP) $(DATDEST)/languages/* ; \ - echo chmod -R g+rw $(DATDEST)/languages/* ; \ - chmod -R g+rw $(DATDEST)/languages/* ; \ - fi - @if [ ! "$(RUNGROUP)" ] ; then \ - chmod 700 $(DATDEST)/languages/ ; \ - $(CP) $(LANGOBJS) $(DATDEST)/languages ; \ - chmod 600 $(DATDEST)/languages/* ; \ - fi - +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +# Default target executed when no arguments are given to make. +default_target: all +.PHONY : default_target + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/local/bin/cmake + +# The command to remove a file. +RM = /usr/local/bin/cmake -E remove -f + +# The program to use to edit the cache. +CMAKE_EDIT_COMMAND = /usr/local/bin/ccmake + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /celes/anope + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /celes/anope + +#============================================================================= +# Targets provided globally by CMake. + +# Special rule for the target edit_cache +edit_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." + cd /celes/anope/lang && /usr/local/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : edit_cache + +# Special rule for the target edit_cache +edit_cache/fast: edit_cache +.PHONY : edit_cache/fast + +# Special rule for the target install +install: preinstall + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." + cd /celes/anope/lang && /usr/local/bin/cmake -P cmake_install.cmake +.PHONY : install + +# Special rule for the target install +install/fast: preinstall/fast + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." + cd /celes/anope/lang && /usr/local/bin/cmake -P cmake_install.cmake +.PHONY : install/fast + +# Special rule for the target install/local +install/local: preinstall + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." + cd /celes/anope/lang && /usr/local/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake +.PHONY : install/local + +# Special rule for the target install/local +install/local/fast: install/local +.PHONY : install/local/fast + +# Special rule for the target install/strip +install/strip: preinstall + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." + cd /celes/anope/lang && /usr/local/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake +.PHONY : install/strip + +# Special rule for the target install/strip +install/strip/fast: install/strip +.PHONY : install/strip/fast + +# Special rule for the target list_install_components +list_install_components: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" +.PHONY : list_install_components + +# Special rule for the target list_install_components +list_install_components/fast: list_install_components +.PHONY : list_install_components/fast + +# Special rule for the target rebuild_cache +rebuild_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." + cd /celes/anope/lang && /usr/local/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : rebuild_cache + +# Special rule for the target rebuild_cache +rebuild_cache/fast: rebuild_cache +.PHONY : rebuild_cache/fast + +# The main all target +all: cmake_check_build_system + cd /celes/anope && $(CMAKE_COMMAND) -E cmake_progress_start /celes/anope/CMakeFiles /celes/anope/lang/CMakeFiles/progress.make + cd /celes/anope && $(MAKE) -f CMakeFiles/Makefile2 lang/all + $(CMAKE_COMMAND) -E cmake_progress_start /celes/anope/CMakeFiles 0 +.PHONY : all + +# The main clean target clean: - rm -f $(LANGOBJS) langcomp language.h - -spotless: clean - rm -f index - - -cat: cat.l langcomp index - @./langcomp $@.l -de: de.l langcomp index - @./langcomp $@.l -en_us: en_us.l langcomp index - @./langcomp $@.l -es: es.l langcomp index - @./langcomp $@.l -fr: fr.l langcomp index - @./langcomp $@.l -gr: gr.l langcomp index - @./langcomp $@.l -hun: hun.l langcomp index - @./langcomp $@.l -it: it.l langcomp index - @./langcomp $@.l -nl: nl.l langcomp index - @./langcomp $@.l -pl: pl.l langcomp index - @./langcomp $@.l -pt: pt.l langcomp index - @./langcomp $@.l -ru: ru.l langcomp index - @./langcomp $@.l -tr: tr.l langcomp index - @./langcomp $@.l - -langcomp: langcomp.c - @$(MAKEBIN) $(CC) $(CFLAGS) langcomp.c -o $@ - - -language.h: index Makefile - @perl -e <index >$@ 'print STDERR "Generating language.h... "; $$i=0; while (<>) { chop; printf "#define %-32s %d\n", $$_, $$i++; } print "\n#define NUM_STRINGS $$i\n"; print STDERR "$$i strings\n";' - @cp language.h ../include - -index: en_us.l - @grep '^[A-Z]' en_us.l >index + cd /celes/anope && $(MAKE) -f CMakeFiles/Makefile2 lang/clean +.PHONY : clean + +# The main clean target +clean/fast: clean +.PHONY : clean/fast + +# Prepare targets for installation. +preinstall: all + cd /celes/anope && $(MAKE) -f CMakeFiles/Makefile2 lang/preinstall +.PHONY : preinstall + +# Prepare targets for installation. +preinstall/fast: + cd /celes/anope && $(MAKE) -f CMakeFiles/Makefile2 lang/preinstall +.PHONY : preinstall/fast + +# clear depends +depend: + cd /celes/anope && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 +.PHONY : depend + +# Convenience name for target. +lang/CMakeFiles/langcomp.dir/rule: + cd /celes/anope && $(MAKE) -f CMakeFiles/Makefile2 lang/CMakeFiles/langcomp.dir/rule +.PHONY : lang/CMakeFiles/langcomp.dir/rule + +# Convenience name for target. +langcomp: lang/CMakeFiles/langcomp.dir/rule +.PHONY : langcomp + +# fast build rule for target. +langcomp/fast: + cd /celes/anope && $(MAKE) -f lang/CMakeFiles/langcomp.dir/build.make lang/CMakeFiles/langcomp.dir/build +.PHONY : langcomp/fast + +# Convenience name for target. +lang/CMakeFiles/language.dir/rule: + cd /celes/anope && $(MAKE) -f CMakeFiles/Makefile2 lang/CMakeFiles/language.dir/rule +.PHONY : lang/CMakeFiles/language.dir/rule + +# Convenience name for target. +language: lang/CMakeFiles/language.dir/rule +.PHONY : language + +# fast build rule for target. +language/fast: + cd /celes/anope && $(MAKE) -f lang/CMakeFiles/language.dir/build.make lang/CMakeFiles/language.dir/build +.PHONY : language/fast + +langcomp.o: langcomp.c.o +.PHONY : langcomp.o + +# target to build an object file +langcomp.c.o: + cd /celes/anope && $(MAKE) -f lang/CMakeFiles/langcomp.dir/build.make lang/CMakeFiles/langcomp.dir/langcomp.c.o +.PHONY : langcomp.c.o + +langcomp.i: langcomp.c.i +.PHONY : langcomp.i + +# target to preprocess a source file +langcomp.c.i: + cd /celes/anope && $(MAKE) -f lang/CMakeFiles/langcomp.dir/build.make lang/CMakeFiles/langcomp.dir/langcomp.c.i +.PHONY : langcomp.c.i + +langcomp.s: langcomp.c.s +.PHONY : langcomp.s + +# target to generate assembly for a file +langcomp.c.s: + cd /celes/anope && $(MAKE) -f lang/CMakeFiles/langcomp.dir/build.make lang/CMakeFiles/langcomp.dir/langcomp.c.s +.PHONY : langcomp.c.s + +# Help Target +help: + @echo "The following are some of the valid targets for this Makefile:" + @echo "... all (the default if no target is provided)" + @echo "... clean" + @echo "... depend" + @echo "... edit_cache" + @echo "... install" + @echo "... install/local" + @echo "... install/strip" + @echo "... langcomp" + @echo "... language" + @echo "... list_install_components" + @echo "... rebuild_cache" + @echo "... langcomp.o" + @echo "... langcomp.i" + @echo "... langcomp.s" +.PHONY : help + + + +#============================================================================= +# Special targets to cleanup operation of make. + +# Special rule to run CMake to check the build system integrity. +# No rule that depends on this can have commands that come from listfiles +# because they might be regenerated. +cmake_check_build_system: + cd /celes/anope && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 +.PHONY : cmake_check_build_system + diff --git a/lang/langcomp.c b/lang/langcomp.c index 5c5988394..773702ba7 100644 --- a/lang/langcomp.c +++ b/lang/langcomp.c @@ -7,7 +7,7 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * + * * $Id$ * */ @@ -165,8 +165,8 @@ char *anopeStrDup(const char *src) { /*************************************************************************/ int main(int ac, char **av) { - char *filename = NULL, *s; - char langname[254], outfile[256]; + char *filename = NULL, *s, *outfile; + //char langname[254], outfile[256]; FILE *in, *out; int warn = 0; int retval = 0; @@ -175,24 +175,25 @@ int main(int ac, char **av) int pos; int maxerr = 50; /* Max errors before we bail out */ - if (ac >= 2 && strcmp(av[1], "-w") == 0) { + if (ac >= 3 && strcmp(av[2], "-w") == 0) { warn = 1; - av[1] = av[2]; + av[2] = av[3]; ac--; } - if (ac != 2) { - fprintf(stderr, "Usage: %s [-w] <lang-file>\n", av[0]); + if (ac != 3) { + fprintf(stderr, "Usage: %s [-w] <lang-file> <out-file>\n", av[0]); return 1; } filename = av[1]; - s = strrchr(filename, '.'); + /*s = strrchr(filename, '.'); if (!s) s = filename + strlen(filename); if (s-filename > (int)sizeof(langname)-3) s = filename + sizeof(langname)-1; strncpy(langname, filename, s-filename); langname[s-filename] = '\0'; - snprintf(outfile, sizeof(outfile), "%s", langname); + snprintf(outfile, sizeof(outfile), "%s", langname);*/ + outfile = av[2]; if (read_index_file() < 0) return 1; @@ -243,7 +244,7 @@ int main(int ac, char **av) if (maxerr == 0) fprintf(stderr, "%s:%d: Too many errors!\n", filename, linenum); - + } } |
