cake
/
libp7
Archived
1
0
Fork 1

Improved Makefile, added cpp case in headers

This commit is contained in:
Thomas Touhey 2016-09-12 14:38:35 +02:00
parent 716cd7402a
commit bbb00b3abc
5 changed files with 77 additions and 19 deletions

View File

@ -17,9 +17,30 @@ include Makefile.vars
# TARGETS
## General targets
## - Make it all
all: lib$(NAME).so
all: all-lib all-doc
## - Clean it all
clean: clean-lib clean-doc
## - Force-clean it all
fclean: fclean-lib clean-doc
## - Remake it all
re: fclean all
## - Install it all
install: install-lib install-doc
## - Uninstall
uninstall: uninstall-lib uninstall-doc
## - Reinstall library
reinstall: uninstall install
## Library-specific targets
## - Make all libraries
all-lib: lib$(NAME).so
## - Make a module object directory
$(MODULES:%=$(OBJDIR)/%):
$(MD) $@
@ -37,39 +58,41 @@ lib$(NAME).so: $(ALLOBJ)
$(LD) -o $@ $^ $(LDFLAGS)
## - Remove object files
clean:
clean-lib:
$(RM) $(ALLOBJ)
## - Clean and remove final library
fclean: clean
fclean-lib: clean
$(RM) lib$(NAME).a lib$(NAME).so.$(VERSION) lib$(NAME).so
## - Remake library
re: fclean all
re-lib: fclean-lib all-lib
## - Install header
define make-installinc-rule
install-$(INCDIR)/$1.h: $(INCDIR)/$1.h
install-lib-$(INCDIR)/$1.h: $(INCDIR)/$1.h
$(INST) -D -m 644 $(INCDIR)/$1.h $(IINCDIR)/$1.h
endef
$(foreach inc,$(INCPUB), \
$(eval $(call make-installinc-rule,$(inc))))
## - Install library
install: $(INCPUB:%=install-$(INCDIR)/%.h)
install-lib: $(INCPUB:%=install-lib-$(INCDIR)/%.h)
$(INST) -D -m 644 lib$(NAME).so $(ILIBDIR)/lib$(NAME).so.$(VERSION)
$(LN) lib$(NAME).so.$(VERSION) $(ILIBDIR)/lib$(NAME).so
$(if $(INSTALL_UDEV_RULE),$(INST) -D -m 644 udev.rules $(UDEVDIR)/60-casio-usb.rules)
## - Uninstall library
uninstall:
uninstall-lib:
$(RM) $(ILIBDIR)/lib$(NAME).a $(ILIBDIR)/lib$(NAME).so*
$(RM) $(IINCDIR)/lib$(NAME).h
$(RM) -r $(IINCDIR)/lib$(NAME)
$(RM) $(UDEVDIR)/60-casio-usb.rules
## - Reinstall library
reinstall: uninstall install
## Documentation related
## - Make all manpages
all-doc: $(ALLMAN)
## - Make manpages directories
$(MAN_SECTIONS:%=$(MANDIR)/man%):
$(MD) $@
@ -82,16 +105,13 @@ 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
install-doc-$1-%:| $(MANDIR)/man$1/%.$1
$(INST) -D -m 644 $(MANDIR)/man$1/$$*.$1 $(IMANDIR)/man$1/$$*.$1
$(GZIP) $(IMANDIR)/man$1/$$*.$1
endef
@ -99,11 +119,25 @@ $(foreach section, $(MAN_SECTIONS), \
$(eval $(call make-installmanpage-rule,$(section))))
## - Install manpages
install-doc: $(foreach s,$(MAN_SECTIONS),$(MAN_$(s):%=install-$(s)-%))
install-doc: $(foreach s,$(MAN_SECTIONS),$(MAN_$(s):%=install-doc-$(s)-%))
## PHONY
.PHONY: all clean fclean re $(INCPUB:%=install-$(INCDIR)/%.h) install
.PHONY: uninstall reinstall
.PHONY: all-doc clean-doc $(MAN_SECTIONS:%=install-%-%) install-doc
## - Clean a man section
uninstall-doc-%:
$(RM) $(IMANDIR)/man$*/libp7.$*
$(RM) $(IMANDIR)/man$*/p7_*.$*
## - Uninstall manpages
uninstall-doc: $(MAN_SECTIONS:%=uninstall-doc-%)
# PHONY
# - General
.PHONY: all clean fclean re install uninstall
# - Library-related
.PHONY: all-lib clean-lib fclean-lib re-lib install-lib uninstall-lib
.PHONY: $(INCPUB:%=install-lib-$(INCDIR)/%.h)
# - Documentation related
.PHONY: all-doc clean-doc install-doc uninstall-doc
.PHONY: $(foreach s,$(MAN_SECTIONS),$(MAN_$(s):%=install-doc-$(s)-%))
.PHONY: $(MAN_SECTIONS:%=uninstall-doc-%)
# END OF FILE

View File

@ -11,6 +11,9 @@
#ifndef LIBP7_H
# define LIBP7_H
# include <stdio.h>
# ifdef __cplusplus
extern "C" {
# endif
/* ************************************************************************** */
/* libp7 errors */
@ -96,4 +99,7 @@ int p7_copyfile(char *dirname, char *filename, char *newdir, char *newname,
/* Display streamed screen */
int p7_getscreen(int (*callback)(unsigned char*));
# ifdef __cplusplus
}
# endif
#endif /* LIBP7_H */

View File

@ -12,6 +12,9 @@
# define LIBP7_PACKET_H
# define MAX_COMMAND_ARGUMENT_SIZE 128
# define MAX_VRAM_SIZE 1024 /* to increase for other formats */
# ifdef __cplusplus
extern "C" {
# endif
/* ************************************************************************** */
/* Useful structures */
@ -269,4 +272,7 @@ typedef struct {
p7_packetscr_t screen;
} p7_packet_t;
# ifdef __cplusplus
}
# endif
#endif /* LIBP7_PACKET_H */

View File

@ -12,6 +12,9 @@
# define LIBP7_PACKETIO_H
# include <libp7/packet.h>
# define MAX_RAWDATA_SIZE 256
# ifdef __cplusplus
extern "C" {
# endif
/* ************************************************************************** */
/* Packet sending */
@ -70,4 +73,7 @@ int p7_recv_screen(unsigned char *picdata);
/* Unshift (get response without sending) */
int p7_unshift(void);
# ifdef __cplusplus
}
# endif
#endif /* LIBP7_PACKETIO_H */

View File

@ -16,6 +16,9 @@
# include <stdlib.h>
# include <string.h>
# include <errno.h>
# ifdef __cplusplus
extern "C" {
# endif
/* timeouts */
# define ACTIVE_TIMEOUT (10 * 1000) /* 10 seconds */
@ -34,4 +37,7 @@ extern int p7_active;
/* initialize using streams */
int p7_init_stream(FILE *stream, int active);
# ifdef __cplusplus
}
# endif
#endif /* LIBP7_STREAMS_H */