# 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

# Configuration flags
# - If your platform provides dlopen/dlsym/dlclose add -DHAS_DLFCN and replace
#    -lltdl with the appropriate libraries to CONFIGLIBS
CONFIGFLAGS=
CONFIGLIBS=-lltdl

# Installation prefix
prefix=/usr/local

all: src.util/linkltc/linkltc

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

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

OBJECTS_LINKLTC=src.util/linkltc/linkltc.o

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

dist-clean: clean

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

src.util/linkltc/linkltc: $(OBJECTS_LINKLTC) src/libtranscript.la
	$(SILENTLD) $(CC) $(CFLAGS) $(CONFIGFLAGS) $(LDFLAGS) -o $@ $(OBJECTS_LINKLTC) \
		$(LDLIBS) -Lsrc/.libs -ltranscript $(CONFIGLIBS)
