From a867dfc296334421ca3fea390c2050ad702afb00 Mon Sep 17 00:00:00 2001 From: Lailouezzz Date: Fri, 3 Jan 2020 00:35:06 +0100 Subject: [PATCH] FIX : STATIC compilation work --- Makefile | 6 +-- Makefile.vars | 4 +- src/cafix/vars.mk | 2 + src/g1a-wrapper/vars.mk | 4 +- src/mcsfile/vars.mk | 2 + src/p7/main.c | 83 ++++++++++++++++++++++++++++++++++------- src/p7/vars.mk | 2 + src/p7os/vars.mk | 2 + src/p7screen/vars.mk | 4 +- 9 files changed, 89 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 031f31a..760e171 100755 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/Makefile.vars b/Makefile.vars index 4f077b7..d456713 100755 --- a/Makefile.vars +++ b/Makefile.vars @@ -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_`: 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 diff --git a/src/cafix/vars.mk b/src/cafix/vars.mk index ce38114..9a95ead 100755 --- a/src/cafix/vars.mk +++ b/src/cafix/vars.mk @@ -1,4 +1,6 @@ #!/usr/bin/make -f disable: +libs_static: + @echo libusb libcasio libs: @echo libcasio diff --git a/src/g1a-wrapper/vars.mk b/src/g1a-wrapper/vars.mk index a4cdc31..9a95ead 100644 --- a/src/g1a-wrapper/vars.mk +++ b/src/g1a-wrapper/vars.mk @@ -1,4 +1,6 @@ #!/usr/bin/make -f disable: +libs_static: + @echo libusb libcasio libs: - @echo libcasio magick + @echo libcasio diff --git a/src/mcsfile/vars.mk b/src/mcsfile/vars.mk index 41148b4..5964b3b 100755 --- a/src/mcsfile/vars.mk +++ b/src/mcsfile/vars.mk @@ -1,4 +1,6 @@ #!/usr/bin/make -f #disable: +libs_static: + @echo math zlib libusb libcasio libs: @echo libcasio diff --git a/src/p7/main.c b/src/p7/main.c index dd16ba1..8b3797f 100644 --- a/src/p7/main.c +++ b/src/p7/main.c @@ -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; diff --git a/src/p7/vars.mk b/src/p7/vars.mk index 41148b4..6a15849 100755 --- a/src/p7/vars.mk +++ b/src/p7/vars.mk @@ -1,4 +1,6 @@ #!/usr/bin/make -f #disable: +libs_static: + @echo libusb libcasio libs: @echo libcasio diff --git a/src/p7os/vars.mk b/src/p7os/vars.mk index 372e49b..660d307 100755 --- a/src/p7os/vars.mk +++ b/src/p7os/vars.mk @@ -1,3 +1,5 @@ #!/usr/bin/make -f +libs_static: + @echo libusb libcasio libs: @echo libcasio diff --git a/src/p7screen/vars.mk b/src/p7screen/vars.mk index 1aea089..a320ec3 100755 --- a/src/p7screen/vars.mk +++ b/src/p7screen/vars.mk @@ -1,4 +1,6 @@ #!/usr/bin/make -f #disable: +libs_static: + @echo sdl libusb libcasio libs: - @echo libcasio sdl + @echo libcasio