| 1 |
# |
| 2 |
# Copyright (c) 2021, Hiroo Hayashi |
| 3 |
# |
| 4 |
# This source code is released for free distribution under the terms of the |
| 5 |
# GNU General Public License version 2 or (at your option) any later version. |
| 6 |
# |
| 7 |
# Makefile to generate ctags_vs2013.vcxproj and ctags_vs2013.vcxproj.filters |
| 8 |
# |
| 9 |
# usage: make [-B] |
| 10 |
# |
| 11 |
# Restrictions: |
| 12 |
# - Input Files: ctags_vs2013.vcxproj.in and ctags_vs2013.vcxproj.filters.in |
| 13 |
# - The last charactor of the files must be '>'. |
| 14 |
# cf. check_eof_chars_in_vcxproj() in misc/src-check. |
| 15 |
# - Other lines must be end with LF. |
| 16 |
# - GNU make is required. |
| 17 |
|
| 18 |
VCXPROJ = ctags_vs2013.vcxproj |
| 19 |
VCXPROJ_FILTERS = ctags_vs2013.vcxproj.filters |
| 20 |
SOURCE_MAK = ../source.mak |
| 21 |
|
| 22 |
all: $(VCXPROJ) $(VCXPROJ_FILTERS) |
| 23 |
|
| 24 |
include $(SOURCE_MAK) |
| 25 |
|
| 26 |
# exclude some files for Win32 and replace a slash (/) to a backslash (\) |
| 27 |
MVC_SRCS = $(MVC_GNULIB_SRCS) $(CMDLINE_SRCS) $(LIB_SRCS) $(OPTLIB2C_SRCS) $(PARSER_SRCS) $(OPTSCRIPT_DSL_SRCS) $(DEBUG_SRCS) $(WIN32_SRCS) |
| 28 |
MVC_SRCS_EXCLUDE = main/mbcs.c main/seccomp.c main/trace.c |
| 29 |
MVC_SRCS_CONV = $(sort $(subst /,\\,$(filter-out $(MVC_SRCS_EXCLUDE),$(MVC_SRCS)))) |
| 30 |
|
| 31 |
MVC_HEADS = $(MVC_GNULIB_HEADS) $(CMDLINE_HEADS) $(LIB_HEADS) $(OPTLIB2C_HEADS) $(PARSER_HEADS) $(OPTSCRIPT_DSL_HEADS) $(DEBUG_HEADS) $(WIN32_HEADS) |
| 32 |
MVC_HEADS_EXCLUDE = main/interactive_p.h main/mbcs.h main/mbcs_p.h main/trace.h |
| 33 |
MVC_HEADS_CONV = $(sort $(subst /,\\,$(filter-out $(MVC_HEADS_EXCLUDE),$(MVC_HEADS)))) |
| 34 |
|
| 35 |
MVC_INC_DIRS1 = ..;../main;../gnulib;../parsers;../parsers/cxx;../dsl; |
| 36 |
MVC_INC_DIRS2 = ..;../main;../gnulib;../parsers;../parsers/cxx; |
| 37 |
|
| 38 |
# a portable 'echo' which disables the interpretation of escape characters like 'echo -E' on bash |
| 39 |
# see https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/autoconf.html#Limitations-of-Builtins |
| 40 |
ECHO = printf '%s\n' |
| 41 |
# escape backslashes and newlines in the replacement pattern for sed |
| 42 |
ESCAPE_BACKSLASH = sed -e 's|\\|\\\\|g' -e 's/$$/\\/' | sed -e '$$s/\\$$//' |
| 43 |
# insert CR before LF except for the last line |
| 44 |
LF2CRLF = sed -e '$$!s/$$/\r/' |
| 45 |
|
| 46 |
$(VCXPROJ): $(VCXPROJ).in $(SOURCE_MAK) |
| 47 |
@echo generating $@ ... |
| 48 |
@# C source files \ |
| 49 |
SRCS=$$(for i in $(MVC_SRCS_CONV); do \ |
| 50 |
$(ECHO) " <ClCompile Include=\"..\\$$i\" />"; \ |
| 51 |
done); \ |
| 52 |
SRCS=$$($(ECHO) "$$SRCS" | $(ESCAPE_BACKSLASH)); \ |
| 53 |
# header files \ |
| 54 |
HEADS=$$(for i in $(MVC_HEADS_CONV); do \ |
| 55 |
$(ECHO) " <ClInclude Include=\"..\\$$i\" />"; \ |
| 56 |
done; \ |
| 57 |
$(ECHO) " <ClInclude Include=\"resource.h\" />"); \ |
| 58 |
HEADS=$$($(ECHO) "$$HEADS" | $(ESCAPE_BACKSLASH)); \ |
| 59 |
# replace @foo@ in $(VCXPROJ).in \ |
| 60 |
sed -e "s![@]SRCS[@]!$$SRCS!" \ |
| 61 |
-e "s![@]HEADS[@]!$$HEADS!" \ |
| 62 |
-e "s|[@]INC_DIRS1[@]|${MVC_INC_DIRS1}|" \ |
| 63 |
-e "s|[@]INC_DIRS2[@]|${MVC_INC_DIRS2}|" $< | $(LF2CRLF) > $@ |
| 64 |
|
| 65 |
$(VCXPROJ_FILTERS): $(VCXPROJ_FILTERS).in $(SOURCE_MAK) |
| 66 |
@echo generating $@ ... |
| 67 |
@# C source files \ |
| 68 |
SRCS=$$(for i in $(MVC_SRCS_CONV); do \ |
| 69 |
dirname=$$($(ECHO) $$i | sed -e 's/\\[a-zA-Z_0-9.-]*$$//'); \ |
| 70 |
$(ECHO) " <ClCompile Include=\"..\\$$i\">"; \ |
| 71 |
$(ECHO) " <Filter>Source Files\\$$dirname</Filter>"; \ |
| 72 |
$(ECHO) " </ClCompile>"; \ |
| 73 |
done); \ |
| 74 |
SRCS=$$($(ECHO) "$$SRCS" | $(ESCAPE_BACKSLASH)); \ |
| 75 |
# header files \ |
| 76 |
HEADS=$$(for i in $(MVC_HEADS_CONV); do \ |
| 77 |
$(ECHO) " <ClInclude Include=\"..\\$$i\">"; \ |
| 78 |
$(ECHO) " <Filter>Header Files</Filter>"; \ |
| 79 |
$(ECHO) " </ClInclude>"; \ |
| 80 |
done; \ |
| 81 |
$(ECHO) " <ClInclude Include=\"resource.h\">"; \ |
| 82 |
$(ECHO) " <Filter>Header Files</Filter>"; \ |
| 83 |
$(ECHO) " </ClInclude>"); \ |
| 84 |
HEADS=$$($(ECHO) "$$HEADS" | $(ESCAPE_BACKSLASH)); \ |
| 85 |
# replace @foo@ in $(VCXPROJ_FILTERS).in \ |
| 86 |
sed -e "s![@]SRCS[@]!$$SRCS!" \ |
| 87 |
-e "s![@]HEADS[@]!$$HEADS!" $< | $(LF2CRLF) > $@ |