cake
/
libp7
Archived
1
0
Fork 1
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libp7/Makefile

93 lines
2.6 KiB
Makefile
Executable File

#******************************************************************************#
# _____ _ #
# Makefile |_ _|__ _ _| |__ ___ _ _ #
# | Project : libp7 | |/ _ \| | | | '_ \ / _ \ | | | #
# | | (_) | |_| | | | | __/ |_| | #
# By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr #
# Last updated: 2016/05/12 01:14:00 |___/ #
# #
#******************************************************************************#
# INCLUDE VARS
include Makefile.vars
# DEDUCED VARS
ALLOBJ = $(foreach mod,$(MODULES),$(SRC_$(mod):%=$(OBJDIR)/$(mod)/%.o))
ALLMAN = $(foreach s,$(MAN_SECTIONS),$(MAN_$(s):%=$(MANDIR)/man$(s)/%.$(s)))
# TARGETS
## General targets
## - Make it all
all: lib$(NAME).a
## Library-specific targets
## - Make a module object directory
$(MODULES:%=$(OBJDIR)/%):
$(MD) $@
## - Make a module object out of a module source file
define make-moduleobj-rule
$(OBJDIR)/$1/%.o: $(SRCDIR)/$1/%.c | $(OBJDIR)/$1
$(CC) -c -o $$@ $$< $(CFLAGS)
endef
$(foreach mod,$(MODULES), \
$(eval $(call make-moduleobj-rule,$(mod))))
## - Make the library
lib$(NAME).a: $(ALLOBJ)
$(AR) rc $@ $^
$(RANLIB) $@
## - Remove object files
clean:
$(RM) $(ALLOBJ)
## - Clean and remove final library
fclean: clean
$(RM) lib$(NAME).a
## - Remake library
re: fclean all
## - Install library
install:
$(INST) -D -m 644 lib$(NAME).a $(ILIBDIR)/lib$(NAME).a
$(INST) -D -m 644 $(INCDIR)/lib$(NAME).h $(IINCDIR)/lib$(NAME).h
$(if $(INSTALL_UDEV_RULE),$(INST) -D -m 644 udev.rules $(UDEVDIR)/60-casio-usb.rules)
## Documentation related
## - Make manpages directories
$(MAN_SECTIONS:%=$(MANDIR)/man%):
$(MD) $@
## - Make-A-Manpage
define make-manpage-rule
$(MANDIR)/man$1/%.$1: $(DOCDIR)/%.$1.txt | $(MANDIR)/man$1
$(A2X) -f manpage -D $$| $$<
endef
$(foreach section, $(MAN_SECTIONS), \
$(eval $(call make-manpage-rule,$(section))))
## - Make all manpages
all-doc: $(ALLMAN)
## - Remove all manpages
clean-doc:
$(RM) $(ALLMAN)
## - Install-A-Manpage
define make-installmanpage-rule
install-$1-%:| $(MANDIR)/man$1/%.$1
$(INST) -D -m 644 $(MANDIR)/man$1/$$*.$1 $(IMANDIR)/man$1/$$*.$1
$(GZIP) $(IMANDIR)/man$1/$$*.$1
endef
$(foreach section, $(MAN_SECTIONS), \
$(eval $(call make-installmanpage-rule,$(section))))
## - Install manpages
install-doc: $(foreach s,$(MAN_SECTIONS),$(MAN_$(s):%=install-$(s)-%))
## PHONY
.PHONY: all clean fclean re install
# END OF FILE