mirror of
https://github.com/cc65/cc65.git
synced 2025-04-02 09:29:35 +00:00
Replaced builtin linker configs with ordinary .cfg files.
The benefits are: - Independency of ld65 build from perl - More transparent behaviour
This commit is contained in:
parent
4757642a12
commit
37c492b544
@ -151,27 +151,27 @@ static const TargetEntry TargetMap[] = {
|
||||
|
||||
/* Table with target properties by target id */
|
||||
static const TargetProperties PropertyTable[TGT_COUNT] = {
|
||||
{ "none", CPU_6502, CTNone },
|
||||
{ "module", CPU_6502, CTNone },
|
||||
{ "atari", CPU_6502, CTAtari },
|
||||
{ "vic20", CPU_6502, CTPET },
|
||||
{ "c16", CPU_6502, CTPET },
|
||||
{ "c64", CPU_6502, CTPET },
|
||||
{ "c128", CPU_6502, CTPET },
|
||||
{ "plus4", CPU_6502, CTPET },
|
||||
{ "cbm510", CPU_6502, CTPET },
|
||||
{ "cbm610", CPU_6502, CTPET },
|
||||
{ "pet", CPU_6502, CTPET },
|
||||
{ "bbc", CPU_6502, CTNone },
|
||||
{ "apple2", CPU_6502, CTNone },
|
||||
{ "apple2enh", CPU_65C02, CTNone },
|
||||
{ "geos-cbm", CPU_6502, CTNone },
|
||||
{ "geos-apple", CPU_65C02, CTNone },
|
||||
{ "lunix", CPU_6502, CTNone },
|
||||
{ "atmos", CPU_6502, CTNone },
|
||||
{ "nes", CPU_6502, CTNone },
|
||||
{ "supervision", CPU_65SC02, CTNone },
|
||||
{ "lynx", CPU_65C02, CTNone },
|
||||
{ "none", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "module", CPU_6502, BINFMT_O65, CTNone },
|
||||
{ "atari", CPU_6502, BINFMT_BINARY, CTAtari },
|
||||
{ "vic20", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "c16", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "c64", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "c128", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "plus4", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "cbm510", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "cbm610", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "pet", CPU_6502, BINFMT_BINARY, CTPET },
|
||||
{ "bbc", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "apple2", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "apple2enh", CPU_65C02, BINFMT_BINARY, CTNone },
|
||||
{ "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone },
|
||||
{ "lunix", CPU_6502, BINFMT_O65, CTNone },
|
||||
{ "atmos", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "nes", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "supervision", CPU_65SC02, BINFMT_BINARY, CTNone },
|
||||
{ "lynx", CPU_65C02, BINFMT_BINARY, CTNone },
|
||||
};
|
||||
|
||||
/* Target system */
|
||||
|
@ -81,14 +81,17 @@ typedef struct TargetProperties TargetProperties;
|
||||
struct TargetProperties {
|
||||
const char Name[12]; /* Name of the target */
|
||||
cpu_t DefaultCPU; /* Default CPU for this target */
|
||||
unsigned char BinFmt; /* Default binary format for this target */
|
||||
const unsigned char* CharMap; /* Character translation table */
|
||||
};
|
||||
|
||||
/* Target system */
|
||||
extern target_t Target;
|
||||
|
||||
/* Table with default CPUs per target */
|
||||
extern const cpu_t DefaultCPU[TGT_COUNT];
|
||||
/* Types of available output formats */
|
||||
#define BINFMT_DEFAULT 0 /* Default (binary) */
|
||||
#define BINFMT_BINARY 1 /* Straight binary format */
|
||||
#define BINFMT_O65 2 /* Andre Fachats o65 format */
|
||||
|
||||
|
||||
|
||||
|
@ -33,6 +33,10 @@
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "target.h"
|
||||
|
||||
/* ld65 */
|
||||
#include "error.h"
|
||||
#include "binfmt.h"
|
||||
|
||||
|
@ -44,11 +44,6 @@
|
||||
|
||||
|
||||
|
||||
/* Types of available output formats */
|
||||
#define BINFMT_DEFAULT 0 /* Default (binary) */
|
||||
#define BINFMT_BINARY 1 /* Straight binary format */
|
||||
#define BINFMT_O65 2 /* Andre Fachats o65 format */
|
||||
|
||||
/* Default format (depends on target system) */
|
||||
extern unsigned char DefaultBinFmt;
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Check number of params
|
||||
die "Usage: cvt-cfg.pl input output varname\n" unless ($#ARGV == 2);
|
||||
|
||||
# Get the parameters
|
||||
$InputName = shift (@ARGV);
|
||||
$OutputName = shift (@ARGV);
|
||||
$VarName = shift (@ARGV);
|
||||
|
||||
# Open both files
|
||||
open (IN, "<$InputName") or die "Cannot open $InputName\n";
|
||||
open (OUT, ">$OutputName") or die "Cannot open $OutputName\n";
|
||||
|
||||
# Print the header to the output file
|
||||
print OUT "static const char $VarName [] = \n";
|
||||
|
||||
# Read from input, print to output
|
||||
while ($Line = <IN>) {
|
||||
|
||||
# Remove the newline
|
||||
chomp $Line;
|
||||
|
||||
# Separate an existing comment. No need to be overly clever, just ignore
|
||||
# hash marks in strings.
|
||||
if ($Line =~ /(.*?)(\s*)(\#\s*)(.*?)\s*$/) {
|
||||
$Line = $1;
|
||||
$CommentSpace = $2;
|
||||
$Comment = $4;
|
||||
} else {
|
||||
$CommentSpace = "";
|
||||
$Comment = "";
|
||||
}
|
||||
|
||||
# Remove leading and trailing spaces
|
||||
$Line =~ s/^\s*|\s*$//g;
|
||||
|
||||
# Replace control chars
|
||||
$Line =~ s/\\/\\\\/g;
|
||||
$Line =~ s/\"/\\\"/g;
|
||||
$Line =~ s/\'/\\\'/g;
|
||||
|
||||
# Print to output
|
||||
print OUT "\"$Line\\n\"";
|
||||
|
||||
# Add a comment if we have one
|
||||
if ($Comment ne "") {
|
||||
print OUT "$CommentSpace/* $Comment */";
|
||||
}
|
||||
|
||||
# Terminate the line
|
||||
print OUT "\n";
|
||||
}
|
||||
|
||||
# Terminate the variable declaration
|
||||
print OUT ";\n";
|
||||
|
||||
# Close the files
|
||||
close IN;
|
||||
close OUT;
|
||||
|
||||
# Done
|
||||
exit 0;
|
||||
|
||||
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "check.h"
|
||||
#include "print.h"
|
||||
#include "segdefs.h"
|
||||
#include "target.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xsprintf.h"
|
||||
|
||||
|
@ -67,7 +67,6 @@
|
||||
#include "scanner.h"
|
||||
#include "segments.h"
|
||||
#include "spool.h"
|
||||
#include "tgtcfg.h"
|
||||
#include "tpool.h"
|
||||
|
||||
|
||||
@ -326,21 +325,6 @@ static void OptDefine (const char* Opt attribute ((unused)), const char* Arg)
|
||||
|
||||
|
||||
|
||||
static void OptDumpConfig (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Dump a builtin linker configuration */
|
||||
{
|
||||
/* Map the given target name to its id */
|
||||
target_t T = FindTarget (Arg);
|
||||
if (T == TGT_UNKNOWN) {
|
||||
Error ("Target system `%s' is unknown", Arg);
|
||||
}
|
||||
|
||||
/* Dump the builtin configuration */
|
||||
DumpBuiltinConfig (stdout, T);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void OptEndGroup (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
/* End a library group */
|
||||
@ -486,7 +470,8 @@ static void OptStartGroup (const char* Opt attribute ((unused)),
|
||||
static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Set the target system */
|
||||
{
|
||||
const TargetDesc* D;
|
||||
StrBuf FileName = STATIC_STRBUF_INITIALIZER;
|
||||
char* PathName;
|
||||
|
||||
/* Map the target name to a target id */
|
||||
Target = FindTarget (Arg);
|
||||
@ -494,14 +479,25 @@ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
|
||||
Error ("Invalid target name: `%s'", Arg);
|
||||
}
|
||||
|
||||
/* Get the target description record */
|
||||
D = &Targets[Target];
|
||||
/* Set the target binary format */
|
||||
DefaultBinFmt = GetTargetProperties (Target)->BinFmt;
|
||||
|
||||
/* Set the target data */
|
||||
DefaultBinFmt = D->BinFmt;
|
||||
CfgSetBuf (D->Cfg);
|
||||
/* Build config file name from target name */
|
||||
SB_CopyStr (&FileName, GetTargetName (Target));
|
||||
SB_AppendStr (&FileName, ".cfg");
|
||||
SB_Terminate (&FileName);
|
||||
|
||||
/* Read the target config */
|
||||
/* Search for the file */
|
||||
PathName = SearchFile (CfgSearchPath, SB_GetBuf (&FileName));
|
||||
if (PathName == 0) {
|
||||
Error ("Cannot find config file `%s'", SB_GetBuf (&FileName));
|
||||
}
|
||||
|
||||
/* Free file name memory */
|
||||
SB_Done (&FileName);
|
||||
|
||||
/* Read the file */
|
||||
CfgSetName (PathName);
|
||||
CfgRead ();
|
||||
}
|
||||
|
||||
@ -527,7 +523,6 @@ int main (int argc, char* argv [])
|
||||
{ "--config", 1, OptConfig },
|
||||
{ "--dbgfile", 1, OptDbgFile },
|
||||
{ "--define", 1, OptDefine },
|
||||
{ "--dump-config", 1, OptDumpConfig },
|
||||
{ "--end-group", 0, OptEndGroup },
|
||||
{ "--force-import", 1, OptForceImport },
|
||||
{ "--help", 0, OptHelp },
|
||||
|
@ -23,9 +23,6 @@ override CFLAGS += -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD
|
||||
EBIND = emxbind
|
||||
LDFLAGS =
|
||||
|
||||
# Perl script for config file conversion
|
||||
CVT=cfg/cvt-cfg.pl
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# List of all object files
|
||||
|
||||
@ -65,28 +62,6 @@ OBJS = asserts.o \
|
||||
# -----------------------------------------------------------------------------
|
||||
# List of all config includes
|
||||
|
||||
INCS = apple2.inc \
|
||||
apple2enh.inc \
|
||||
atari.inc \
|
||||
atmos.inc \
|
||||
bbc.inc \
|
||||
c128.inc \
|
||||
c16.inc \
|
||||
c64.inc \
|
||||
cbm510.inc \
|
||||
cbm610.inc \
|
||||
geos-apple.inc \
|
||||
geos-cbm.inc \
|
||||
lunix.inc \
|
||||
lynx.inc \
|
||||
module.inc \
|
||||
nes.inc \
|
||||
none.inc \
|
||||
pet.inc \
|
||||
plus4.inc \
|
||||
supervision.inc \
|
||||
vic20.inc
|
||||
|
||||
LIBS = $(COMMON)/common.a
|
||||
|
||||
|
||||
@ -103,12 +78,10 @@ all: depend
|
||||
@$(MAKE) -f make/gcc.mak all
|
||||
endif
|
||||
|
||||
$(EXE): $(INCS) $(OBJS) $(LIBS)
|
||||
$(EXE): $(OBJS) $(LIBS)
|
||||
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
|
||||
@if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
|
||||
|
||||
inc: $(INCS)
|
||||
|
||||
clean:
|
||||
$(RM) *~ core.* *.map
|
||||
|
||||
@ -119,74 +92,6 @@ zap: clean
|
||||
# Make the dependencies
|
||||
|
||||
.PHONY: depend dep
|
||||
depend dep: $(INCS) $(OBJS:.o=.c)
|
||||
depend dep: $(OBJS:.o=.c)
|
||||
@echo "Creating dependency information"
|
||||
$(CC) $(CFLAGS) -MM $(OBJS:.o=.c) > .depend
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Rules to make config includes
|
||||
|
||||
apple2.inc: cfg/apple2.cfg
|
||||
@$(CVT) $< $@ CfgApple2
|
||||
|
||||
apple2enh.inc: cfg/apple2enh.cfg
|
||||
@$(CVT) $< $@ CfgApple2Enh
|
||||
|
||||
atari.inc: cfg/atari.cfg
|
||||
@$(CVT) $< $@ CfgAtari
|
||||
|
||||
atmos.inc: cfg/atmos.cfg
|
||||
@$(CVT) $< $@ CfgAtmos
|
||||
|
||||
bbc.inc: cfg/bbc.cfg
|
||||
@$(CVT) $< $@ CfgBBC
|
||||
|
||||
c16.inc: cfg/c16.cfg
|
||||
@$(CVT) $< $@ CfgC16
|
||||
|
||||
c64.inc: cfg/c64.cfg
|
||||
@$(CVT) $< $@ CfgC64
|
||||
|
||||
c128.inc: cfg/c128.cfg
|
||||
@$(CVT) $< $@ CfgC128
|
||||
|
||||
cbm510.inc: cfg/cbm510.cfg
|
||||
@$(CVT) $< $@ CfgCBM510
|
||||
|
||||
cbm610.inc: cfg/cbm610.cfg
|
||||
@$(CVT) $< $@ CfgCBM610
|
||||
|
||||
geos-apple.inc: cfg/geos-apple.cfg
|
||||
@$(CVT) $< $@ CfgGeosApple
|
||||
|
||||
geos-cbm.inc: cfg/geos-cbm.cfg
|
||||
@$(CVT) $< $@ CfgGeosCBM
|
||||
|
||||
lunix.inc: cfg/lunix.cfg
|
||||
@$(CVT) $< $@ CfgLunix
|
||||
|
||||
lynx.inc: cfg/lynx.cfg
|
||||
@$(CVT) $< $@ CfgLynx
|
||||
|
||||
module.inc: cfg/module.cfg
|
||||
@$(CVT) $< $@ CfgModule
|
||||
|
||||
nes.inc: cfg/nes.cfg
|
||||
@$(CVT) $< $@ CfgNES
|
||||
|
||||
none.inc: cfg/none.cfg
|
||||
@$(CVT) $< $@ CfgNone
|
||||
|
||||
pet.inc: cfg/pet.cfg
|
||||
@$(CVT) $< $@ CfgPET
|
||||
|
||||
plus4.inc: cfg/plus4.cfg
|
||||
@$(CVT) $< $@ CfgPlus4
|
||||
|
||||
supervision.inc: cfg/supervision.cfg
|
||||
@$(CVT) $< $@ CfgSupervision
|
||||
|
||||
vic20.inc: cfg/vic20.cfg
|
||||
@$(CVT) $< $@ CfgVic20
|
||||
|
||||
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* tgtcfg.c */
|
||||
/* */
|
||||
/* Target machine configurations the ld65 linker */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2009, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "check.h"
|
||||
|
||||
/* ld65 */
|
||||
#include "binfmt.h"
|
||||
#include "tgtcfg.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Target configurations */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Actual target configurations, converted into C strings by a perl script */
|
||||
#include "apple2.inc"
|
||||
#include "apple2enh.inc"
|
||||
#include "atari.inc"
|
||||
#include "atmos.inc"
|
||||
#include "bbc.inc"
|
||||
#include "c128.inc"
|
||||
#include "c16.inc"
|
||||
#include "c64.inc"
|
||||
#include "cbm510.inc"
|
||||
#include "cbm610.inc"
|
||||
#include "geos-apple.inc"
|
||||
#include "geos-cbm.inc"
|
||||
#include "lunix.inc"
|
||||
#include "lynx.inc"
|
||||
#include "module.inc"
|
||||
#include "nes.inc"
|
||||
#include "none.inc"
|
||||
#include "pet.inc"
|
||||
#include "plus4.inc"
|
||||
#include "supervision.inc"
|
||||
#include "vic20.inc"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Target configurations for all systems */
|
||||
const TargetDesc Targets[TGT_COUNT] = {
|
||||
{ BINFMT_BINARY, CfgNone },
|
||||
{ BINFMT_O65, CfgModule },
|
||||
{ BINFMT_BINARY, CfgAtari },
|
||||
{ BINFMT_BINARY, CfgVic20 },
|
||||
{ BINFMT_BINARY, CfgC16 },
|
||||
{ BINFMT_BINARY, CfgC64 },
|
||||
{ BINFMT_BINARY, CfgC128 },
|
||||
{ BINFMT_BINARY, CfgPlus4 },
|
||||
{ BINFMT_BINARY, CfgCBM510 },
|
||||
{ BINFMT_BINARY, CfgCBM610 },
|
||||
{ BINFMT_BINARY, CfgPET },
|
||||
{ BINFMT_BINARY, CfgBBC },
|
||||
{ BINFMT_BINARY, CfgApple2 },
|
||||
{ BINFMT_BINARY, CfgApple2Enh },
|
||||
{ BINFMT_BINARY, CfgGeosCBM },
|
||||
{ BINFMT_BINARY, CfgGeosApple },
|
||||
{ BINFMT_O65, CfgLunix },
|
||||
{ BINFMT_BINARY, CfgAtmos },
|
||||
{ BINFMT_BINARY, CfgNES },
|
||||
{ BINFMT_BINARY, CfgSupervision },
|
||||
{ BINFMT_BINARY, CfgLynx },
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void DumpBuiltinConfig (FILE* F, target_t T)
|
||||
/* Dump a builtin linker configuration */
|
||||
{
|
||||
/* Check the given parameter */
|
||||
PRECONDITION (T > TGT_UNKNOWN && T < TGT_COUNT);
|
||||
|
||||
/* Dump the config */
|
||||
fprintf (F, "%s\n", Targets[T].Cfg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* tgtcfg.h */
|
||||
/* */
|
||||
/* Target machine configurations the ld65 linker */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef TGTCFG_H
|
||||
#define TGTCFG_H
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* common */
|
||||
#include "target.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Target configurations */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Structure describing a target */
|
||||
typedef struct TargetDesc TargetDesc;
|
||||
struct TargetDesc {
|
||||
unsigned char BinFmt; /* Default binary format for the target */
|
||||
const char* Cfg; /* Pointer to configuration */
|
||||
};
|
||||
|
||||
/* Target configurations for all systems */
|
||||
extern const TargetDesc Targets [TGT_COUNT];
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void DumpBuiltinConfig (FILE* F, target_t T);
|
||||
/* Dump a builtin linker configuration */
|
||||
|
||||
|
||||
|
||||
/* End of tgtcfg.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user