# @package      hubzero-projfs
# @file         Makefile
# @copyright    Copyright (c) 2005-2020 The Regents of the University of California.
# @license      http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
#
# Copyright (c) 2005-2020 The Regents of the University of California.
#
# This file is part of: The HUBzero(R) Platform for Scientific Collaboration
#
# The HUBzero(R) Platform for Scientific Collaboration (HUBzero) is free
# software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# HUBzero 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# HUBzero is a registered trademark of The Regents of the University of California.
#

#CFLAGS	= -g -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=25 -Wall 
CFLAGS	= -O3 -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=25 -Wall -Werror
CFLAGS += -Iinclude
LDFLAGS	= -lfuse
INSTDIR=$(DESTDIR)/sbin

PROJFS_BUILDDIR = projfs_build
IRPROJFS_BUILDDIR = irprojfs_build
SOURCE_FILES = $(wildcard *.c)
PROJFS_OBJECT_FILES = $(SOURCE_FILES:%.c=$(PROJFS_BUILDDIR)/%.o)
IRPROJFS_OBJECT_FILES = $(SOURCE_FILES:%.c=$(IRPROJFS_BUILDDIR)/%.o)

all: projfs irprojfs

irprojfs: $(IRPROJFS_OBJECT_FILES)
	$(CC) -o $@ $^ $(LDFLAGS)

$(IRPROJFS_OBJECT_FILES): $(IRPROJFS_BUILDDIR)/%.o: %.c
	@mkdir -p $(@D)
	$(CC) $(CFLAGS) -DIRODS_BUILD -c -o $@ $<

projfs: $(PROJFS_OBJECT_FILES)
	$(CC) -o $@ $^ $(LDFLAGS)

$(PROJFS_OBJECT_FILES): $(PROJFS_BUILDDIR)/%.o: %.c
	@mkdir -p $(@D)
	$(CC) $(CFLAGS) -c -o $@ $<

install: projfs irprojfs
	install -d $(INSTDIR) --mode 0755
	install projfs $(INSTDIR)/mount.projfs --mode 0755
	install irprojfs $(INSTDIR)/mount.irprojfs --mode 0755

clean:
	rm -f $(IRPROJFS_BUILDDIR)/*.o $(PROJFS_BUILDDIR)/*.o projfs irprojfs build-stamp configure-stamp
