# aewm - An Exiguous Window Manager - vim:ft=make:noet
# Copyright 1998-2006 Decklin Foster <decklin@red-bean.com>
# This program is free software; see LICENSE for details.

# Set this to the location of your X11 installation.
XROOT = /usr/X11R6

# Uncomment this to add Xft support (requires X.Org or XFree86 >= 4.0.2).
#DEFINES += -DXFT
#EXTRA_INC += `pkg-config --cflags xft`
#EXTRA_LIBS += `pkg-config --libs xft` -lXext

# Uncomment this to add Shape extension support (X11R6 or better required).
#DEFINES += -DSHAPE
#EXTRA_LIBS += -lXext

# Uncomment for debugging info (abandon all hope, ye who enter here).
#DEFINES += -DDEBUG
#EXTRA_LIBS += -lefence

# --------------------------------------------------------------------

CC       = gcc
CFLAGS   = -g -O2 -Wall

MYLIBDIR = lib
BINDIR   = $(DESTDIR)$(XROOT)/bin
MANDIR   = $(DESTDIR)$(XROOT)/man/man1
CFGDIR   = $(DESTDIR)/etc/X11/aewm
INCLUDES = -I$(MYLIBDIR) -I$(XROOT)/include $(EXTRA_INC)
LDPATH   = -L$(XROOT)/lib
LIBS     = -lX11 $(EXTRA_LIBS)

PROG     = aewm
MANPAGE  = aewm.1x
OBJS     = init.o event.o win.o map.o ops.o misc.o $(MYLIBDIR)/common.o $(MYLIBDIR)/parser.o $(MYLIBDIR)/atom.o
HEADERS  = aewm.h

all: $(PROG)
	$(MAKE) -C clients

$(PROG): $(OBJS)
	$(CC) $(OBJS) $(LDPATH) $(LIBS) -o $@

$(OBJS): %.o: %.c $(HEADERS)
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

install: all
	install -s $(PROG) $(BINDIR)
	install -m 644 $(MANPAGE) $(MANDIR)
	gzip -9vf $(MANDIR)/$(MANPAGE)
	mkdir -p $(CFGDIR) && cp aewmrc.ex $(CFGDIR)/aewmrc
	$(MAKE) -C clients $@

clean:
	rm -f $(PROG) $(OBJS)
	$(MAKE) -C clients $@

.PHONY: all install clean
