ZDS-II Object file relocations

tools/zds/zdsgen.c:  Remove this program.  It should have been a simpler way to manage ZDS-II compiler and assember differences.  However, the compiler arguments needed to pass through too many layers of bash command line modifications and, as a result, it was not possible to retain quotes on critical strings.  This approch was abandoned for an alternative approach.

boards/z80/ez80/scripts/eZ80_Config.mk:  Add definitions to move the object files as necessary.  This seems to work well and is implemented for both native and Cygwin Windows build -- but only for the Z20x.
This commit is contained in:
Gregory Nutt
2020-02-24 11:25:11 -06:00
committed by Alan Carvalho de Assis
parent d74ca3ab82
commit 75be4c5677
5 changed files with 51 additions and 736 deletions
+36 -29
View File
@@ -47,57 +47,63 @@ endef
# lie in a lower directory, but lies in the current directory and is # lie in a lower directory, but lies in the current directory and is
# handled within COMPILE and ASSEMBLE. # handled within COMPILE and ASSEMBLE.
define RMOBJS
$(call DELFILE, $(1))
$(call DELFILE, $(subst .obj,.lst,$(1)))
$(call DELFILE, $(subst .obj,.src,$(1)))
endef
ifeq ($(CONFIG_WINDOWS_NATIVE),y) ifeq ($(CONFIG_WINDOWS_NATIVE),y)
define CONDMOVE
$(Q) if not exist $1 (move /Y $2 $3)
endef
define MVOBJS
$(call CONDMOVE, $(1),$(subst .obj,.src,$(2)),$(subst .obj,.src,$(3)))
$(call CONDMOVE, $(1),$(subst .obj,.lst,$(2)),$(subst .obj,.lst,$(3)))
$(call CONDMOVE, $(1),$(2),$(3))
endef
define COMPILE define COMPILE
$(call DELFILE, $(2)) $(call RMOBJS, $(2))
$(Q) $(CC) $(CFLAGS) $($(strip $(1))_CFLAGS) ${shell echo $(1) | sed -e "s/\//\\/g"} $(Q) $(CC) $(CFLAGS) $($(strip $(1))_CFLAGS) ${shell echo $(1) | sed -e "s/\//\\/g"}
if not exist $(2) $(call MOVEFILE, $(subst .c,.obj,$(1)), $(2)) $(call MVOBJS, $(2), $(subst .c,.obj,$(notdir $(1))), $(2))
endef endef
define ASSEMBLE define ASSEMBLE
$(call DELFILE, $(2)) $(call RMOBJS, $(2))
$(Q) $(AS) $(AFLAGS) $($(strip $(1))_AFLAGS) ${shell echo $(1) | sed -e "s/\//\\/g"} $(Q) $(AS) $(AFLAGS) $($(strip $(1))_AFLAGS) ${shell echo $(1) | sed -e "s/\//\\/g"}
if not exist $(2) $(call MOVEFILE, $(subst .asm,.obj,$(1)), $(2)) $(call MVOBJS, $(2), $(subst .asm,.obj,$(notdir $(1))), $(2))
endef endef
else else
define CONDMOVE
$(Q) if [ ! -e $(1) ]; then mv -f $(2) $(3) ; fi
endef
define MVOBJS
$(call CONDMOVE, $(1),$(subst .obj,.src,$(2)),$(subst .obj,.src,$(3)))
$(call CONDMOVE, $(1),$(subst .obj,.lst,$(2)),$(subst .obj,.lst,$(3)))
$(call CONDMOVE, $(1),$(2),$(3))
endef
define COMPILE define COMPILE
$(call DELFILE, $(2)) $(call RMOBJS, $(2))
$(Q) $(CC) $(CFLAGS) $($(strip $(1))_CFLAGS) `cygpath -w "$(1)"` $(Q) $(CC) $(CFLAGS) $($(strip $(1))_CFLAGS) `cygpath -w "$(1)"`
$(Q) ( \ $(call MVOBJS, $(2), $(subst .c,.obj,$(notdir $(1))), $(2))
__rename=`basename $(2)` ;\
if [ ! -e $${__rename} ] ; then \
__src=`basename $(1) | cut -d'.' -f1` ; \
__dest=`echo $(2) | sed -e "s/.obj//g"` ; \
mv -f $${__src}.obj $(2) ; \
mv -f $${__src}.lst $${__dest}.lst ; \
mv -f $${__src}.src $${__dest}.src ; \
fi ; \
)
endef endef
define ASSEMBLE define ASSEMBLE
$(call DELFILE, $(2)) $(call RMOBJS, $(2))
$(Q) $(AS) $(AFLAGS) $($(strip $(1))_AFLAGS) `cygpath -w "$(1)"` $(Q) $(AS) $(AFLAGS) $($(strip $(1))_AFLAGS) `cygpath -w "$(1)"`
$(Q) ( \ $(call MVOBJS, $(2), $(subst .asm,.obj,$(notdir $(1))), $(2))
__rename=`basename $(2)` ; \
if [ ! -e $${__rename} ] ; then \
__src=`basename $(1) | cut -d'.' -f1` ; \
__dest=`echo $(2) | sed -e "s/.obj//g"` ; \
mv -f $${__src}.obj $(2) ; \
mv -f $${__src}.lst $${__dest}.lst ; \
mv -f $${__src}.src $${__dest}.src ; \
fi ; \
)
endef endef
endif endif
define MOVEOBJ define MOVEOBJ
$(call MOVEFILE, "$(1).obj", "$(2)$(DELIM)$(1).obj")
$(call MOVEFILE, "$(1).lst", "$(2)$(DELIM)$(1).lst")
$(call MOVEFILE, "$(1).src", "$(2)$(DELIM)$(1).src")
endef endef
# ARCHIVE will move a list of object files into the library. This is # ARCHIVE will move a list of object files into the library. This is
@@ -142,4 +148,5 @@ endef
define CLEAN define CLEAN
$(Q) rm -f *.obj *.src *.lib *.hex *.lod *.lst $(Q) rm -f *.obj *.src *.lib *.hex *.lod *.lst
endef endef
endif endif
+1 -6
View File
@@ -50,7 +50,7 @@ endif
# Targets # Targets
all: zdsar.exe zdsgen.exe all: zdsar.exe
default: all default: all
.PHONY: clean .PHONY: clean
@@ -64,11 +64,6 @@ CFLAGS += -DHAVE_STRTOK_C=1
zdsar.exe: zdsar.c zdsar.exe: zdsar.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o zdsar.exe zdsar.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o zdsar.exe zdsar.c
# zdsgen - Wrapper for the ZDS-II compiler and assembler
zdsgen.exe: zdsgen.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o zdsgen.exe zdsgen.c
clean: clean:
@rm -f *.o *.a *.dSYM *~ .*.swp @rm -f *.o *.a *.dSYM *~ .*.swp
@rm -f zdsar zdsar.exe @rm -f zdsar zdsar.exe
+2 -1
View File
@@ -7,5 +7,6 @@ tools/zds/zdsar.c: This is a wrapper around the ZDS_II librarian. It
the build files but it also improves performance and, more importantly,i the build files but it also improves performance and, more importantly,i
provides a common solution for the Windows native build case. provides a common solution for the Windows native build case.
This tool should work with all ZDS-II based platforms including z8, zNeo, and ez80. These tools should work with all ZDS-II based platforms including z8, zNeo,
and ez80.
+12 -12
View File
@@ -115,7 +115,7 @@ static char g_initial_wd[MAX_PATH]; /* Initial working directory */
static char g_path[MAX_PATH]; /* Buffer for expanding paths */ static char g_path[MAX_PATH]; /* Buffer for expanding paths */
static char g_objpath[MAX_PATH]; /* Temporary for path generation */ static char g_objpath[MAX_PATH]; /* Temporary for path generation */
#ifdef HOST_CYGWIN #ifdef HOST_CYGWIN
static char g_expand[MAX_EXPAND]; /* Temporary for expanded path */ static char g_expand[MAX_EXPAND]; /* Temporary for quoted path */
static char g_dequoted[MAX_PATH]; /* Temporary for de-quoted path */ static char g_dequoted[MAX_PATH]; /* Temporary for de-quoted path */
static char g_hostpath[MAX_PATH]; /* Temporary for host path conversions */ static char g_hostpath[MAX_PATH]; /* Temporary for host path conversions */
#endif #endif
@@ -231,7 +231,7 @@ static void append(char **base, char *str)
*base = newbase; *base = newbase;
} }
static const char *do_expand(const char *argument) static const char *quote_backslash(const char *argument)
{ {
#ifdef HOST_CYGWIN #ifdef HOST_CYGWIN
const char *src; const char *src;
@@ -254,7 +254,7 @@ static const char *do_expand(const char *argument)
break; break;
} }
/* Already expanded? */ /* Already quoted? */
if (*src == '\\') if (*src == '\\')
{ {
@@ -767,10 +767,10 @@ static void do_archive(void)
if (g_arflags != NULL) if (g_arflags != NULL)
{ {
const char *expanded; const char *quoted;
expanded = do_expand(g_arflags); quoted = quote_backslash(g_arflags);
cmdlen += strlen(expanded); cmdlen += strlen(quoted);
if (cmdlen >= MAX_BUFFER) if (cmdlen >= MAX_BUFFER)
{ {
@@ -779,7 +779,7 @@ static void do_archive(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcat(g_command, expanded); strcat(g_command, quoted);
} }
/* Add each object file. This loop will continue until each path has been /* Add each object file. This loop will continue until each path has been
@@ -789,7 +789,7 @@ static void do_archive(void)
nobjects = 0; nobjects = 0;
while ((object = strtok_r(objects, " ", &lasts)) != NULL) while ((object = strtok_r(objects, " ", &lasts)) != NULL)
{ {
const char *expanded; const char *quoted;
const char *converted; const char *converted;
/* Set objects to NULL. This will force strtok_r to move from the /* Set objects to NULL. This will force strtok_r to move from the
@@ -887,8 +887,8 @@ static void do_archive(void)
pathlen = 4; /* For =-+ and terminator */ pathlen = 4; /* For =-+ and terminator */
expanded = do_expand(g_path); quoted = quote_backslash(g_path);
pathlen += strlen(expanded); pathlen += strlen(quoted);
/* Get the full length */ /* Get the full length */
@@ -899,14 +899,14 @@ static void do_archive(void)
{ {
fprintf(stderr, "ERROR: object argument is too long [%d/%d]: " fprintf(stderr, "ERROR: object argument is too long [%d/%d]: "
"%s=-+%s\n", "%s=-+%s\n",
totallen, MAX_BUFFER, g_libname, expanded); totallen, MAX_BUFFER, g_libname, quoted);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Append the next librarian command */ /* Append the next librarian command */
pathlen = snprintf(&g_command[cmdlen], MAX_BUFFER - cmdlen, "%s=-+%s", pathlen = snprintf(&g_command[cmdlen], MAX_BUFFER - cmdlen, "%s=-+%s",
g_libname, expanded); g_libname, quoted);
cmdlen += pathlen; cmdlen += pathlen;
/* Terminate early if we have a LOT files in the command line */ /* Terminate early if we have a LOT files in the command line */
-688
View File
File diff suppressed because it is too large Load Diff