@@ -66,7 +66,7 @@ project(git
66
66
LANGUAGES C )
67
67
68
68
69
- #macros for parsing the Makefile for sources
69
+ #macros for parsing the Makefile for sources and scripts
70
70
macro (parse_makefile_for_sources list_var regex )
71
71
file (STRINGS ${CMAKE_SOURCE_DIR} /Makefile ${list_var} REGEX "^${regex} \\ +=(.*)" )
72
72
string (REPLACE "${regex} +=" "" ${list_var} ${${list_var}} )
@@ -77,6 +77,16 @@ macro(parse_makefile_for_sources list_var regex)
77
77
list (REMOVE_ITEM ${list_var} "" ) #remove empty list elements
78
78
endmacro ()
79
79
80
+ macro (parse_makefile_for_scripts list_var regex lang )
81
+ file (STRINGS ${CMAKE_SOURCE_DIR} /Makefile ${list_var} REGEX "^${regex} \\ +=(.*)" )
82
+ string (REPLACE "${regex} +=" "" ${list_var} ${${list_var}} )
83
+ string (STRIP ${${list_var}} ${list_var} ) #remove trailing/leading whitespaces
84
+ string (REPLACE " " ";" ${list_var} ${${list_var}} ) #convert string to a list
85
+ if (NOT ${lang} ) #exclude for SCRIPT_LIB
86
+ list (TRANSFORM ${list_var} REPLACE "${lang} " "" ) #do the replacement
87
+ endif ()
88
+ endmacro ()
89
+
80
90
include (CheckTypeSize )
81
91
include (CheckCSourceRuns )
82
92
include (CheckCSourceCompiles )
@@ -112,6 +122,11 @@ if(Intl_FOUND)
112
122
include_directories (SYSTEM ${Intl_INCLUDE_DIRS} )
113
123
endif ()
114
124
125
+ find_program (MSGFMT_EXE msgfmt )
126
+ if (NOT MSGFMT_EXE )
127
+ message (WARNING "Text Translations won't be build" )
128
+ endif ()
129
+
115
130
#default behaviour
116
131
include_directories (${CMAKE_SOURCE_DIR} )
117
132
add_compile_definitions (GIT_HOST_CPU= "${CMAKE_SYSTEM_PROCESSOR} " )
@@ -590,3 +605,97 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}
590
605
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR} /CreateLinks.cmake
591
606
DEPENDS git git-remote-http )
592
607
add_custom_target (git-links ALL DEPENDS ${git_links} ${git_http_links} )
608
+
609
+
610
+ #creating required scripts
611
+ set (SHELL_PATH /bin/sh )
612
+ set (PERL_PATH /usr/bin/perl )
613
+ set (LOCALEDIR ${FALLBACK_RUNTIME_PREFIX} /share/locale )
614
+ set (GITWEBDIR ${FALLBACK_RUNTIME_PREFIX} /share/locale )
615
+ set (INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX} /share/perl5 )
616
+
617
+ #shell scripts
618
+ parse_makefile_for_scripts (git_sh_scripts "SCRIPT_SH" ".sh" )
619
+ parse_makefile_for_scripts (git_shlib_scripts "SCRIPT_LIB" "" )
620
+ set (git_shell_scripts
621
+ ${git_sh_scripts} ${git_shlib_scripts} git-instaweb )
622
+
623
+ foreach (script ${git_shell_scripts} )
624
+ file (STRINGS ${CMAKE_SOURCE_DIR} /${script}.sh content NEWLINE_CONSUME )
625
+ string (REPLACE "@SHELL_PATH@" "${SHELL_PATH} " content "${content} " )
626
+ string (REPLACE "@@DIFF@@" "diff" content "${content} " )
627
+ string (REPLACE "@LOCALEDIR@" "${LOCALEDIR} " content "${content} " )
628
+ string (REPLACE "@GITWEBDIR@" "${GITWEBDIR} " content "${content} " )
629
+ string (REPLACE "@@NO_CURL@@" "" content "${content} " )
630
+ string (REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content} " )
631
+ string (REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content} " )
632
+ string (REPLACE "@@PERL@@" "${PERL_PATH} " content "${content} " )
633
+ string (REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content} " )
634
+ string (REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content} " )
635
+ file (WRITE ${CMAKE_BINARY_DIR} /${script} ${content} )
636
+ endforeach ()
637
+
638
+ #perl scripts
639
+ parse_makefile_for_scripts (git_perl_scripts "SCRIPT_PERL" ".perl" )
640
+
641
+ #create perl header
642
+ file (STRINGS ${CMAKE_SOURCE_DIR} /perl/header_templates/fixed_prefix.template.pl perl_header )
643
+ string (REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header} " )
644
+ string (REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR} " perl_header "${perl_header} " )
645
+
646
+ foreach (script ${git_perl_scripts} )
647
+ file (STRINGS ${CMAKE_SOURCE_DIR} /${script}.perl content NEWLINE_CONSUME )
648
+ string (REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n ${perl_header} \n " content "${content} " )
649
+ string (REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION} " content "${content} " )
650
+ file (WRITE ${CMAKE_BINARY_DIR} /${script} ${content} )
651
+ endforeach ()
652
+
653
+ #python script
654
+ file (STRINGS ${CMAKE_SOURCE_DIR} /git-p4.py content NEWLINE_CONSUME )
655
+ string (REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content} " )
656
+ file (WRITE ${CMAKE_BINARY_DIR} /git-p4 ${content} )
657
+
658
+ #perl modules
659
+ file (GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR} /perl/*.pm" )
660
+
661
+ foreach (pm ${perl_modules} )
662
+ string (REPLACE "${CMAKE_SOURCE_DIR} /perl/" "" file_path ${pm} )
663
+ file (STRINGS ${pm} content NEWLINE_CONSUME )
664
+ string (REPLACE "@@LOCALEDIR@@" "${LOCALEDIR} " content "${content} " )
665
+ string (REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content} " )
666
+ file (WRITE ${CMAKE_BINARY_DIR} /perl/build/lib/${file_path} ${content} )
667
+ #test-lib.sh requires perl/build/lib to be the build directory of perl modules
668
+ endforeach ()
669
+
670
+
671
+ #templates
672
+ file (GLOB templates "${CMAKE_SOURCE_DIR} /templates/*" )
673
+ list (TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR} /templates/" "" )
674
+ list (REMOVE_ITEM templates ".gitignore" )
675
+ list (REMOVE_ITEM templates "Makefile" )
676
+ list (REMOVE_ITEM templates "blt" )# Prevents an error when reconfiguring for in source builds
677
+
678
+ list (REMOVE_ITEM templates "branches--" )
679
+ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR} /templates/blt/branches ) #create branches
680
+
681
+ #templates have @.*@ replacement so use configure_file instead
682
+ foreach (tm ${templates} )
683
+ string (REPLACE "--" "/" blt_tm ${tm} )
684
+ string (REPLACE "this" "" blt_tm ${blt_tm} )# for this--
685
+ configure_file (${CMAKE_SOURCE_DIR} /templates/${tm} ${CMAKE_BINARY_DIR} /templates/blt/${blt_tm} @ONLY )
686
+ endforeach ()
687
+
688
+
689
+ #translations
690
+ if (MSGFMT_EXE )
691
+ file (GLOB po_files "${CMAKE_SOURCE_DIR} /po/*.po" )
692
+ list (TRANSFORM po_files REPLACE "${CMAKE_SOURCE_DIR} /po/" "" )
693
+ list (TRANSFORM po_files REPLACE ".po" "" )
694
+ foreach (po ${po_files} )
695
+ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR} /po/build/locale/${po}/LC_MESSAGES )
696
+ add_custom_command (OUTPUT ${CMAKE_BINARY_DIR} /po/build/locale/${po}/LC_MESSAGES/git.mo
697
+ COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR} /po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR} /po/${po}.po )
698
+ list (APPEND po_gen ${CMAKE_BINARY_DIR} /po/build/locale/${po}/LC_MESSAGES/git.mo )
699
+ endforeach ()
700
+ add_custom_target (po-gen ALL DEPENDS ${po_gen} )
701
+ endif ()
0 commit comments