103 lines
2.8 KiB
Makefile
Executable File
103 lines
2.8 KiB
Makefile
Executable File
#!/usr/bin/make -f
|
||
#******************************************************************************#
|
||
# #
|
||
# Makefile #
|
||
# | Project : libmonochrome #
|
||
# #
|
||
# By: thomas <thomas@touhey.fr> #
|
||
# Last updated: 2015/12/23 10:02:49 #
|
||
# #
|
||
#******************************************************************************#
|
||
# INCLUDE CONFIGURATION
|
||
include Makefile.vars Makefile.cfg
|
||
|
||
# DEDUCED VARIABLES
|
||
ALLOBJ = $(SRC:%=$(OBJDIR)/%.o)
|
||
ALLINC = $(INCPUB:%=$(INCDIR)/%.h) $(INCINT:%=$(INCDIR)/%.h)
|
||
|
||
# STYLE VARS
|
||
define \n
|
||
|
||
|
||
endef
|
||
|
||
# RULES
|
||
## General
|
||
## - Make everything (default)
|
||
all: lib$(NAME).a
|
||
|
||
## Library related
|
||
## - Make the object directory
|
||
$(OBJDIR):
|
||
$(MD) $@
|
||
|
||
## - Make an object file out of a C source file
|
||
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(ALLINC)
|
||
$(CC) -c -o $@ $< $(CFLAGS)
|
||
|
||
## - Make the library
|
||
lib$(NAME).a: $(OBJDIR) $(ALLOBJ)
|
||
$(AR) rc $@ $(ALLOBJ)
|
||
$(RANLIB) $@
|
||
|
||
## - Clean the object files
|
||
clean:
|
||
$(RM) $(ALLOBJ)
|
||
|
||
## - Clean the object files and the binary
|
||
fclean: clean
|
||
$(RM) lib$(NAME).a
|
||
|
||
## - Remake the library
|
||
re: fclean all
|
||
|
||
## - Install library and includes
|
||
install:
|
||
$(INST) -D -m 644 lib$(NAME).a $(ILIBDIR)/lib$(NAME).a
|
||
$(foreach inc, $(INCPUB), \
|
||
$(INST) -D -m 644 $(INCDIR)/$(inc).h $(IINCDIR)/$(inc).h$(\n))
|
||
|
||
## Documentation related
|
||
## - Make man directories
|
||
define make-mandir-rule
|
||
$(MANDIR)/man$1:
|
||
$(MD) $$@
|
||
endef
|
||
$(foreach section,$(MAN_SECTS), \
|
||
$(eval $(call make-mandir-rule,$(section))))
|
||
|
||
## - Make-A-Manpage
|
||
define make-manpage-rule
|
||
$(MANDIR)/man$1/$2.$1: $(DOCDIR)/$2.$1.txt | $(MANDIR)/man$1
|
||
$(A2X) -f manpage -D $$| $$<
|
||
endef
|
||
$(foreach section,$(MAN_SECTS), \
|
||
$(foreach page,$(MAN_$(section)), \
|
||
$(eval $(call make-manpage-rule,$(section),$(page)))))
|
||
|
||
## - Make all manpages
|
||
all-doc: $(foreach section,$(MAN_SECTS),$(MAN_$(section):%=$(MANDIR)/man$(section)/%.$(section)))
|
||
|
||
## - Clean all manpages
|
||
clean-doc:
|
||
$(RM) -R $(MAN_SECTS:%=$(MANDIR)/man%)
|
||
|
||
## - Install a manpage
|
||
define make-installmanpage-rule
|
||
install-$1-$2:| $(MANDIR)/man$1/$2.$1
|
||
$(INST) -D -m 644 $(MANDIR)/man$1/$2.$1 $(IMANDIR)/man$1/$2.$1
|
||
$(GZIP) $(IMANDIR)/man$1/$2.$1
|
||
endef
|
||
$(foreach section, $(MAN_SECTS), \
|
||
$(foreach page,$(MAN_$(section)), \
|
||
$(eval $(call make-installmanpage-rule,$(section),$(page)))))
|
||
|
||
## - Install manpages
|
||
install-doc: $(foreach s,$(MAN_SECTS),$(MAN_$(s):%=install-$(s)-%))
|
||
|
||
## Doz rulz are phunny
|
||
.PHONY: all clean fclean re install
|
||
.PHONY: all-doc $(foreach s,$(MAN_SECTS),$(MAN_$(s):%=install-$(s)-%)) install-doc
|
||
|
||
# END OF FILE
|