# Makefile
# Copyright (C) 2007, 2008 Gustav Behm <gbehm (at) kth.se>
#
# This file is part of Netzack.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

default: jar

TOPDIR=./
DIR = ./
SUBDIRS=bin \
	src \
	scripts

SRC_INCLUDE = COPYING \
	TODO \
	README \
	INSTALL \
	configure \
	Makefile.include


include Makefile.include


Makefile.config:
	./configure

all: Makefile.config
	@$(MAKE) all-recursive

clean: clean-recursive
	$(RM) $(JARFILE)
	$(RM) $(BUILD_DIR)
	$(RM) config.sed
	$(RM) Makefile.config
	$(RM) src/config.xml


jar: Makefile.config all
	$(MKDIR) $(JARFILE)-tmp
	$(MAKE) prepare-jar-recursive
	$(MKDIR) $(BUILD_DIR)/$(PREFIX_LIB)
	$(JAR) cfm $(BUILD_DIR)/$(PREFIX_LIB)/$(JARFILE) $(MANIFEST) -C $(JARFILE)-tmp .
	$(RM) $(JARFILE)-tmp



dist: Makefile.config
	$(MKDIR) $(TMP_DIR)
	$(MAKE) prepare-tarball
	$(TAR) czf $(TARBALL) $(TMP_DIR)
	$(RM) $(TMP_DIR)

install: jar
	$(MKDIR) $(PREFIX)/$(PREFIX_BIN)
	$(INSTALL) -m 0755 $(BUILD_DIR)/$(PREFIX_BIN)/$(EXEC_NAME) $(PREFIX)/$(PREFIX_BIN)/$(EXEC_NAME)

	$(MKDIR) $(PREFIX)/$(PREFIX_LIB)
	$(INSTALL) -m 0644 $(BUILD_DIR)/$(PREFIX_LIB)/$(JARFILE) $(PREFIX)/$(PREFIX_LIB)/$(JARFILE)

uninstall:
	$(RM) $(PREFIX)/$(PREFIX_BIN)/$(EXEC_NAME)
	$(RM) $(PREFIX)/$(PREFIX_LIB)
