FIX : STATIC compilation work

This commit is contained in:
Lailouezzz 2020-01-03 00:35:06 +01:00
parent 26c31947e1
commit a867dfc296
Signed by: Lailouezzz
GPG Key ID: 03FCE8A99EF8482C
9 changed files with 89 additions and 20 deletions

View File

@ -130,8 +130,8 @@ 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 $@ $^)
./build/$(L_ANAME): $(L_SRC:%=$(L_OBJDIR)/%.o)
$(call bcmd,ar rc,$(L_ANAME),$(AR) rcs $@ $^)
# Make an object out of a source file.
@ -176,7 +176,7 @@ $(eval $(call make-obj-rule,$(src))))
$(call imsg,Installing the library.)
$(call qcmd,$(INST) -m 755 -d "$(ILIBDIR)")
$(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" $(if $(STATIC),\
./build/$(if $(FOR_WINDOWS),lib$(LIB).lib,lib$(LIB).a),\
./build/$(if $(FOR_WINDOWS),lib$(LIB).lib,$(L_ANAME)),\
./build/$(if $(FOR_WINDOWS),lib$(LIB).dll.a,$(L_SONAME))))
install-lib-dll:

View File

@ -150,7 +150,7 @@ endif
L_ANAMES := ./build/lib$(LIB).lib ./build/lib$(LIB).a \
./build/lib$(LIB).dll.a
L_AS_DEP := $(if $(STATIC),$(L_ANAME),$(if \
L_AS_DEP := $(if $(STATIC),./build/$(L_ANAME),$(if \
$(FOR_WINDOWS),./build/$(L_SONAME),./build/lib$(LIB).so))
# Files.
@ -198,7 +198,7 @@ endif
# `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_DEPS_$1 := $(shell make -f $(U_SRCDIR)/$1/vars.mk $(if $(STATIC), libs_static, libs) 2>/dev/null)
U_DIS_$1 := $(shell make -f $(U_SRCDIR)/$1/vars.mk disable 2>/dev/null \
&& echo y)
endef

View File

@ -1,4 +1,6 @@
#!/usr/bin/make -f
disable:
libs_static:
@echo libusb libcasio
libs:
@echo libcasio

View File

@ -1,4 +1,6 @@
#!/usr/bin/make -f
disable:
libs_static:
@echo libusb libcasio
libs:
@echo libcasio magick
@echo libcasio

View File

@ -1,4 +1,6 @@
#!/usr/bin/make -f
#disable:
libs_static:
@echo math zlib libusb libcasio
libs:
@echo libcasio

View File

@ -209,6 +209,69 @@ static void print_file_info(void *cookie,
puts(buf);
}
/**
* parse_path:
* Parse a path str.
* Make sure ppath point to a casio_path_t structure initialized to 0.
*
* @arg pathstr the C str to parse
* @arg flags the path flags
* @arg ppath the pointer to the path structure (modified)
* @return return 0 if okey
*/
static int parse_path(const char *pathstr, unsigned int flags, casio_path_t *ppath)
{
int err = 0;
const char *strfnode = pathstr; int lstrfnode = 0;
const char *strsnode = NULL; int lstrsnode = 0;
/* error operands if pointer NULL */
if (ppath == NULL) {
err = casio_error_op;
goto fail;
}
/* check strfnode size */
for (lstrfnode = 0; strfnode[lstrfnode] != '/' && strfnode[lstrfnode] != '\0'; lstrfnode++)
{ }
/* if there is a file into a dir check that */
if (strfnode[lstrfnode] == '/' && strfnode[lstrfnode+1] != '\0') {
strsnode = strfnode + lstrfnode + 1;
/* check lstrsnode size */
for (lstrsnode = 0; strsnode[lstrsnode] != '\0'; lstrsnode++)
{ }
}
/* check the sizes */
if (lstrfnode > 12 || lstrsnode > 12) {
err = casio_error_op;
goto fail;
}
ppath->casio_path_nodes = NULL;
/* make first node */
if(lstrfnode != 0) {
casio_make_pathnode(&ppath->casio_path_nodes, lstrfnode);
memcpy(ppath->casio_path_nodes->casio_pathnode_name, strfnode, lstrfnode);
}
/* make second node if we have dir */
if (strsnode && lstrsnode != 0) {
casio_make_pathnode(&ppath->casio_path_nodes->casio_pathnode_next, lstrsnode);
memcpy(ppath->casio_path_nodes->casio_pathnode_next->casio_pathnode_name, strsnode, lstrsnode);
}
/* finaly write the flags */
ppath->casio_path_flags = flags;
fail:
return (err);
}
/* ---
* Main function.
* --- */
@ -313,17 +376,12 @@ int main(int ac, char **av)
err = casio_reset(handle, args.storage);
break;
#endif
case mn_get: // TODO : implement get file into a dir
// Initialize the path
case mn_get:
/* Initialize the path */
path.casio_path_device = args.storage;
parse_path(args.filename, casio_pathflag_rel, &path);
// Make the node
casio_make_pathnode(&path.casio_path_nodes, strlen(args.filename));
memcpy(path.casio_path_nodes->casio_pathnode_name, args.filename, strlen(args.filename));
// Set flags
path.casio_path_flags = casio_pathflag_rel;
// Open 7.00 fs and open file in read only
/* Open 7.00 fs and open file in read only */
if ((err = casio_open_seven_fs(&fs, handle))
|| (err = casio_open(fs, &fileStream, &path, 0, CASIO_OPENMODE_READ)))
break;
@ -354,12 +412,11 @@ int main(int ac, char **av)
break;
case mn_list:
// Initialize the path
/* Initialize the path */
path.casio_path_device = args.storage;
path.casio_path_nodes = NULL;
path.casio_path_flags = casio_pathflag_rel;
parse_path("", casio_pathflag_rel, &path);
// Open 7.00 fs and list
/* Open 7.00 fs and list */
if ((err = casio_open_seven_fs(&fs, handle))
|| (err = casio_list(fs, &path, print_file_info, NULL)))
break;

View File

@ -1,4 +1,6 @@
#!/usr/bin/make -f
#disable:
libs_static:
@echo libusb libcasio
libs:
@echo libcasio

View File

@ -1,3 +1,5 @@
#!/usr/bin/make -f
libs_static:
@echo libusb libcasio
libs:
@echo libcasio

View File

@ -1,4 +1,6 @@
#!/usr/bin/make -f
#disable:
libs_static:
@echo sdl libusb libcasio
libs:
@echo libcasio sdl
@echo libcasio