1# Copyright (C) 2016 and later: Unicode, Inc. and others.
2# License & terms of use: http://www.unicode.org/copyright.html#License
3#
4# Copyright (c) 2000-2005 IBM, Inc. and others
5# conversion sample code
6# Usage:
7#  - configure, build, install ICU
8#  - ensure that 'icu-config' is in the PATH (PREFIX/bin/icu-config) 
9#  - if ICU is not built relative to this directory,
10#      set the variable ICU_PATH to the 'icu' directory
11#       (i.e.  /foo/icu  )
12#  - do 'make' in this directory
13
14include ../defs.mk
15
16ICU_DEFAULT_PATH=../../..
17
18ifeq ($(strip $(ICU_PATH)),)
19  ICU_PATH=$(ICU_DEFAULT_PATH)
20endif
21
22GENRBOPT = -s. -d.
23
24# Name of your target
25TARGET=uresb
26PKG=$(TARGET)
27RES_SRC=root.txt en.txt sr.txt
28RESOURCES=$(RES_SRC:%.txt=%.res)
29
30# All object files (C or C++)
31OBJECTS=uresb.o
32
33CLEANFILES=*~ $(TARGET).out
34
35all: $(RESOURCES) $(TARGET) 
36
37uresb.o:  $(ICU_PATH)/source/tools/toolutil/uoptions.h
38
39$(ICU_PATH)/source/tools/toolutil/uoptions.h:
40	@echo "Please read the directions at the top of this file (Makefile)"
41	@echo "Can't open $@ - check ICU_PATH"
42	@false
43
44CPPFLAGS += -I$(ICU_PATH)/source/tools/toolutil
45LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil $(shell icu-config --ldflags-toolutil --ldflags-icuio)
46
47.PHONY: all clean distclean check report
48
49distclean clean:
50	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
51	-$(RMV) $(OBJECTS) $(TARGET) $(RESOURCES)
52
53
54## resources
55%.res: %.txt
56	@echo "generating $@"
57	$(GENRB) $(GENRBOPT) $^
58
59## Special for a special codepage
60sr.res : sr.txt
61	@echo "generating $@"
62	$(GENRB) $(GENRBOPT) -e cp1251 $?
63
64# Can change this to LINK.c if it is a C only program
65# Can add more libraries here. 
66$(TARGET): $(OBJECTS)
67	$(CC) -o $@ $^ $(LDFLAGS)
68
69# Make check: simply runs the sample, logged to a file
70check: $(TARGET) $(RESOURCES)
71	$(INVOKE) ./$(TARGET) en | tee $(TARGET).out
72
73# Make report: creates a 'report file' with both source and sample run
74report: $(TARGET).report
75
76$(TARGET).report: check $(TARGET).cpp
77	more $(TARGET).cpp $(TARGET).out > $@
78
79
80
81