SRCS=		compat/setprogname.c
SRCS+=		regxml/regxml.c regxml/xml.c regxml/buffer.c
YSRCS=		regxml/pattern.y

OBJS=		$(SRCS:.c=.o) $(YSRCS:.y=.o)
LDADD=		-lexpat -lm

CFLAGS+=	-I.
CFLAGS+=	-D_GNU_SOURCE	# For asprintf().

YFLAGS+=	-pregxml_yy

all: xmlgrep/xmlgrep xmlsed/xmlsed

clean:
	rm -f xmlgrep/xmlgrep xmlgrep/xmlgrep.o
	rm -f xmlsed/xmlsed xmlsed/xmlsed.o
	rm -f $(OBJS)

.PHONY: all clean

xmlgrep/xmlgrep: xmlgrep/xmlgrep.o $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ xmlgrep/xmlgrep.o $(OBJS) $(LDADD)

xmlsed/xmlsed: xmlsed/xmlsed.o $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ xmlsed/xmlsed.o $(OBJS) $(LDADD)
