# Copyright (C) 2011,2013 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
.POSIX:

# C-compiler flags
CFLAGS=-O2

# C++-compiler flags
CXXFLAGS=-O2

# Config flags
# - If strdup is not provided by the library, remove -DHAS_STRDUP.
# - If your platform does not support the nl_langinfo function, remove
#    -DHAS_NL_LANGINFO
CONFIGFLAGS=-DHAS_STRDUP -DHAS_NL_LANGINFO

all: src.util/ucm2ltc/ucm2ltc

.PHONY: all clean dist-clean
.SUFFIXES: .c .cc .o
.SECONDARY: # Tell GNU make not to delete intermediate files

SILENTCC=@echo '[CC]' $< ;
SILENTCXX=@echo '[CXX]' $< ;
SILENTLD=@echo '[LD]' $@ ;

OBJECTS_UCM2LTC=src.util/ucm2ltc/ucm2ltc.o src.util/ucm2ltc/ucmparser.o src.util/ucm2ltc/variant.o src.util/ucm2ltc/ucm_analyse.o src.util/ucm2ltc/minimize_state_machine.o src.util/ucm2ltc/ucm_write_simple.o src.util/ucm2ltc/ucm.o src.util/ucm2ltc/ucmlexer.o src.util/ucm2ltc/ucm_write_tables.o

clean:
	rm -rf src.util/ucm2ltc/*.o src.util/ucm2ltc/ucm2ltc

dist-clean: clean

.c.o:
	$(SILENTCC) $(CC) $(CFLAGS) $(CONFIGFLAGS) -Isrc -c -o $@ $<

.cc.o:
	$(SILENTCXX) $(CXX) $(CXXFLAGS) $(CONFIGFLAGS) -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -Isrc -c -o $@ $<

src.util/ucm2ltc/ucm2ltc: $(OBJECTS_UCM2LTC) src/libtranscript.la
	$(SILENTLD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJECTS_UCM2LTC) $(LDLIBS) -Lsrc/.libs -ltranscript

