# HPTalx Makefile

# The compiler
CC=gcc

# If you don't need update ROM (for example, you have only a HP48),
#comment this line:
UPDATE_ROM=-DUPDATE_ROM

# Instalation directory
INSTALLDIR=/usr/local/bin

# and the options (which you probably shouldn't change)
VERSION=1.1.0
DEBUG=-g
CFLAGS=-O2 -Wall $(DEBUG) -DVERSION=\"$(VERSION)\" $(UPDATE_ROM)

# Don't change things below
HDR = hptalx.h gui_utils.h icons.h
SRC = main.c io.c io2.c gui_utils.c icons.c setup.c
OBJ = main.o io.o io2.o gui_utils.o icons.o setup.o

# What to do for all
all: hptalx

upgrade:
ifdef UPDATE_ROM
	(cd hp49flash-0.2.4 && make)
endif

# Compile the parts
hptalx: upgrade $(OBJ)
ifdef UPDATE_ROM
# if you don't have ar uncomment the line below
#	$(CC) $(OBJ) hp49flash-0.2.4/unpak.o hp49flash-0.2.4/upgrade.o hp49flash-0.2.4/hpserial.o -o hptalx `gtk-config --libs` -lutil
	$(CC) $(OBJ) -L./hp49flash-0.2.4 -o hptalx `gtk-config --libs` -lutil -lupgrade
else
	$(CC) $(OBJ) -o hptalx `gtk-config --libs` -lutil
endif

$(OBJ): %.o: %.c $(HDR)
	$(CC) $(CFLAGS) `gtk-config --cflags` -c $< -o $@
	
install: all
	strip hptalx
	/usr/bin/ginstall -c -m 755 hptalx $(INSTALLDIR)

uninstall:
	rm $(INSTALLDIR)/hptalx

# remove everything but the source
clean:
	(cd hp49flash-0.2.4 && make clean)
	rm -f *.o hptalx

package: clean
	cd .. && tar czvf hptalx-$(VERSION).tar.gz hptalx-$(VERSION)/
