# makefile for palwiz
# this should work with GNU make, gcc, and bash shell

# version number
NAME = palwiz
VERSION = 1.3

# get current date and time
DATE = $(shell date "+%Y%m%d")
ZIPDATE = $(shell date "+%Y-%m-%d")

# C compiler target architecture
#   this is the setting for OS X to create a universal PPC/Intel binary
#   comment it out if you aren't running OS X for Intel
#TARGET_ARCH = -arch ppc -arch i686

# C compiler flags
CFLAGS = -Wall -Werror -std=gnu99 -O2 -DVERSION=\"$(VERSION)\"

# install directory in ~/bin or wherever you want it
INSTALL_DIR = ~/bin

OBJS = palwiz.o
#OBJS := $(patsubst %.c,%.o,$(wildcard *.c))

.PHONY: all
all: palwiz

palwiz: $(OBJS)

#$(OBJS): asmx.h

.PHONY: strip
strip: palwiz
	strip palwiz

.PHONY: install
install: palwiz
	rm -f $(INSTALL_DIR)/palwiz
	cp palwiz $(INSTALL_DIR)

.PHONY: install-strip
install-strip: strip install

.PHONY: uninstall
uninstall:
	rm -f $(INSTALL_DIR)/palwiz

# do everything
.PHONY: it
it: clean install-strip zip test

.PHONY: zip
zip: palwiz # build everything first to check for errors
	rm -f test/.DS_Store test/rel/.DS_Store
#	-mv -f palwiz-$(VERSION).zip palwiz-$(VERSION).zip.old
#	zip -rq palwiz-$(VERSION).zip palwiz.c README.txt Makefile test
	zip -rq zip/$(NAME)-$(VERSION)-$(ZIPDATE).zip $(NAME).c palwiz.c \
            README.txt Makefile test

.PHONY: test
test:
# note: palwiz must be installed first!
	cd test && testit

.PHONY: clean
clean:
	rm -f $(OBJS) palwiz
