
/*
 * XMakefile for xmake
 */

.set OD		obj
.set SRCS	include.c list.c main.c subs.c var.c wild.c
.set OBJS	$(SRCS:"*.c":"$(OD)/*.o")
.set PROTOS	xmake-protos.h
.set CFLAGS	-g -O
.set LFLAGS
.set XMKPROTO	xmkproto
.set IBIN	/usr/local/bin
.set MBIN	/usr/local/man/man1

.set DIST	/home/httpd/htdocs/xmake
.set VERS	1.04

#if __GNUC__
.set CFLAGS	-g -O2 -Wall -Wstrict-prototypes
#endif
.set CFLAGS	$(CFLAGS) $(EXTDEFS)

all: $(PROTOS) $(OD)/$(XMKPROTO) $(OD)/xmake

fall: clean all

$(OD)/xmake: $(OBJS)
    cc $(CFLAGS) %(right) $(LFLAGS) -o %(left)

$(OBJS):: $(PROTOS)

$(OBJS):: defs.h

$(OBJS): $(SRCS)
    cc $(CFLAGS) %(right) -o %(left) -c

/*
 * This is a cute hack to avoid running xmkproto
 * on every invocation.
 */

$(PROTOS): $(OD)/$(XMKPROTO) $(OD)/.protook
    @touch $(OD)/.protook

$(OD)/.protook : $(SRCS)
    $(OD)/$(XMKPROTO) -o $(PROTOS) %(right:"*.c")

$(OD)/$(XMKPROTO): $(XMKPROTO).c
    cc $(CFLAGS) %(right) -o %(left)


clean:
    rm -f $(OBJS) $(OD)/xmake $(OD)/$(XMKPROTO) core *.core

i: install

install: all $(IBIN)/xmake $(IBIN)/$(XMKPROTO) $(MBIN)/xmake.1

$(IBIN)/xmake $(IBIN)/$(XMKPROTO) : $(OD)/xmake $(OD)/$(XMKPROTO)
    install -c -s -m 755 %(right) %(left)

$(MBIN)/xmake.1 : xmake.1
    install -c -m 644 %(right) %(left)

dist: clean
    (cd ..; tar czf $(DIST)/xmake.tgz.new xmake)
    chown dillon.dillon $(DIST)/xmake.tgz.new
    chmod 644 $(DIST)/xmake.tgz.new
    mv -f $(DIST)/xmake.tgz.new $(DIST)/xmake-$(VERS).tgz
    
