Skip to content

Commit

Permalink
Replaced builtin linker configs with ordinary .cfg files.
Browse files Browse the repository at this point in the history
The benefits are:
- Independency of ld65 build from perl
- More transparent behaviour
  • Loading branch information
oliverschmidt committed Apr 9, 2013
1 parent 4757642 commit 37c492b
Show file tree
Hide file tree
Showing 48 changed files with 52 additions and 424 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 21 additions & 21 deletions src/common/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
7 changes: 5 additions & 2 deletions src/common/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */



Expand Down
4 changes: 4 additions & 0 deletions src/ld65/binfmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@



/* common */
#include "target.h"

/* ld65 */
#include "error.h"
#include "binfmt.h"

Expand Down
5 changes: 0 additions & 5 deletions src/ld65/binfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
67 changes: 0 additions & 67 deletions src/ld65/cfg/cvt-cfg.pl

This file was deleted.

1 change: 1 addition & 0 deletions src/ld65/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "check.h"
#include "print.h"
#include "segdefs.h"
#include "target.h"
#include "xmalloc.h"
#include "xsprintf.h"

Expand Down
43 changes: 19 additions & 24 deletions src/ld65/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#include "scanner.h"
#include "segments.h"
#include "spool.h"
#include "tgtcfg.h"
#include "tpool.h"


Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -486,22 +470,34 @@ 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);
if (Target == TGT_UNKNOWN) {
Error ("Invalid target name: `%s'", Arg);
}

/* Get the target description record */
D = &Targets[Target];
/* Set the target binary format */
DefaultBinFmt = GetTargetProperties (Target)->BinFmt;

/* Build config file name from target name */
SB_CopyStr (&FileName, GetTargetName (Target));
SB_AppendStr (&FileName, ".cfg");
SB_Terminate (&FileName);

/* Search for the file */
PathName = SearchFile (CfgSearchPath, SB_GetBuf (&FileName));
if (PathName == 0) {
Error ("Cannot find config file `%s'", SB_GetBuf (&FileName));
}

/* Set the target data */
DefaultBinFmt = D->BinFmt;
CfgSetBuf (D->Cfg);
/* Free file name memory */
SB_Done (&FileName);

/* Read the target config */
/* Read the file */
CfgSetName (PathName);
CfgRead ();
}

Expand All @@ -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 },
Expand Down
99 changes: 2 additions & 97 deletions src/ld65/make/gcc.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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


Expand All @@ -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

Expand All @@ -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


Loading

5 comments on commit 37c492b

@silverdr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be OK to still keep the --dump-config command?

@oliverschmidt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a misunderstanding (?) The --dump-config option would "pipe" the .cfg file to stdout. I really don't see the point in maintaining an option doing just that.

@silverdr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just thinking of some users, which

  • may remember that there was an easy way to get the default config for a target
  • may not know where to look for the .cfg file(s)

I got bitten myself by this and needed to dig github to find out

  • that the option was in fact removed
  • where to look for config files now

True - it admittedly is not a high priority thing but is also quite a low-maintenance one that could possibly be kept for convenience and backwards compatibility

@mrdudz
Copy link
Contributor

@mrdudz mrdudz commented on 37c492b Nov 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with silverdr - i got bitten by it as well before. it was quite convenient that you can do --dump-config > newconfig.x to start hacking on something custom

@oliverschmidt
Copy link
Contributor Author

@oliverschmidt oliverschmidt commented on 37c492b Nov 29, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.