top_builddir = ../../..
top_srcdir = @top_srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@

BINDIR = $(DESTDIR)$(bindir)

MANDIR = $(DESTDIR)$(mandir)
MAN1DIR = $(MANDIR)/man1

VPATH = $(top_srcdir)/contrib/tool/mlcc

CC = @CC@
PROG = mlcc
CFLAGS = @CFLAGS@ @CPPFLAGS@
INSTALL = @INSTALL@

OBJECTS = data.o main.o comm.o \
 data_entry_string.o data_entry_bool.o data_entry_numeric.o \
 data_entry_color.o data_entry_radio.o

all: $(PROG)

$(PROG): $(OBJECTS)
	$(CC) -o $(PROG) $(OBJECTS) @LDFLAGS@

.SUFFIXES: .c.o

comm.o: comm.h
data.o: comm.h data.h
main.o: comm.h data.h

.c.o:
	$(CC) $(CFLAGS) -c $<

clean:
	rm -f $(OBJECTS) $(PROG) core core.* $(PROG).core 

$(BINDIR):
	mkdir -p $(BINDIR)

$(MAN1DIR):
	mkdir -p $(MAN1DIR)

install: $(BINDIR) $(MAN1DIR)
	$(INSTALL) -m 755 $(PROG) $(BINDIR)
	$(INSTALL) -m 644 $(top_srcdir)/contrib/tool/mlcc/mlcc.1 $(MAN1DIR)

uninstall:
	rm -f $(BINDIR)/$(PROG)
	rm -f $(MAN1DIR)/mlcc.1

mostlyclean:
	rm -f $(OBJECTS) core core.* $(PROG).core 

distclean: clean
	rm -f Makefile
