PACKAGE	= UWfirmforce
VERSION	= 0.1.0
SUBDIRS	= plugins
TARGETS	= UWfirmforce
PREFIX	= /usr/local
DESTDIR	= 
BINDIR	= $(PREFIX)/bin
CC	= cc
CPPFLAGSF=
CPPFLAGS=
CFLAGSF	= -W
CFLAGS	= -Wall -g -O2
LDFLAGS	= 
RM	= rm -f
LN	= ln -f
TAR	= tar -czvf
MKDIR	= mkdir -p
INSTALL	= install


all: subdirs $(TARGETS)

subdirs:
	@for i in $(SUBDIRS); do (cd $$i && $(MAKE)) || exit; done

UWfirmforce_OBJS = UWfirmforce.o plugin.o
UWfirmforce_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
UWfirmforce_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)

UWfirmforce: $(UWfirmforce_OBJS)
	$(CC) -o UWfirmforce $(UWfirmforce_OBJS) $(UWfirmforce_LDFLAGS)

UWfirmforce.o: UWfirmforce.c plugins/plugin.h UWfirmforce.h config.h
	$(CC) $(UWfirmforce_CFLAGS) -c UWfirmforce.c

plugin.o: plugin.c UWfirmforce.h plugins/plugin.h
	$(CC) $(UWfirmforce_CFLAGS) -c plugin.c

clean:
	@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done
	$(RM) -- $(UWfirmforce_OBJS)

distclean:
	@for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done
	$(RM) -- $(UWfirmforce_OBJS)
	$(RM) -- $(TARGETS)

dist:
	$(RM) -r -- $(PACKAGE)-$(VERSION)
	$(LN) -s -- . $(PACKAGE)-$(VERSION)
	@$(TAR) $(PACKAGE)-$(VERSION).tar.gz -- \
		$(PACKAGE)-$(VERSION)/plugins/adma.c \
		$(PACKAGE)-$(VERSION)/plugins/android.c \
		$(PACKAGE)-$(VERSION)/plugins/ar.c \
		$(PACKAGE)-$(VERSION)/plugins/ace.c \
		$(PACKAGE)-$(VERSION)/plugins/bflt.c \
		$(PACKAGE)-$(VERSION)/plugins/brcm.c \
		$(PACKAGE)-$(VERSION)/plugins/bzip2.c \
		$(PACKAGE)-$(VERSION)/plugins/cab.c \
		$(PACKAGE)-$(VERSION)/plugins/cpio.c \
		$(PACKAGE)-$(VERSION)/plugins/cramfs.c \
		$(PACKAGE)-$(VERSION)/plugins/dex.c \
		$(PACKAGE)-$(VERSION)/plugins/dump.c \
		$(PACKAGE)-$(VERSION)/plugins/elf.c \
		$(PACKAGE)-$(VERSION)/plugins/ext2fs.c \
		$(PACKAGE)-$(VERSION)/plugins/fat.c \
		$(PACKAGE)-$(VERSION)/plugins/gzip.c \
		$(PACKAGE)-$(VERSION)/plugins/iso9660.c \
		$(PACKAGE)-$(VERSION)/plugins/java.c \
		$(PACKAGE)-$(VERSION)/plugins/lzma.c \
		$(PACKAGE)-$(VERSION)/plugins/pe.c \
		$(PACKAGE)-$(VERSION)/plugins/romfs.c \
		$(PACKAGE)-$(VERSION)/plugins/squashfs.c \
		$(PACKAGE)-$(VERSION)/plugins/tar.c \
		$(PACKAGE)-$(VERSION)/plugins/trx.c \
		$(PACKAGE)-$(VERSION)/plugins/ttf.c \
		$(PACKAGE)-$(VERSION)/plugins/uboot.c \
		$(PACKAGE)-$(VERSION)/plugins/w700v.c \
		$(PACKAGE)-$(VERSION)/plugins/x509.c \
		$(PACKAGE)-$(VERSION)/plugins/zip.c \
		$(PACKAGE)-$(VERSION)/plugins/Makefile \
		$(PACKAGE)-$(VERSION)/plugins/plugin.h \
		$(PACKAGE)-$(VERSION)/plugins/project.conf \
		$(PACKAGE)-$(VERSION)/UWfirmforce.c \
		$(PACKAGE)-$(VERSION)/plugin.c \
		$(PACKAGE)-$(VERSION)/Makefile \
		$(PACKAGE)-$(VERSION)/GNUmakefile \
		$(PACKAGE)-$(VERSION)/COPYING \
		$(PACKAGE)-$(VERSION)/README \
		$(PACKAGE)-$(VERSION)/ChangeLog \
		$(PACKAGE)-$(VERSION)/UWfirmforce.h \
		$(PACKAGE)-$(VERSION)/config.h \
		$(PACKAGE)-$(VERSION)/project.conf
	$(RM) -- $(PACKAGE)-$(VERSION)

install: $(TARGETS)
	@for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done
	$(MKDIR) $(DESTDIR)$(BINDIR)
	$(INSTALL) -m 0755 -- UWfirmforce $(DESTDIR)$(BINDIR)/UWfirmforce

uninstall:
	@for i in $(SUBDIRS); do (cd $$i && $(MAKE) uninstall) || exit; done
	$(RM) -- $(DESTDIR)$(BINDIR)/UWfirmforce

.PHONY: all subdirs clean distclean dist install uninstall