Integrated p7utils into this repository.
This commit is contained in:
parent
e1705b75d6
commit
9f79156be6
|
@ -6,5 +6,7 @@
|
|||
/man
|
||||
|
||||
/docs/_build
|
||||
build
|
||||
|
||||
.*.swp
|
||||
vgcore*
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
libcasio authors
|
||||
================
|
||||
|
||||
Copyright (C) 2016-2018 Thomas Touhey <thomas@touhey.fr>
|
|
@ -1,4 +1,6 @@
|
|||
# Contributing to libcasio
|
||||
Contributing to libcasio
|
||||
========================
|
||||
|
||||
For now, this is a personal project from Thomas "Cakeisalie5" Touhey.
|
||||
No contributions are allowed while it is. An announce will be put on the
|
||||
[P7 website](https://p7.planet-casio.com/en.html) when they will be.
|
||||
`P7 website <https://p7.planet-casio.com/en.html>`_ when they will be.
|
|
@ -0,0 +1,336 @@
|
|||
GNU General Public License
|
||||
==========================
|
||||
|
||||
_Version 2, June 1991_
|
||||
_Copyright © 1989, 1991 Free Software Foundation, Inc.,_
|
||||
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: **(1)** copyright the software, and
|
||||
**(2)** offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
**0.** This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The “Program”, below,
|
||||
refers to any such program or work, and a “work based on the Program”
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term “modification”.) Each licensee is addressed as “you”.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
**1.** You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
**2.** You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
* **a)** You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
* **b)** You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
* **c)** If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
**3.** You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
* **a)** Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
* **b)** Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
* **c)** Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
**4.** You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
**5.** You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
**6.** Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
**7.** If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
**8.** If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
**9.** The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and “any
|
||||
later version”, you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
**10.** If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
### NO WARRANTY
|
||||
|
||||
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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 General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w` and `show c` should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w` and `show c`; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a “copyright disclaimer” for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
|
@ -0,0 +1,10 @@
|
|||
libcasio license
|
||||
================
|
||||
|
||||
This repository has content from several sources which had several licenses
|
||||
applied. This means:
|
||||
|
||||
- the utilities (``src/`` folder) are under GPL version 2 (see ``GPL2.md``).
|
||||
- the library (``lib/`` and ``include/`` folder) are under LGPL version 3
|
||||
(see ``LGPL3.md``).
|
||||
- the rest is under LGPL version 3 (see ``LGPL3.md``).
|
230
Makefile
230
Makefile
|
@ -1,24 +1,31 @@
|
|||
#!/usr/bin/make -f
|
||||
#*****************************************************************************#
|
||||
# Include variables and message subsystem #
|
||||
#*****************************************************************************#
|
||||
include Makefile.vars Makefile.msg
|
||||
|
||||
#*****************************************************************************#
|
||||
# General targets #
|
||||
#*****************************************************************************#
|
||||
# ---
|
||||
# General targets.
|
||||
# ---
|
||||
|
||||
# Build everything.
|
||||
all: all-lib
|
||||
|
||||
all: all-lib all-utils
|
||||
|
||||
# Mostly clean everything (remove everything but the end results).
|
||||
mostlyclean: mostlyclean-lib
|
||||
|
||||
mostlyclean:
|
||||
|
||||
mclean: mostlyclean
|
||||
|
||||
# Clean everything.
|
||||
clean: clean-lib
|
||||
|
||||
clean:
|
||||
$(call rmsg,Removing the build folder.)
|
||||
$(call qcmd,$(RM) -r build obj)
|
||||
$(call qcmd,$(RM) $(SONAMES) $(ANAMES))
|
||||
|
||||
fclean: clean
|
||||
|
||||
# To original state.
|
||||
|
||||
mrproper: clean
|
||||
$(call rmsg,Removing configuration.)
|
||||
$(call qcmd,$(RM) Makefile.cfg)
|
||||
|
@ -31,12 +38,6 @@ re: clean all
|
|||
# Install everything.
|
||||
install: install-lib
|
||||
|
||||
# Uninstall everything. (experimental)
|
||||
uninstall: uninstall-lib
|
||||
|
||||
# Reinstall everything. (experimental)
|
||||
reinstall: uninstall install
|
||||
|
||||
# Make a distribution tarball
|
||||
dist: mrproper
|
||||
$(call bcmd,mkdir,lib$(NAME)-$(VERSION),\
|
||||
|
@ -51,16 +52,20 @@ dist: mrproper
|
|||
$(call qcmd,$(RM) -r lib$(NAME)-$(VERSION))
|
||||
|
||||
.PHONY: all mostlyclean mclean clean fclean mrproper re
|
||||
.PHONY: dist install uninstall reinstall
|
||||
#*****************************************************************************#
|
||||
# Configuration (version) checking dependencies #
|
||||
#*****************************************************************************#
|
||||
.PHONY: dist install
|
||||
|
||||
# ---
|
||||
# Configuration (version) checking dependencies.
|
||||
# ---
|
||||
|
||||
# Define the dependencies.
|
||||
|
||||
CHECKCFG := $(if $(shell test -f Makefile.cfg || echo y),check-config, \
|
||||
$(if $(shell [ "$(VERSION)" = "$(CONFIG_VERSION)" ] || echo y), \
|
||||
check-config-version))
|
||||
|
||||
# Define the rules.
|
||||
|
||||
check-config:
|
||||
@echo -e "\033[1;31mNo configuration file found!"
|
||||
@echo -e "You should configure before re-running this target.\033[0m"
|
||||
|
@ -71,75 +76,80 @@ dist: mrproper
|
|||
@false
|
||||
|
||||
.PHONY: check-config check-config-version
|
||||
#*****************************************************************************#
|
||||
# Information getting from the Makefile variables #
|
||||
#*****************************************************************************#
|
||||
|
||||
# ---
|
||||
# Targets for gathering information from the Makefile variables.
|
||||
# ---
|
||||
|
||||
# Get the project name.
|
||||
|
||||
getname:
|
||||
@echo lib$(NAME)
|
||||
@echo $(NAME)
|
||||
|
||||
# Get the project version.
|
||||
|
||||
getversion:
|
||||
@echo $(VERSION)
|
||||
|
||||
# Check if is indev.
|
||||
|
||||
isindev:
|
||||
@$(if $(INDEV),echo $(INDEV),true)
|
||||
|
||||
# Get the maintainer.
|
||||
|
||||
getmaintainer:
|
||||
@echo "$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>"
|
||||
|
||||
.PHONY: getname getversion getmaintainer
|
||||
#*****************************************************************************#
|
||||
# Library-specific targets #
|
||||
#*****************************************************************************#
|
||||
# Make the library.
|
||||
all-lib: $(CHECKCFG) $(if $(STATIC),$(ANAME),$(SONAME))
|
||||
.PHONY: getname getversion isindev getmaintainer
|
||||
|
||||
# Make a module object directory.
|
||||
$(OBJDIR)/ $(DIRS:%=$(OBJDIR)/%):
|
||||
# ---
|
||||
# Make directories.
|
||||
# ---
|
||||
|
||||
./build/ $(L_OBJDIRS) $(U_OBJDIRS) $(M_SECTIONS:%=$(M_MANDIR)/man%/):
|
||||
$(call bcmd,mkdir,$@,$(MD) $@)
|
||||
|
||||
# ---
|
||||
# Library specific targets.
|
||||
# ---
|
||||
|
||||
# Make the library.
|
||||
|
||||
all-lib: $(CHECKCFG) $(if $(STATIC),./build/$(L_ANAME),./build/$(L_SONAME))
|
||||
|
||||
# Make the shared or static library.
|
||||
|
||||
ifeq ($(FOR_WINDOWS),)
|
||||
./build/lib$(LIB).so: ./build/$(L_SONAME)
|
||||
$(call bcmd,ln,$@,$(LN) $(L_SONAME) $@)
|
||||
endif
|
||||
|
||||
./build/$(L_SONAME): $(L_SRC:%=$(L_OBJDIR)/%.o)
|
||||
$(call bcmd,ld,$(L_SONAME),$(LD) -o $@ $^ $(L_LDFLAGS))
|
||||
./build/lib$(L_ANAME).a: $(L_SRC:%=$(L_OBJDIR)/%.o)
|
||||
$(call bcmd,ar rc,lib$(L_ANAME).a,$(AR) rcs $@ $^)
|
||||
|
||||
# Make an object out of a source file.
|
||||
|
||||
define make-obj-rule
|
||||
$(OBJDIR)/$1.c.o: $(SRCDIR)/$1.c $(INC) $(INCI) | $(dir $(OBJDIR)/$1)
|
||||
$(call bcmd,cc,$$@,$(CC) -c -o $$@ $$< $(CFLAGS))
|
||||
$(L_OBJDIR)/$1.c.o: $(L_SRCDIR)/$1.c $(L_INC) | $(dir $(L_OBJDIR)/$1)
|
||||
$(call bcmd,cc,$$@,$(CC) -c -o $$@ $$< $(L_CFLAGS))
|
||||
endef
|
||||
$(foreach src,$(basename $(SRC)),\
|
||||
$(foreach src,$(basename $(L_SRC)),\
|
||||
$(eval $(call make-obj-rule,$(src))))
|
||||
|
||||
# Make the shared library.
|
||||
$(SONAME): $(SRC:%=$(OBJDIR)/%.o)
|
||||
$(call bcmd,ld,$@,$(LD) -o $@ $^ $(LDFLAGS))
|
||||
|
||||
# Make the static library.
|
||||
lib$(NAME).a: $(SRC:%=$(OBJDIR)/%.o)
|
||||
$(call bcmd,ar rc,$@,$(AR) rcs $@ $^)
|
||||
|
||||
# Remove the objects directory.
|
||||
mostlyclean-lib:
|
||||
$(call rmsg,Removing object directory.)
|
||||
$(call qcmd,$(RM) -r $(OBJDIR))
|
||||
mclean-lib: mostlyclean-lib
|
||||
|
||||
# Clean and remove the built library.
|
||||
clean-lib: mclean-lib
|
||||
$(call rmsg,Removing the library.)
|
||||
$(call qcmd,$(RM) $(SONAMES) $(ANAMES))
|
||||
|
||||
# Remake the library.
|
||||
re-lib: clean-lib all-lib
|
||||
|
||||
# Install the library and development files.
|
||||
|
||||
LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(STATIC),,\
|
||||
$(if $(FOR_WINDOWS),,y)))
|
||||
IWINDLL := $(if $(FOR_WINDOWS),$(if $(STATIC),,y))
|
||||
|
||||
install-lib: all-lib $(if $(INSTALL_DEVEL),install-cfgtool)
|
||||
$(call imsg,Installing the library.)
|
||||
$(call qcmd,$(INST) -m 755 -d "$(ILIBDIR)")
|
||||
$(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" $(if $(STATIC),\
|
||||
$(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a),\
|
||||
$(if $(FOR_WINDOWS),lib$(L_NAME).lib,lib$(L_NAME).a),\
|
||||
$(if $(FOR_WINDOWS),lib$(NAME).dll.a,$(SONAME))))
|
||||
|
||||
$(if $(IWINDLL),$(call qcmd,$(INST) -m 755 -d "$(IBINDIR)"))
|
||||
|
@ -160,26 +170,12 @@ $(eval $(call make-obj-rule,$(src))))
|
|||
$(call qcmd,$(INST) -m 644 $(INCDIR)/$(i) \
|
||||
"$(IINCDIR)/lib$(NAME)-$(VERSION)/$(i)"$(\n))))
|
||||
|
||||
# Uninstall the library and development files. (experimental)
|
||||
uninstall-lib: $(CHECKCFG) uninstall-cfgtool
|
||||
$(call rmsg,Uninstalling the library.)
|
||||
$(call qcmd,$(RM) "$(IBINDIR)/lib$(NAME).dll")
|
||||
$(call qcmd,$(RM) "$(ILIBDIR)/lib$(NAME).so"* \
|
||||
"$(ILIBDIR)/lib$(NAME).a" "$(ILIBDIR)/lib$(NAME).dll"*)
|
||||
$(call rmsg,Uninstalling development files.)
|
||||
$(call qcmd,$(RM) -r "$(IINCDIR)/lib$(NAME)-$(VERSION)")
|
||||
$(call qcmd,$(RM) "$(IINCDIR)/lib$(NAME).h")
|
||||
$(call qcmd,$(RM) -r "$(IINCDIR)/lib$(NAME)")
|
||||
.PHONY: all-lib install-lib
|
||||
|
||||
# Reinstall the library and development files.
|
||||
reinstall-lib: uninstall-lib install-lib
|
||||
# ---
|
||||
# Configuration tools related.
|
||||
# ---
|
||||
|
||||
.PHONY: all-lib mostlyclean-lib mclean-lib clean-lib re-lib
|
||||
.PHONY: install-lib uninstall-lib reinstall-lib
|
||||
#*****************************************************************************#
|
||||
# Configuration tools-related #
|
||||
#*****************************************************************************#
|
||||
# Install it.
|
||||
install-cfgtool: $(CHECKCFG)
|
||||
$(call imsg,Installing the configuration tool.)
|
||||
$(call qcmd,$(INST) -m 755 -d "$(IBINDIR)")
|
||||
|
@ -203,20 +199,82 @@ $(eval $(call make-obj-rule,$(src))))
|
|||
>"$(IPKGDIR)/lib$(NAME).pc" \
|
||||
&& chmod 644 "$(IPKGDIR)/lib$(NAME).pc")
|
||||
|
||||
# Uninstall it
|
||||
uninstall-cfgtool: $(CHECKCFG)
|
||||
$(call rmsg,Uninstalling configuration tool and package.)
|
||||
$(call qcmd,$(RM) "$(IPKGDIR)/lib$(NAME).pc" \
|
||||
"$(IBINDIR)/lib$(NAME)-config" "$(IBINDIR)/"*"-lib$(NAME)-config" \
|
||||
$(if $(TARGET),"$(HBINDIR)/$(TARGET)lib$(NAME)-config"))
|
||||
.PHONY: install-cfgtool
|
||||
|
||||
# ---
|
||||
# Utilities related.
|
||||
# ---
|
||||
|
||||
# Make the utilities.
|
||||
|
||||
all-utils: $(CHECKCFG) $(DEFAULT_UTILS:%=all-%)
|
||||
|
||||
# Make a utility.
|
||||
|
||||
define make-util-rules
|
||||
./build/$1$(if $(FOR_WINDOWS),.exe): $(U_OBJ_$1) \
|
||||
$(if $(filter libcasio,$(U_DEPS_$1)),./build/lib$(LIB).so) | ./build/
|
||||
$(call bcmd,ld,$$@,$(LD) -o $$@ $(U_OBJ_$1) $(U_LDFLAGS_$1))
|
||||
|
||||
all-$1: ./build/$1$(if $(FOR_WINDOWS),.exe)
|
||||
endef
|
||||
$(foreach util,$(UTILS),\
|
||||
$(eval $(call make-util-rules,$(util))))
|
||||
|
||||
# Make an object out of a file.
|
||||
|
||||
define make-util-obj-rules
|
||||
ifeq ($(suffix $(U_OBJDIR)/$1/$2),.c)
|
||||
$(U_OBJDIR)/$1/$2.o: $(U_SRCDIR)/$1/$2 $(U_INC_$1) \
|
||||
| $(dir $(U_OBJDIR)/$1/$2)
|
||||
$(call bcmd,cc,$$@,$(CC) -c -o $$@ $$< $(U_CFLAGS_$1))
|
||||
endif
|
||||
endef
|
||||
$(foreach util,$(UTILS),\
|
||||
$(foreach src,$(U_SRC_$(util)),\
|
||||
$(eval $(call make-util-obj-rules,$(util),$(src)))))
|
||||
|
||||
# Install a utility.
|
||||
|
||||
define make-util-install-rule
|
||||
install-$1 install-$1.exe: $(CHECKCFG)
|
||||
$(call imsg,Installing $1$(if $(FOR_WINDOWS),.exe).)
|
||||
$(call qcmd,$(INSTALL) -m 755 -d "$(IBINDIR)")
|
||||
$(call qcmd,$(INSTALL) -m 755 -t "$(IBINDIR)" $1$(if $(FOR_WINDOWS),.exe))
|
||||
endef
|
||||
|
||||
.PHONY: all-utils $(foreach util,$(UTILS),all-$(util) install-$(util) \
|
||||
install-$(util).exe)
|
||||
|
||||
# ---
|
||||
# Manpages related.
|
||||
# ---
|
||||
|
||||
# Produce the manpages.
|
||||
|
||||
all-man: $(foreach sec,$(M_SECTIONS),\
|
||||
$(M_PAGES_$(sec):%=$(M_MANDIR)/man$(sec)/%.$(sec).gz))
|
||||
|
||||
# Produce one page.
|
||||
|
||||
define make-manpage-rules
|
||||
$(M_MANDIR)/man$1/$2.$1.gz: $(M_MANDIR)/man$1/$2.$1
|
||||
$(call bcmd,gzip,$$<,$(GZIP) $$<)
|
||||
|
||||
$(M_MANDIR)/man$1/$2.$1: $(M_SRCDIR)/$2.$1.txt | $(M_MANDIR)/man$1/
|
||||
$(call bcmd,a2x,$$<,$(A2X) -f manpage -D $$| $$< 2>/dev/null)
|
||||
endef
|
||||
$(foreach sec,$(M_SECTIONS),\
|
||||
$(foreach pg,$(M_PAGES_$(sec)),\
|
||||
$(eval $(call make-manpage-rules,$(sec),$(pg)))))
|
||||
|
||||
# ---
|
||||
# Documentation-related targets.
|
||||
# ---
|
||||
|
||||
.PHONY: install-cfgtool uninstall-cfgtool
|
||||
#*****************************************************************************#
|
||||
# Documentation-related targets #
|
||||
#*****************************************************************************#
|
||||
# Make the HTML documentation.
|
||||
html:
|
||||
make -C docs
|
||||
|
||||
.PHONY: html
|
||||
|
||||
# End of file
|
||||
|
|
295
Makefile.vars
295
Makefile.vars
|
@ -1,71 +1,49 @@
|
|||
#!/usr/bin/make -f
|
||||
#*****************************************************************************#
|
||||
# Include configuration #
|
||||
#*****************************************************************************#
|
||||
# Do it
|
||||
-include Makefile.cfg
|
||||
|
||||
# Correct target
|
||||
# Correct the target.
|
||||
TARGET := $(if $(TARGET),$(TARGET)-)
|
||||
#*****************************************************************************#
|
||||
# Project main information #
|
||||
#*****************************************************************************#
|
||||
# Project name and description
|
||||
NAME := casio
|
||||
DESCRIPTION := Library for manipulating CASIO protocols and file formats.
|
||||
|
||||
# Maintainer information
|
||||
MAINTAINER_NAME := Thomas \"Cakeisalie5\" Touhey
|
||||
# ---
|
||||
# Main information about the project.
|
||||
# ---
|
||||
|
||||
# Name and description.
|
||||
|
||||
NAME := libcasio
|
||||
DESCRIPTION := Library and utils for using CASIO protocols and file formats.
|
||||
|
||||
# Maintainer information.
|
||||
|
||||
MAINTAINER_NAME := Thomas « Cakeisalie5 » Touhey
|
||||
MAINTAINER_MAIL := thomas@touhey.fr
|
||||
|
||||
# Project version
|
||||
MAINTAINER := $(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>
|
||||
|
||||
# Project version.
|
||||
|
||||
MAJOR := 0
|
||||
MINOR := 1
|
||||
INDEV := yes
|
||||
|
||||
# Project version string
|
||||
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
|
||||
#*****************************************************************************#
|
||||
# Project directories #
|
||||
#*****************************************************************************#
|
||||
# Headers directory - where all the headers are.
|
||||
INCDIR := ./include
|
||||
|
||||
# Sources directory - where all the sources are.
|
||||
SRCDIR := ./src
|
||||
# Name of some components.
|
||||
|
||||
# Objects directory - where the objects will be put.
|
||||
OBJDIR := ./obj
|
||||
LIB := casio
|
||||
|
||||
# Documentation directory - where the asciidoc sources for the manpages are.
|
||||
DOCDIR := ./doc
|
||||
# ---
|
||||
# Utilities.
|
||||
# ---
|
||||
|
||||
# Manpages directory - where the manpages will be put.
|
||||
MANDIR := ./man
|
||||
#*****************************************************************************#
|
||||
# Object names #
|
||||
#*****************************************************************************#
|
||||
# Dynamic library name
|
||||
SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR))
|
||||
SONAMES := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.*)
|
||||
# Package configuration.
|
||||
|
||||
# Static library name
|
||||
ANAME := $(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a)
|
||||
ANAMES := lib$(NAME).lib lib$(NAME).a lib$(NAME).dll.a
|
||||
|
||||
# Libs
|
||||
DEPS := libfontcharacter
|
||||
DEPS_PRIV := zlib $(if $(NO_LIBUSB),,libusb-1.0)
|
||||
ALLDEPS := $(DEPS) $(DEPS_PRIV)
|
||||
#*****************************************************************************#
|
||||
# Binary utilities #
|
||||
#*****************************************************************************#
|
||||
# Package configuration
|
||||
PKGCONFIG := $(TARGET)pkg-config
|
||||
|
||||
# Compiler
|
||||
# Compiler.
|
||||
|
||||
CC := $(TARGET)gcc
|
||||
# - Check flags (warnings)
|
||||
|
||||
CWERROR := all extra no-attributes no-unused-macros no-vla no-multichar
|
||||
ifneq ($(MORE_WARNINGS),)
|
||||
CWERROR += shadow write-strings redundant-decls format format-nonliteral \
|
||||
|
@ -74,18 +52,18 @@ ifneq ($(MORE_WARNINGS),)
|
|||
stack-protector no-unused-parameter
|
||||
endif
|
||||
CWARN := $(CWERROR:%=-W%)
|
||||
# - For random manipulations (profiling, ...)
|
||||
#CMOREFLAGS :=
|
||||
# - All C compiling flags
|
||||
|
||||
CFLAGS := -I $(INCDIR) $(CWARN) -std=c99 -pedantic \
|
||||
$(if $(STATIC),-DLIBCASIO_STATIC,-fPIC) $(if $(OPTIMIZE_SIZE),-Os,-O2) \
|
||||
-D LOGLEVEL="casio_loglevel_$(LOG_LEVEL)" \
|
||||
$(shell $(PKGCONFIG) --cflags $(ALLDEPS) 2>/dev/null) \
|
||||
$(CMOREFLAGS)
|
||||
|
||||
# Linker
|
||||
# Linker.
|
||||
|
||||
LD := $(TARGET)gcc
|
||||
# - Specific linker flags
|
||||
|
||||
LDFLAGS := $(if $(STATIC),,-shared) \
|
||||
$(shell $(PKGCONFIG) --libs $(ALLDEPS) 2>/dev/null) -lm
|
||||
ifneq ($(FOR_WINDOWS),)
|
||||
|
@ -96,62 +74,203 @@ else
|
|||
-e lib$(NAME)__version \
|
||||
-Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs)
|
||||
endif
|
||||
#LDMOREFLAGS :=
|
||||
|
||||
LDFLAGS += $(LDMOREFLAGS)
|
||||
|
||||
# Archive manager
|
||||
# Archive manager, directory maker, file copier, file mover,
|
||||
# symbolic link maker, file/folder remover, documentation creator,
|
||||
# installer, gzipper.
|
||||
|
||||
AR := $(TARGET)ar
|
||||
|
||||
# Directory maker
|
||||
MD := mkdir -p
|
||||
# Copier
|
||||
CP := cp
|
||||
# Mover
|
||||
MV := mv
|
||||
# Symbolic link maker
|
||||
LN := ln -sf
|
||||
# File remover
|
||||
RM := rm -f
|
||||
# Documentation creator
|
||||
A2X := a2x
|
||||
# Installer
|
||||
INST := install
|
||||
# GZipper
|
||||
GZIP := gzip -f
|
||||
#*****************************************************************************#
|
||||
# Look up the sources and includes #
|
||||
#*****************************************************************************#
|
||||
# Look up the sources.
|
||||
SRC := $(patsubst $(SRCDIR)/%,%,$(shell find $(SRCDIR) -name "*.c"))
|
||||
DIRS := $(sort $(dir $(SRC)))
|
||||
GZIP := gzip -k -f
|
||||
|
||||
# Look up the includes.
|
||||
INC := $(shell find $(INCDIR) -name "*.h")
|
||||
INCp := $(INC:$(INCDIR)/%=%)
|
||||
# ---
|
||||
# Dependencies definitions.
|
||||
# ---
|
||||
|
||||
# Look up the source includes.
|
||||
INCI := $(shell find $(SRCDIR) -name "*.h")
|
||||
#*****************************************************************************#
|
||||
# Look for manpages #
|
||||
#*****************************************************************************#
|
||||
# Get the manpages sections and contents
|
||||
MAN_SECTIONS :=
|
||||
define check-man
|
||||
MAN_SECTIONS += $1
|
||||
MAN_$1 += $2
|
||||
# libcasio, defined here.
|
||||
|
||||
DEP_libcasio_CFLAGS := -I include
|
||||
DEP_libcasio_LIBS := -L build -lcasio
|
||||
|
||||
# zlib, compression library.
|
||||
|
||||
DEP_zlib_CFLAGS := $(shell $(PKGCONFIG) zlib --cflags)
|
||||
DEP_zlib_LIBS := $(shell $(PKGCONFIG) zlib --libs)
|
||||
|
||||
# libusb, communication library.
|
||||
|
||||
DEP_libusb_CFLAGS := $(shell $(PKGCONFIG) libusb-1.0 --cflags)
|
||||
DEP_libusb_LIBS := $(shell $(PKGCONFIG) libusb-1.0 --libs)
|
||||
|
||||
# imagemagick, for image manipulation.
|
||||
|
||||
DEP_magick_CFLAGS := $(shell $(PKGCONFIG) MagickCore --cflags)
|
||||
DEP_magick_LIBS := $(shell $(PKGCONFIG) MagickCore --libs)
|
||||
|
||||
# SDL, for simple graphical utilities.
|
||||
|
||||
DEP_sdl_CFLAGS := $(shell $(PKGCONFIG) sdl --cflags)
|
||||
DEP_sdl_LIBS := $(shell $(PKGCONFIG) sdl --libs)
|
||||
|
||||
# ---
|
||||
# Informations about the library.
|
||||
# ---
|
||||
|
||||
# Dependencies.
|
||||
|
||||
L_DEPS :=
|
||||
L_DEPS_PRIV := zlib $(if $(NO_LIBUSB),,libusb)
|
||||
|
||||
# Folders.
|
||||
|
||||
L_INCDIR := ./include
|
||||
L_SRCDIR := ./lib
|
||||
L_OBJDIR := ./build/lib
|
||||
|
||||
# Destination (dynamic and static library name).
|
||||
|
||||
L_SONAME := $(if $(FOR_WINDOWS),lib$(LIB).dll,lib$(LIB).so.$(MAJOR))
|
||||
L_SONAMES := ./build/$(if $(FOR_WINDOWS),lib$(LIB).dll,lib$(LIB).so.*)
|
||||
|
||||
L_ANAME := lib$(LIB)$(if $(FOR_WINDOWS),.lib,.a)
|
||||
L_ANAMES := ./build/lib$(LIB).lib ./build/lib$(LIB).a \
|
||||
./build/lib$(LIB).dll.a
|
||||
|
||||
# Files.
|
||||
|
||||
L_SRC := $(patsubst $(L_SRCDIR)/%,%,$(wildcard $(L_SRCDIR)/*.c \
|
||||
$(L_SRCDIR)/**/*.c $(L_SRCDIR)/**/**/*.c $(L_SRCDIR)/**/**/**/*.c))
|
||||
L_OBJ := $(L_SRC:%=$(L_OBJDIR)/%.o)
|
||||
L_OBJDIRS := $(sort $(dir $(L_OBJ)))
|
||||
|
||||
L_INCp := $(patsubst $(L_INCDIR)/%,%,$(wildcard $(L_INCDIR)/*.h \
|
||||
$(L_INCDIR)/**/*.h))
|
||||
L_INC := $(L_INCp:%=$(L_INCDIR)/%) \
|
||||
$(wildcard $(L_SRCDIR)/*.h $(L_SRCDIR)/**/*.h)
|
||||
|
||||
# Flags.
|
||||
|
||||
L_CFLAGS := $(CFLAGS) $(foreach dep,$(L_DEPS) $(L_DEPS_PRIV),\
|
||||
$(DEP_$(dep)_CFLAGS)) -I $(L_INCDIR)
|
||||
L_LIBS := $(foreach dep,$(L_DEPS) $(L_DEPS_PRIV),$(DEP_$(dep)_LIBS))
|
||||
|
||||
L_LDFLAGS := $(if $(STATIC),,-shared) $(L_LIBS)
|
||||
ifneq ($(FOR_WINDOWS),)
|
||||
L_LDFLAGS += -Wl,--out-implib,lib$(NAME).dll.a -lws2_32 -lsetupapi -luuid
|
||||
else
|
||||
L_LDFLAGS += $(if $(STATIC),,"-Wl,-soname,$(L_SONAME)" \
|
||||
-e lib$(LIB)__version "-Wl,-z,relro" "-Wl,-z,combreloc" \
|
||||
-Wl,-z,defs)
|
||||
endif
|
||||
|
||||
# ---
|
||||
# Informations about the utilities.
|
||||
# ---
|
||||
|
||||
# Folders.
|
||||
|
||||
U_SRCDIR := ./src
|
||||
U_OBJDIR := ./build/utils
|
||||
|
||||
# Look for utilities.
|
||||
|
||||
UTILS := $(patsubst $(U_SRCDIR)/%,%,$(wildcard $(U_SRCDIR)/*))
|
||||
|
||||
# Get the dependencies.
|
||||
# `U_DEPS_<util>`: dependencies for util <util>.
|
||||
# `U_DIS_<util>`: if the util is disabled or not.
|
||||
|
||||
define get-util-info
|
||||
U_DEPS_$1 := $(shell make -f $(U_SRCDIR)/$1/vars.mk libs 2>/dev/null)
|
||||
U_DIS_$1 := $(shell make -f $(U_SRCDIR)/$1/vars.mk disable 2>/dev/null \
|
||||
&& echo y)
|
||||
endef
|
||||
$(foreach doc,$(wildcard $(DOCDIR)/*.*.txt),\
|
||||
$(eval $(call check-man,$(patsubst .%,%,$(suffix $(doc))),$(basename $(doc)))))
|
||||
$(foreach util,$(UTILS),\
|
||||
$(eval $(call get-util-info,$(util))))
|
||||
|
||||
# Get the default utilities.
|
||||
|
||||
DEFAULT_UTILS := $(foreach util,$(UTILS),\
|
||||
$(if $(U_DIS_$(util)),,$(util)))
|
||||
|
||||
# Look for the utilities source files and flags.
|
||||
# It is important to not merge this function with the `get-util-info` as
|
||||
# you cannot use a variable defined earlier in such a function, you have
|
||||
# to do a second one.
|
||||
|
||||
define get-util-source
|
||||
U_SRC_$1 := $(patsubst $(U_SRCDIR)/$1/%,%,$(wildcard $(U_SRCDIR)/$1/*.c \
|
||||
$(U_SRCDIR)/$1/**/*.c))
|
||||
U_INC_$1 := $(patsubst $(U_INCDIR)/$1/%,%,$(wildcard $(U_SRCDIR)/$1/*.h \
|
||||
$(U_SRCDIR)/$1/**/*.h))
|
||||
|
||||
U_CFLAGS_$1 := $(CFLAGS) $(foreach dep,$(U_DEPS_$1),$(DEP_$(dep)_CFLAGS)) \
|
||||
-D BIN="$1$(if $(FOR_WINDOWS),.exe)" \
|
||||
-D MAINTAINER="$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" \
|
||||
-D DEFAULT_STORAGE="$(DEFAULT_STORAGE)" \
|
||||
-D DEFAULT_ZOOM="$(DEFAULT_ZOOM)"
|
||||
U_LIBS_$1 := $(foreach dep,$(U_DEPS_$1),$(DEP_$(dep)_LIBS))
|
||||
|
||||
U_LDFLAGS_$1 := $(foreach dep,$(U_DEPS_$1),$(DEP_$(dep)_LIBS))
|
||||
endef
|
||||
define get-util-objects
|
||||
U_OBJ_$1 := $(U_SRC_$1:%=$(U_OBJDIR)/$1/%.o)
|
||||
endef
|
||||
|
||||
$(foreach util,$(UTILS),\
|
||||
$(eval $(call get-util-source,$(util))))
|
||||
$(foreach util,$(UTILS),\
|
||||
$(eval $(call get-util-objects,$(util))))
|
||||
|
||||
# Get the object directories.
|
||||
|
||||
U_OBJDIRS := $(sort $(dir $(foreach util,$(UTILS),\
|
||||
$(U_SRC_$(util):%=$(U_OBJDIR)/$(util)/%))))
|
||||
|
||||
# ---
|
||||
# Manpages.
|
||||
# ---
|
||||
|
||||
# Manpages folder.
|
||||
|
||||
M_SRCDIR := ./man
|
||||
M_MANDIR := ./build/man
|
||||
|
||||
# Get the manpages sections and contents.
|
||||
|
||||
M_SECTIONS :=
|
||||
define check-man
|
||||
M_SECTIONS += $1
|
||||
M_PAGES_$1 += $2
|
||||
endef
|
||||
$(foreach doc,$(wildcard $(M_SRCDIR)/*.*.txt),\
|
||||
$(eval $(call check-man,$(patsubst .%,%,$(suffix $(basename $(doc)))),\
|
||||
$(notdir $(basename $(basename $(doc)))))))
|
||||
|
||||
# Remove duplicate sections.
|
||||
MAN_SECTIONS := $(sort $(MAN_SECTIONS))
|
||||
#*****************************************************************************#
|
||||
# Check for DESTDIR (add as prefix to installation root) #
|
||||
#*****************************************************************************#
|
||||
|
||||
M_SECTIONS := $(sort $(M_SECTIONS))
|
||||
|
||||
# ---
|
||||
# Check for DESTDIR (add as prefix to installation root).
|
||||
# ---
|
||||
|
||||
# Save original library and include dir.
|
||||
|
||||
OIINCDIR := $(IINCDIR)
|
||||
OILIBDIR := $(ILIBDIR)
|
||||
|
||||
# Make it.
|
||||
|
||||
define add-dest-dir
|
||||
$1 = $(DESTDIR)$($1)
|
||||
endef
|
||||
|
|
76
README.md
76
README.md
|
@ -1,76 +0,0 @@
|
|||
# libcasio - Utilities for manipulating CASIO's protocols and file formats
|
||||
## Introduction
|
||||
This is the central library in the P7 project, a project to free software
|
||||
surrounding CASIO calculators. It aims at being able to manage CASIO's
|
||||
proprietary protocols and file formats. It is basically a merge of two
|
||||
libraries of the P7 project: the libp7, which managed protocols, and the
|
||||
libg1m, which managed file formats.
|
||||
|
||||
## Prerequisites
|
||||
Side note : the library might work with older versions of these dependencies,
|
||||
I took these as a reference because these are the ones I work with.
|
||||
|
||||
Because of libusb, the library compiles in C99. Without it, it compiles
|
||||
using C89.
|
||||
|
||||
### Build-only dependencies
|
||||
| Name | Version |
|
||||
| ------------------------------------------------------------------- | -------- |
|
||||
| [make](https://www.gnu.org/software/make/) | >= 4.0 |
|
||||
| [gcc](https://gcc.gnu.org/) | >= 4.9 |
|
||||
| [binutils](https://www.gnu.org/software/binutils/) | >= 2.25 |
|
||||
| [asciidoc](http://asciidoc.org/) | >= 8.6.9 |
|
||||
| [gzip](https://www.gnu.org/software/gzip/) | >= 1.6 |
|
||||
| [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) | any |
|
||||
|
||||
### Build and runtime dependencies
|
||||
| Name | Version |
|
||||
| -------------------------------------------------------------------- | -------- |
|
||||
| [libfontcharacter](https://github.com/PlaneteCasio/libfontcharacter) | >= 1.0 |
|
||||
| [libusb](http://libusb.info/) | >= 1.0 |
|
||||
| [zlib](http://zlib.net/) | >= 1.2.8 |
|
||||
|
||||
## Configuring
|
||||
First of all, the configure script has a help message where all of the
|
||||
options are listed. The defaults should be appropriate for a native build,
|
||||
just `./configure` if that's what you want to do, but you should read at
|
||||
least the next paragraph.
|
||||
|
||||
If you're installing on or packaging for a GNU/Linux distribution, you might
|
||||
want to install the `udev` rule to let the access to the direct calculator
|
||||
connexions to normal users. As calculators can be connected as serial devices,
|
||||
which are attributed to the `uucp` group (on Manjaro GNU/Linux), I chose to
|
||||
attribute the `uucp` group to calculators plugged directly as USB. If you
|
||||
agree with that, just add the `--udev` option to the configuration command
|
||||
line; otherwise, make your own, or make nothing, I don't really care.
|
||||
|
||||
Building for the MS-Windows platform is supported, just use a `-mingw32`
|
||||
target.
|
||||
|
||||
Also, building a static library, for both PC and embedded systems, is
|
||||
supported : just use the `--static` option. If you want to build a static
|
||||
library so that a cross-compiler that uses Microsoft Windows static library
|
||||
formats, add the `--windows` option (notice that for a `-mingw32` target and
|
||||
a dynamic library generation, this option is automatically added).
|
||||
|
||||
## Building and installing
|
||||
Once configuring is done (necessary step), just `make`.
|
||||
To install, use `make install`.
|
||||
|
||||
To build and install only the lib, use `all-lib` then `install-lib`.
|
||||
To build and install only the docs, use `all-doc` and `install-doc`.
|
||||
|
||||
If you ought to package this library, use the `DESTDIR` Makefile variable,
|
||||
e.g. `make install DESTDIR=./package-root`. Do **not** use the `--root`
|
||||
configure options for this, as configure tools (`libp7-config` and the
|
||||
`pkg-config` configuration file) will add what's in the `--root` option value
|
||||
but not in the `DESTDIR` option.
|
||||
|
||||
Other useful targets:
|
||||
|
||||
- `uninstall`, `uninstall-lib`, `uninstall-bin`, `uninstall-doc`:
|
||||
will try to uninstall using the current configuration (experimental);
|
||||
- `mostlyclean`, `clean`, `clean-doc`, `mostlyclean-lib`, `clean-lib`:
|
||||
remove built files at different levels;
|
||||
- `re`, `re-lib`, `re-doc`: regenerate built files at different levels
|
||||
(clean and build) -- useful when configuration is changed.
|
|
@ -0,0 +1,80 @@
|
|||
libcasio - Library and utilitiess for using CASIO's protocols and file formats
|
||||
==============================================================================
|
||||
|
||||
This is the main repository for the P7 project, a project to free software
|
||||
surrounding CASIO calculators. It aims at being able to manage CASIO's
|
||||
proprietary protocols and file formats. It is basically a merge of three
|
||||
subprojects of the P7 project: the libp7, which managed protocols, the
|
||||
libg1m, which managed file formats, and the p7utils, which had the utilities
|
||||
now put in this repository.
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
Side note : the library might work with older versions of these dependencies,
|
||||
I took these as a reference because these are the ones I work with.
|
||||
|
||||
Because of libusb, the library requires C99. Without it, it should compile
|
||||
using C89.
|
||||
|
||||
Build-only dependencies
|
||||
-----------------------
|
||||
|
||||
- `make <https://www.gnu.org/software/make/>`_ (>= 4.0).
|
||||
- `gcc <https://gcc.gnu.org/>`_ (>= 4.9).
|
||||
- `binutils <https://www.gnu.org/software/binutils/>`_ (>= 2.25).
|
||||
- `asciidoc <http://asciidoc.org/>`_ (>= 8.6.9).
|
||||
- `gzip <https://www.gnu.org/software/gzip/>`_ (1.6).
|
||||
- `pkg-config <https://www.freedesktop.org/wiki/Software/pkg-config/>`_.
|
||||
|
||||
Runtime dependencies
|
||||
--------------------
|
||||
|
||||
- `libusb <http://libusb.info/>`_ (>= 1.0).
|
||||
- `zlib <http://zlib.net/>`_ (>= 1.2.8).
|
||||
|
||||
Configuring
|
||||
-----------
|
||||
|
||||
First of all, the configure script has a help message where all of the
|
||||
options are listed. The defaults should be appropriate for a native build,
|
||||
just ``./configure`` if that's what you want to do, but you should read at
|
||||
least the next paragraph.
|
||||
|
||||
If you're installing on or packaging for a GNU/Linux distribution, you might
|
||||
want to install the ``udev`` rule to let the access to the direct calculator
|
||||
connexions to normal users. As calculators can be connected as serial devices,
|
||||
which are attributed to the ``uucp`` group (on Manjaro GNU/Linux), I chose to
|
||||
attribute the ``uucp`` group to calculators plugged directly as USB. If you
|
||||
agree with that, just add the ``--udev`` option to the configuration command
|
||||
line; otherwise, make your own, or make nothing, I don't really care.
|
||||
|
||||
Building for the MS-Windows platform is supported, just use a ``-mingw32``
|
||||
BFD target.
|
||||
|
||||
Also, building a static library, for both PC and embedded systems, is
|
||||
supported : just use the ``--static`` option. If you want to build a static
|
||||
library so that a cross-compiler that uses Microsoft Windows static library
|
||||
formats, add the ``--windows`` option (notice that for a ``-mingw32`` target
|
||||
and a dynamic library generation, this option is automatically added).
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
|
||||
Once configuring is done (necessary step), just ``make``.
|
||||
To install, use ``make install``.
|
||||
|
||||
To build and install only the lib, use ``all-lib`` then ``install-lib``.
|
||||
To build and install only the docs, use ``all-doc`` and ``install-doc``.
|
||||
|
||||
If you ought to package this library, use the ``DESTDIR`` Makefile variable,
|
||||
e.g. ``make install DESTDIR=./package-root``. Do **not** use the ``--root``
|
||||
configure options for this, as configure tools (``libcasio-config`` and the
|
||||
``pkg-config`` configuration file) will add what's in the `--root` option
|
||||
value but not in the ``DESTDIR`` option.
|
||||
|
||||
Other useful targets:
|
||||
|
||||
- ``clean``: remove built files;
|
||||
- ``re``: regenerate built files (clean and build) -- useful when
|
||||
configuration is changed.
|
|
@ -1,9 +1,12 @@
|
|||
#!/bin/sh
|
||||
cd "$(dirname $0)"
|
||||
#*****************************************************************************#
|
||||
# Defaults #
|
||||
#*****************************************************************************#
|
||||
# Project variables
|
||||
|
||||
# ---
|
||||
# Defaults.
|
||||
# ---
|
||||
|
||||
# Project variables.
|
||||
|
||||
[ -f Makefile.cfg ] && mv Makefile.cfg Makefile.cfg.tmp
|
||||
name="$(make -s getname)"
|
||||
version="$(make -s getversion)"
|
||||
|
@ -11,15 +14,18 @@ indev="$(make -s isindev)"
|
|||
maintainer="$(make -s getmaintainer)"
|
||||
[ -f Makefile.cfg.tmp ] && mv Makefile.cfg.tmp Makefile.cfg
|
||||
|
||||
# Platform
|
||||
# Platform.
|
||||
|
||||
platform="$(command -v gcc 1>/dev/null && gcc --print-multiarch)"
|
||||
platform="$([ "$platform" ] && echo "/$platform")"
|
||||
|
||||
# Make options
|
||||
# Make options.
|
||||
|
||||
make_full_log=
|
||||
more_warnings=
|
||||
|
||||
# Build options
|
||||
# Build options.
|
||||
|
||||
target=
|
||||
no_file=
|
||||
no_libusb=
|
||||
|
@ -29,7 +35,11 @@ optimize_size=
|
|||
no_log=
|
||||
loglevel=none # none, info, warn, error, fatal
|
||||
|
||||
# Installation directories
|
||||
default_zoom=8
|
||||
default_storage=fls0
|
||||
|
||||
# Installation directories.
|
||||
|
||||
root=''
|
||||
[ x"$indev" != x ] && prefix='${root}/opt/p7-project' \
|
||||
|| prefix='${root}/usr'
|
||||
|
@ -42,15 +52,19 @@ libdir='${prefix}/lib'"$platform"
|
|||
includedir='${prefix}/include'"$platform"
|
||||
pkgdir='${libdir}/pkgconfig'
|
||||
|
||||
# Installation options
|
||||
# Installation options.
|
||||
|
||||
install_devel=yes
|
||||
|
||||
# Tweaks
|
||||
# Tweaks.
|
||||
|
||||
cflags=
|
||||
ldflags=
|
||||
#*****************************************************************************#
|
||||
# Help message #
|
||||
#*****************************************************************************#
|
||||
|
||||
# ---
|
||||
# Help message.
|
||||
# ---
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
\`configure\` configures ${name} to adapt to systems that aren't mine.
|
||||
|
@ -69,11 +83,15 @@ Build options:
|
|||
--static build a static library (by default, dynamic)
|
||||
--windows build DLLs and .libs instead of ELF and archives
|
||||
--optimize-size optimize size instead of speed
|
||||
|
||||
--no-file do not use the libc FILE interface
|
||||
--no-libusb do not use libusb
|
||||
--no-log disable logging
|
||||
--loglevel=LOGLEVEL default library log level [$loglevel]
|
||||
|
||||
--default-zoom=ZOOM the default zoom for p7screen [$default_zoom]
|
||||
--default-storage=STOR the default storage device for p7 [$default_storage]
|
||||
|
||||
Installation options:
|
||||
--no-devel should not install developement files
|
||||
|
||||
|
@ -97,9 +115,11 @@ Report bugs to ${maintainer}.
|
|||
EOF
|
||||
exit 0
|
||||
}
|
||||
#*****************************************************************************#
|
||||
# Version message #
|
||||
#*****************************************************************************#
|
||||
|
||||
# ---
|
||||
# Version message.
|
||||
# ---
|
||||
|
||||
version() {
|
||||
cat <<EOF
|
||||
${name} configure script v${version}
|
||||
|
@ -111,9 +131,11 @@ FITNESS FOR A PARTICULAR PURPOSE.
|
|||
EOF
|
||||
exit 0
|
||||
}
|
||||
#*****************************************************************************#
|
||||
# Check for help and version #
|
||||
#*****************************************************************************#
|
||||
|
||||
# ---
|
||||
# Check for help and version.
|
||||
# ---
|
||||
|
||||
put_version=
|
||||
put_help=
|
||||
for arg ; do case "$arg" in
|
||||
|
@ -122,9 +144,11 @@ for arg ; do case "$arg" in
|
|||
esac; done
|
||||
[ $put_version ] && version
|
||||
[ $put_help ] && usage
|
||||
#*****************************************************************************#
|
||||
# Parse arguments #
|
||||
#*****************************************************************************#
|
||||
|
||||
# ---
|
||||
# Parse arguments.
|
||||
# ---
|
||||
|
||||
for arg ; do case "$arg" in
|
||||
--make-full-log) make_full_log=yes ;;
|
||||
--maintainer) more_warnings=yes; loglevel=info ;;
|
||||
|
@ -148,6 +172,24 @@ got '$level'"
|
|||
fi
|
||||
# then set
|
||||
loglevel=$level ;;
|
||||
--default-zoom=*)
|
||||
zoom="${arg#*=}"
|
||||
if ! [ $zoom -eq $zoom 2>/dev/null ]; then
|
||||
echo "--default-zoom: a number is expected (got \"$zoom\")" >&2
|
||||
elif [ $zoom -lt 1 ]; then
|
||||
echo "--default-zoom: should be 1 or more (got $zoom)" >&2
|
||||
elif [ $zoom -gt 16 ]; then
|
||||
echo "--default-zoom: should be 16 or less (got $zoom)" >&2
|
||||
else default_zoom=$zoom; fi ;;
|
||||
--default-storage=*)
|
||||
storage="${arg#*=}"
|
||||
# check if 4 chars long
|
||||
if [ ! $(echo "$storage" | wc -c ) -eq 5 ]; then
|
||||
echo "$0: --default-storage: must be 4 characters long"
|
||||
continue
|
||||
fi
|
||||
# then set
|
||||
default_storage="$storage" ;;
|
||||
--no-devel) install_devel= ;;
|
||||
--root=*) root="${arg#*=}" ;;
|
||||
--hprefix=*) hprefix="${arg#*=}" ;;
|
||||
|
@ -161,27 +203,33 @@ CFLAGS=*) cflags="${arg#*=}" ;;
|
|||
LDFLAGS=*) ldflags="${arg#*=}" ;;
|
||||
*) echo "$arg: didn't read" ;;
|
||||
esac; done
|
||||
#*****************************************************************************#
|
||||
# Little things #
|
||||
#*****************************************************************************#
|
||||
# Cross-compilation things
|
||||
|
||||
# ---
|
||||
# Checks and tweaks.
|
||||
# ---
|
||||
|
||||
# Cross-compilation things.
|
||||
|
||||
if [ ! $prefix_set ] && [ $target ]; then
|
||||
prefix="$prefix"/"$target"
|
||||
fi
|
||||
|
||||
# Check MS-Windows targets
|
||||
# Check MS-Windows targets.
|
||||
|
||||
win_target=
|
||||
case "$target" in *-mingw32) if [ ! "$static" ]; then
|
||||
windows=y; win_target=y
|
||||
fi;; esac
|
||||
|
||||
# Evaluate variables
|
||||
# Evaluate variables.
|
||||
|
||||
vars="prefix bindir libdir pkgdir includedir hprefix hbindir"
|
||||
for var in $vars; do
|
||||
eval $var'='$(eval 'echo $'$var)
|
||||
done
|
||||
|
||||
# Check that static and MS-Windows are not asked.
|
||||
|
||||
if [ "$static" ] && [ "$windows" ]; then
|
||||
cat >&2 <<EOF
|
||||
Sadly, there is no equivalent of MSVC's LIB.EXE for GNU/Linux.
|
||||
|
@ -191,6 +239,7 @@ exit 1
|
|||
fi
|
||||
|
||||
# Check that MS-Windows has a target.
|
||||
|
||||
if [ "$windows" ] && [ ! "$target" ]; then
|
||||
cat >&2 <<EOF
|
||||
You have selected the --windows option, but have selected no target.
|
||||
|
@ -200,10 +249,12 @@ EOF
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Check if is on Cygwin
|
||||
# Check if is on Cygwin.
|
||||
|
||||
[ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] && windows=y
|
||||
|
||||
# Check that MS-Windows has a mingw* target.
|
||||
|
||||
if [ "$windows" ] && [ ! "$win_target" ]; then
|
||||
cat >&2 <<EOF
|
||||
You have selected the --windows option, but have not selected a
|
||||
|
@ -215,21 +266,26 @@ If it is not, please reconfigure to use a mingw32/mingw64 toolchain!
|
|||
|
||||
EOF
|
||||
fi
|
||||
#*****************************************************************************#
|
||||
# Create Makefile configuration #
|
||||
#*****************************************************************************#
|
||||
# Clean before
|
||||
|
||||
# ---
|
||||
# Create Makefile configuration.
|
||||
# ---
|
||||
|
||||
# Clean before.
|
||||
|
||||
make mrproper MAKE_FULL_LOG=y 1>/dev/null 2>/dev/null
|
||||
|
||||
# Create the configuration header
|
||||
# Create the configuration header.
|
||||
|
||||
tools/write-header-config --version=${version} \
|
||||
--maintainer="$(echo ${maintainer} | sed 's/"/\\"/g')" \
|
||||
$([ "$no_file" ] && echo --no-file) \
|
||||
$([ "$no_libusb" ] && echo --no-libusb) \
|
||||
$([ "$no_log" ] && echo --no-log) \
|
||||
>include/${name}/config.h
|
||||
>include/libcasio/config.h
|
||||
|
||||
# Do it!
|
||||
|
||||
exec 3>&1 1>Makefile.cfg
|
||||
cat <<EOF
|
||||
#!/usr/bin/make -f
|
||||
|
@ -248,6 +304,8 @@ cat <<EOF
|
|||
OPTIMIZE_SIZE := $optimize_size
|
||||
LOG_LEVEL = $loglevel
|
||||
NO_LIBUSB = $no_libusb
|
||||
DEFAULT_ZOOM := $default_zoom
|
||||
DEFAULT_STORAGE := $default_storage
|
||||
|
||||
# Installation directories
|
||||
HBINDIR = $hbindir
|
||||
|
@ -269,6 +327,7 @@ exec 1>&3 3>&-
|
|||
chmod +x Makefile.cfg
|
||||
|
||||
# Print the end message.
|
||||
|
||||
echo "Configuration loaded, you can make now."
|
||||
|
||||
# End of file.
|
||||
|
|
|
@ -227,6 +227,20 @@ typedef int casio_fs_list_t
|
|||
OF((void *casio__cookie, casio_path_t *casio__path,
|
||||
casio_fs_list_func_t *casio__callback, void *casio__cbcookie));
|
||||
|
||||
/* The `casio_fs_optim` callback is used to optimize the filesystem
|
||||
* (run a defragmentation, …).
|
||||
*
|
||||
* FIXME: we need a `casio_path_t` equivalent to express devices.
|
||||
* On CASIOWIN, the device is expressed as a path node/string (e.g.
|
||||
* "fls0" in \fls0\file.txt), on WINDOWS, it can be expressed as a
|
||||
* letter (e.g. C:), a path from the Local Device \\.\ or
|
||||
* Root Local Device \\?\, or a mount point, and on Linux/Mac, as a
|
||||
* mount point. This is a mess we need to clean up sometime, for now
|
||||
* we're only considering this operation for CASIOWIN. */
|
||||
|
||||
typedef int casio_fs_optim_t
|
||||
OF((void *casio__cookie, const char *device));
|
||||
|
||||
/* And here is the structure with all of the functions.
|
||||
* It is the one used when you want to open a libcasio filesystem interface
|
||||
* abstraction. */
|
||||
|
@ -243,17 +257,21 @@ struct casio_fsfuncs_s {
|
|||
|
||||
casio_fs_list_t *casio_fsfuncs_list;
|
||||
casio_fs_open_t *casio_fsfuncs_open;
|
||||
|
||||
casio_fs_optim_t *casio_fsfuncs_optim;
|
||||
};
|
||||
/* ************************************************************************* */
|
||||
/* Filesystem public functions */
|
||||
/* ************************************************************************* */
|
||||
CASIO_BEGIN_DECLS
|
||||
|
||||
/* Open a custom filesystem. */
|
||||
/* Open a custom filesystem, and close any filesystem. */
|
||||
|
||||
CASIO_EXTERN int CASIO_EXPORT casio_open_fs
|
||||
OF((casio_fs_t **casio__filesystem,
|
||||
void *casio__cookie, const casio_fsfuncs_t *casio__funcs));
|
||||
CASIO_EXTERN int CASIO_EXPORT casio_close_fs
|
||||
OF((casio_fs_t *casio__filesystem));
|
||||
|
||||
/* Manipulate native paths. */
|
||||
|
||||
|
@ -289,6 +307,11 @@ CASIO_EXTERN int CASIO_EXPORT casio_open_nat
|
|||
void *casio__path, casio_off_t casio__size,
|
||||
casio_openmode_t casio__mode));
|
||||
|
||||
/* Optimize the filesystem. */
|
||||
|
||||
CASIO_EXTERN int CASIO_EXPORT casio_optimize
|
||||
OF((casio_fs_t *casio__fs, const char *casio__device));
|
||||
|
||||
CASIO_END_DECLS
|
||||
CASIO_END_NAMESPACE
|
||||
#endif /* LIBCASIO_FS_H */
|
||||
|
|
|
@ -45,7 +45,7 @@ CASIO_BEGIN_NAMESPACE
|
|||
typedef unsigned long casio_mcsfile_type_t;
|
||||
typedef unsigned long casio_mcstype_t;
|
||||
|
||||
# define casio_mcstype_unknown 0x00000000,
|
||||
# define casio_mcstype_unknown 0x00000000
|
||||
|
||||
/* A program. */
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
CASIO_LOCAL casio_fsfuncs_t posix_fs_funcs = {
|
||||
NULL, &casio_make_posix_path, &casio_free_posix_path,
|
||||
&casio_posix_stat, NULL, NULL, NULL,
|
||||
NULL, NULL
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
|
||||
/**
|
|
@ -34,10 +34,15 @@ int CASIO_EXPORT casio_open_fs(casio_fs_t **pfs,
|
|||
int err; casio_fs_t *fs;
|
||||
|
||||
/* Allocate the filesystem. */
|
||||
|
||||
*pfs = malloc(sizeof(casio_fs_t)); fs = *pfs;
|
||||
if (!fs) { err = casio_error_alloc; goto fail; }
|
||||
if (!fs) {
|
||||
err = casio_error_alloc;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Copy the data into it. */
|
||||
|
||||
fs->casio_fs_cookie = cookie;
|
||||
memcpy(&fs->casio_fs_funcs, funcs, sizeof(casio_fsfuncs_t));
|
||||
return (0);
|
||||
|
@ -47,3 +52,28 @@ fail:
|
|||
(*funcs->casio_fsfuncs_close)(cookie);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/**
|
||||
* casio_close_fs:
|
||||
* Close a filesystem.
|
||||
*/
|
||||
|
||||
int CASIO_EXPORT casio_close_fs(casio_fs_t *fs)
|
||||
{
|
||||
casio_fs_close_t *cl;
|
||||
int err = 0;
|
||||
|
||||
if (!fs)
|
||||
return (0);
|
||||
|
||||
/* Call the custom free function for the filesystem content. */
|
||||
|
||||
cl = fs->casio_fs_funcs.casio_fsfuncs_close;
|
||||
if (cl)
|
||||
err = (*cl)(fs->casio_fs_cookie);
|
||||
|
||||
/* Free the element and go! */
|
||||
|
||||
free(fs);
|
||||
return (err);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/* ****************************************************************************
|
||||
* fs/open.c -- open a libcasio filesystem.
|
||||
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
||||
*
|
||||
* This file is part of libcasio.
|
||||
* libcasio 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.0 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* libcasio 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 libcasio; if not, see <http://www.gnu.org/licenses/>.
|
||||
* ************************************************************************* */
|
||||
#include "fs.h"
|
||||
|
||||
/**
|
||||
* casio_optimize:
|
||||
* Optimize a filesystem.
|
||||
*
|
||||
* @arg fs the filesystem.
|
||||
* @arg device the device name.
|
||||
* @return the error code (0 if ok).
|
||||
*/
|
||||
|
||||
int CASIO_EXPORT casio_optimize(casio_fs_t *fs, const char *device)
|
||||
{
|
||||
int err;
|
||||
casio_fs_optim_t *optim;
|
||||
|
||||
/* Get the callback. */
|
||||
|
||||
optim = fs->casio_fs_funcs.casio_fsfuncs_optim;
|
||||
if (!optim)
|
||||
return (casio_error_op);
|
||||
|
||||
/* Just do it. */
|
||||
|
||||
err = (*optim)(fs->casio_fs_cookie, device);
|
||||
return (err);
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
* Send data packet.
|
||||
*
|
||||
* Carries 'raw' data in the context of a command. E.g. file data.
|
||||
* Maximum data size is 256 octets.
|
||||
* Maximum data size is CASIO_SEVEN_MAX_RAWDATA_SIZE (256) octets.
|
||||
*
|
||||
* @arg handle the link handle
|
||||
* @arg total the total number of data packets in trans
|
||||
|
@ -43,8 +43,12 @@ int CASIO_EXPORT casio_seven_send_data_packet(casio_link_t *handle,
|
|||
unsigned int total, unsigned int id,
|
||||
const void *data, unsigned int datasize, int resp)
|
||||
{
|
||||
unsigned char buf[8 + CASIO_SEVEN_MAX_RAWDATA_SIZE];
|
||||
|
||||
if (datasize > CASIO_SEVEN_MAX_RAWDATA_SIZE)
|
||||
return (casio_error_op);
|
||||
|
||||
/* make new buffer */
|
||||
unsigned char buf[8 + datasize];
|
||||
casio_putascii(buf, total, 4);
|
||||
casio_putascii(&buf[4], id, 4);
|
||||
memcpy(&buf[8], data, datasize);
|
|
@ -26,7 +26,8 @@ CASIO_LOCAL casio_fsfuncs_t sevenfs_callbacks = {
|
|||
(casio_fs_freepath_t*)&casio_free_sevenfs_path,
|
||||
NULL, NULL,
|
||||
(casio_fs_del_t*)&casio_sevenfs_delete,
|
||||
NULL, NULL, NULL
|
||||
NULL, NULL, NULL,
|
||||
(casio_fs_optim_t*)&casio_sevenfs_optimize
|
||||
};
|
||||
|
||||
/**
|
|
@ -0,0 +1,42 @@
|
|||
/* ****************************************************************************
|
||||
* link/seven_fs/optimize.c -- optimize a Protocol 7.00 filesystem.
|
||||
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
||||
*
|
||||
* This file is part of libcasio.
|
||||
* libcasio 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.0 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* libcasio 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 libcasio; if not, see <http://www.gnu.org/licenses/>.
|
||||
* ************************************************************************* */
|
||||
#include "seven_fs.h"
|
||||
|
||||
/**
|
||||
* casio_sevenfs_optimize:
|
||||
* Optimize a Protocol 7.00 filesystem.
|
||||
*
|
||||
* @arg cookie the cookie.
|
||||
* @return the error code (0 if ok).
|
||||
*/
|
||||
|
||||
int CASIO_EXPORT casio_sevenfs_optimize(sevenfs_cookie_t *cookie,
|
||||
const char *device)
|
||||
{
|
||||
int err; casio_link_t *handle = cookie;
|
||||
|
||||
msg((ll_info, "Sending the optimize command."));
|
||||
err = casio_seven_send_cmdfls_opt(handle, device);
|
||||
if (err)
|
||||
return (err);
|
||||
if (response.casio_seven_packet_type != casio_seven_type_ack)
|
||||
return (casio_error_unknown);
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -46,4 +46,9 @@ CASIO_EXTERN void CASIO_EXPORT casio_free_sevenfs_path
|
|||
CASIO_EXTERN int CASIO_EXPORT casio_sevenfs_delete
|
||||
OF((sevenfs_cookie_t *casio__cookie, sevenfs_path_t *casio__path));
|
||||
|
||||
/* Optimize the filesystem. */
|
||||
|
||||
CASIO_EXTERN int CASIO_EXPORT casio_sevenfs_optimize
|
||||
OF((sevenfs_cookie_t *casio__cookie, const char *casio__device));
|
||||
|
||||
#endif /* LOCAL_LINK_SEVEN_FS_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue