summaryrefslogtreecommitdiff
path: root/unicode/Makefile
blob: db7d5449302b518c009a42d6282e2905ee20980a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Ensure BUILDDIR is on the include path
CFLAGS := $(CFLAGS) -I$(BUILDDIR)/

$(BUILDDIR)/unicode:
	$(Q)$(MKDIR) $@

# Collect UnicodeLib headers
UHDRS := $(BUILDDIR)/VersionNum
define add_uhdr

$$(BUILDDIR)/unicode/$$(notdir $(1)).h: $(1) $$(BUILDDIR)/unicode
	$$(VQ)$$(ECHO) "    COPY: $$<"
	$$(Q)$$(CP) $$< $$@

UHDRS += $$(BUILDDIR)/unicode/$$(notdir $(1)).h

endef

$(eval $(foreach UHDR,$(wildcard unicode/UnicodeLib/h/*),$(call add_uhdr,$(UHDR))))

# Work out UnicodeLib sources to ignore
IGNORE_SRCS := debug mkunictype textconv
ifneq ($(findstring -riscos,$(HOST)),)
  IGNORE_SRCS := $(IGNORE_SRCS) unix
else
  IGNORE_SRCS := $(IGNORE_SRCS) riscos
endif

# Collect UnicodeLib sources
define add_usrc

$$(BUILDDIR)/unicode/$$(notdir $(1)).c: $(1) $$(UHDRS)
	$$(VQ)$$(ECHO) "    COPY: $$<"
	$$(Q)$$(CP) $$< $$@

SOURCES += $$(BUILDDIR)/unicode/$$(notdir $(1)).c

endef

$(eval $(foreach USRC,$(filter-out $(addprefix unicode/UnicodeLib/c/,$(IGNORE_SRCS)),$(wildcard unicode/UnicodeLib/c/*)),$(call add_usrc,$(USRC))))

$(BUILDDIR)/VersionNum: unicode/UnicodeLib/VersionNum $(BUILDDIR)/unicode
	$(VQ)$(ECHO) "    COPY: $<"
	$(Q)$(CP) $< $@

# Hand-crafted rules to ensure unictype.c gets built
$(BUILDDIR)/unicode_mkunictype.c: unicode/UnicodeLib/c/mkunictype
	$(VQ)$(ECHO) "    COPY: $<"
	$(Q)$(CP) $< $@

$(BUILDDIR)/mkunictype: $(BUILDDIR)/unicode_mkunictype.c
	$(VQ)$(ECHO) "BUILD.CC: $<"
	$(Q)$(BUILD_CC) -I$(BUILDDIR)/unicode -o $@ $<

$(BUILDDIR)/unicode/unictype.c: unicode/UnicodeLib/data/UnicodeData $(BUILDDIR)/mkunictype $(UHDRS)
	$(VQ)$(ECHO) "UNICTYPE: $<"
	$(Q)$(BUILDDIR)/mkunictype <$< >$@

SOURCES := $(SOURCES) $(BUILDDIR)/unicode/unictype.c

###############################################################################
## Unicode resource                                                          ##
###############################################################################

# Hand-crafted rules for makealiases
$(BUILDDIR)/unicode_makealiases.c: unicode/Unicode/c/makealiases
	$(VQ)$(ECHO) "    COPY: $<"
	$(Q)$(CP) $< $@

$(BUILDDIR)/makealiases: $(BUILDDIR)/unicode_makealiases.c
	$(VQ)$(ECHO) "BUILD.CC: $<"
	$(Q)$(BUILD_CC) -o $@ $<

# The dependencies *must* be in makealiases command line order
$(BUILDDIR)/Aliases: $(BUILDDIR)/makealiases unicode/Unicode/data/aliases-top unicode/Unicode/data/character-sets unicode/Unicode/data/aliases-bottom
	$(VQ)$(ECHO) " MKALIAS: compiling Aliases"
	$(Q)$^ $@

# This is basically an open-coded version of the upstream Makefile logic
# TODO: is there a more robust way?
$(BUILDDIR)/unires: $(BUILDDIR)/Aliases $(wildcard unicode/Unicode/*)
	$(Q)$(MKDIR) $@.tmp
	$(Q)$(CP) unicode/Unicode/Resources/UK/!Boot,feb $@.tmp/!Boot,feb
	$(Q)$(CP) unicode/Unicode/Resources/UK/!Help $@.tmp/!Help
	$(Q)$(CP) unicode/Unicode/Resources/UK/!Run,feb $@.tmp/!Run,feb
	$(Q)$(CP) -r unicode/Unicode/Resources/Encodings $@.tmp/Encodings
	$(Q)$(MKDIR) $@.tmp/Files
	$(Q)$(CP) unicode/Unicode/data/CharNames $@.tmp/Files/CharNames
	$(Q)$(CP) $(BUILDDIR)/Aliases $@.tmp/Files/Aliases
	$(Q)$(MKDIR) $@.tmp/Themes
	$(Q)$(CP) unicode/Unicode/Resources/UK/!Sprites,ff9 $@.tmp/Themes/!Sprites,ff9
	$(Q)$(CP) unicode/Unicode/Resources/UK/!Sprites11,ff9 $@.tmp/Themes/!Sprites11,ff9
	$(Q)$(CP) unicode/Unicode/Resources/UK/!Sprites22,ff9 $@.tmp/Themes/!Sprites22,ff9
	$(Q)$(CP) -r unicode/Unicode/Resources/UK/Morris4 $@.tmp/Themes/Morris4
	$(Q)$(CP) -r unicode/Unicode/Resources/UK/Ursula $@.tmp/Themes/Ursula
	$(Q)$(MV) $@.tmp $@