File Makefile.in of Package libfatfs

# SPDX-License-Identifier: LGPL-3.0-or-later 

# Copyright (C) 2025 Perry Werneck <perry.werneck@gmail.com>
#
# This program 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.
#
# 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 Lesser General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

#---[ Library configuration ]------------------------------------------------------------

SOURCES= \
	source/diskio.c \
	source/ff.c \
	source/ffsystem.c \
	source/ffunicode.c

#---[ Tools ]----------------------------------------------------------------------------

CC=@CC@
LD=@CC@
LN_S=@LN_S@
MKDIR=@MKDIR_P@
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
AR=@AR@

#---[ Paths ]----------------------------------------------------------------------------

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
libdir=@libdir@
includedir=@includedir@
datarootdir=@datarootdir@
localedir=@localedir@
docdir=@docdir@
sysconfdir=/etc

OBJDIR=.obj
OBJDBG=$(OBJDIR)/Debug
OBJRLS=$(OBJDIR)/Release

BINDIR=.bin
BINDBG=$(BINDIR)/Debug
BINRLS=$(BINDIR)/Release

#---[ Rules ]----------------------------------------------------------------------------

CFLAGS= \
	@CFLAGS@ \
	-fPIC \
	-Isrc/include

LDFLAGS=\
	@LDFLAGS@

LIBS= \
	@LIBS@

#---[ Debug Rules ]----------------------------------------------------------------------

$(OBJDBG)/%.o: \
	%.c

	@echo $< ...
	@$(MKDIR) $(dir $@)

	@$(CC) \
		$(CFLAGS) \
		-DDEBUG=1 \
		-MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<

	@$(CC) \
		$(CFLAGS) \
		-Wall -Wextra -fstack-check \
		-DDEBUG=1 \
		-o $@ \
		-c $<

#---[ Release Rules ]--------------------------------------------------------------------

$(OBJRLS)/%.o: \
	%.c

	@echo $< ...
	@$(MKDIR) $(dir $@)

	@$(CC) \
		$(CFLAGS) \
		-DNDEBUG=1 \
		-MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<

	@$(CC) \
		$(CFLAGS) \
		-Wall -Wextra -fstack-check \
		-DNDEBUG=1 \
		-o $@ \
		-c $<

#---[ Release Targets ]------------------------------------------------------------------

all: \
	$(BINRLS)/libfatfs.a \
	$(BINRLS)/libfatfs.so.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@

Release: \
	$(BINRLS)/libfatfs.a

$(BINRLS)/libfatfs.so.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \
	$(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)

	@$(MKDIR) $(@D)
	@echo $< ...
	@$(LD) \
		-shared -Wl,-soname,\$(@F) \
		-o $@ \
		$(LDFLAGS) \
		$^ \
		$(LIBS)

$(BINRLS)/libfatfs.a: \
	$(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)

	@$(MKDIR) $(@D)
	@echo $< ...
	@$(AR) rcs $@ $^

#---[ Install Targets ]------------------------------------------------------------------

install: \
	$(BINRLS)/libfatfs.a \
	$(BINRLS)/libfatfs.so.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@

	@$(MKDIR) \
		$(DESTDIR)$(libdir)

	@$(INSTALL_PROGRAM) \
		$(BINRLS)/libfatfs.so.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \
		$(DESTDIR)$(libdir)/libfatfs.so.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@

	@ln -s \
		libfatfs.so.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \
		$(DESTDIR)$(libdir)/libfatfs.so

	@$(INSTALL_PROGRAM) \
		$(BINRLS)/libfatfs.a \
		$(DESTDIR)$(libdir)/libfatfs.a

	@$(MKDIR) \
		$(DESTDIR)$(includedir)/fatfs

	@$(INSTALL_DATA) \
		source/diskio.h \
		$(DESTDIR)$(includedir)/fatfs

	@$(INSTALL_DATA) \
		source/ffconf.h \
		$(DESTDIR)$(includedir)/fatfs

	@$(INSTALL_DATA) \
		source/ff.h \
		$(DESTDIR)$(includedir)/fatfs

	@$(MKDIR) \
		$(DESTDIR)$(libdir)/pkgconfig

	@$(INSTALL_DATA) \
		pkgconfig.pc \
		$(DESTDIR)$(libdir)/pkgconfig/libfatfs.pc

clean: \
	cleanDebug \
	cleanRelease

cleanDebug:

	@rm -fr $(OBJDBG)
	@rm -fr $(BINDBG)

cleanRelease:

	@rm -fr $(OBJRLS)
	@rm -fr $(BINRLS)

clean: \
	cleanDebug \
	cleanRelease


-include $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).d)
-include $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).d)


openSUSE Build Service is sponsored by