OPENSSLDIR=@OPENSSL@
TQSLLIBDIR=@TQSLLIB@
TQSLLIB=@TQSLLIB@
EXPAT=@EXPAT@
# LIBTQSL can be tqsllib or tqsllibd for static or DLL linkage, respectively
LIBTQSL=tqsllibd
EXTRALIBS = -L$(TQSLLIBDIR) -l$(LIBTQSL) -L$(OPENSSLDIR)/lib -L$(EXPAT)/lib -lexpat -lcrypto
INCDIR = -I$(TQSLLIBDIR) -I$(OPENSSLDIR)/include
BUILD=@BUILD@
ifeq ($(BUILD),)
  BUILD=unofficial
endif
CYYFLAGS = $(INCDIR) -DHAVE_CONFIG_H
TQSLLIBFILE=$(TQSLLIBDIR)/lib$(LIBTQSL).a

# The WXWIN environment variable must be set to the root of
# the wxWindows installation
WXDIR=$(WXWIN)

# makeg95.env provides the mingw and windres options needed.
include $(WXDIR)/src/makeg95.env

TARGETS = tqslcert tqsl

all: $(TARGETS)

TQSLCERT_OBJ = tqslcert.o crqwiz.o dxcc.o tqslcert-resources.o \
	certtree.o tqslcert_prefs.o getpassword.o extwizard.o \
	loadcertwiz.o wxutil.o

TQSL_OBJ = tqsl.o stationdial.o dxcc.o tqslcert-resources.o extwizard.o \
	tqslwiz.o qsodatadialog.o tqslvalidator.o tqsl_prefs.o wxutil.o

tqslcert: $(TQSLCERT_OBJ) $(TQSLLIBFILE)
	$(CC) $(LDFLAGS) -o $@ $(TQSLCERT_OBJ) $(LDLIBS) -lstdc++
	strip tqslcert.exe

tqsl: $(TQSL_OBJ) $(TQSLLIBFILE)
	$(CC) $(LDFLAGS) -o $@ $(TQSL_OBJ) $(LDLIBS) -lstdc++
	strip tqsl.exe

include apps.depends

tqslcertbuild.h: buildskel.h
	cp buildskel.h tqslcertbuild.h

tqslcert.o:
	perl touchver.pl tqslcertbuild.h BUILD $(BUILD)
	$(CC) $(CPPFLAGS) $(CYYFLAGS) -fexceptions -frtti -c -o $@ $*.cpp
	
tqslbuild.h: buildskel.h
	cp buildskel.h tqslbuild.h

tqsl.o:
	perl touchver.pl tqslbuild.h BUILD $(BUILD)
	$(CC) $(CPPFLAGS) $(CYYFLAGS) -fexceptions -frtti -c -o $@ $*.cpp
	
tqslcert-resources.o: tqslcert.rc tqsl.ico
	windres -i tqslcert.rc -o tqslcert-resources.o $(RESFLAGS)

%.o: %.cpp
	$(CC) $(CPPFLAGS) $(CYYFLAGS) -fexceptions -frtti -c -o $@ $*.cpp

clean:
	rm -f *.exe *.o *.a *~ xxx.*

distclean:
	$(MAKE) clean
	rm -f Makefile
