# -*- Mode: Makefile -*-
# Makefile.Base
# Copyright (c) 2003-2013 Steward and Lee, LLC, Updated by Andre Gompel
# This is part of pdftk
#
# Visit: www.pdftk.com for pdftk information and articles
# Permalink: http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
#
# Please email Sid Steward with questions or bug reports.
# Include "pdftk" in the subject line to ensure successful delivery:
# sid.steward at pdflabs dot com
#
# Don't call this makefile directly; it is included by other,
# platform-specific makefiles, e.g.: Makefile.Debian
#

export JAVALIBPATH= $(CURDIR)/../java

JAVALIB= $(JAVALIBPATH)/java_lib.o

ifdef USE_LIBGCJ_SUPPLEMENT
export LIBGCJ_SUPPLEMENT= libgcj_supplement
export LIBGCJ_SUPPLEMENT_FULL_O= $(JAVALIBPATH)/$(LIBGCJ_SUPPLEMENT).o
endif

# this must already be set according to your platform Makefile;
# we're just appending to it, here
#
CPPFLAGS+= -DPDFTK_VER=\"2.02\"

all : javalib pdftk

javalib :
	$(MAKE) -f Makefile -iC $(JAVALIBPATH) all

attachments.o : attachments.cc attachments.h pdftk.h $(JAVALIB)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(JAVALIBPATH) attachments.cc -c

report.o : report.cc report.h pdftk.h $(JAVALIB)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(JAVALIBPATH) report.cc -c

passwords.o : passwords.cc passwords.h pdftk.h $(JAVALIB)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(JAVALIBPATH) passwords.cc -c

pdftk.o : pdftk.cc pdftk.h attachments.h report.h passwords.h $(JAVALIB)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(JAVALIBPATH) pdftk.cc -c

pdftk : pdftk.o attachments.o report.o passwords.o $(JAVALIB) $(LIBGCJ_SUPPLEMENT_FULL_O)
	$(CXX) $(CXXFLAGS) attachments.o report.o passwords.o pdftk.o $(JAVALIB) $(LIBGCJ_SUPPLEMENT_FULL_O) $(LDLIBS) -o pdftk

install:
	/usr/bin/install pdftk /usr/local/bin 

uninstall:
	$(RM) $(RMFLAGS) /usr/local/bin/pdftk

clean:
	$(RM) $(RMFLAGS) *.o
	$(RM) $(RMFLAGS) pdftk
	$(MAKE) -f Makefile -C $(JAVALIBPATH) clean
