Merge pull request #7 from michaelcmartin/fix-link

Fix linking
This commit is contained in:
Michael Steil 2016-04-13 14:42:44 -07:00
commit 19a063f863
7 changed files with 170 additions and 238 deletions

146
Makefile
View File

@ -1,35 +1,25 @@
.SUFFIXES: .o .c .h .run
# to make for another target CPU, redefine PROC to the name of the target
# processor, e.g., 68000
PROC =6502
OBJECTS = y.tab.o actions.o buildStuff1.o buildStuff2.o\
buildStuff3.o builtInFunctions.o builtInFunsSD.o debugPrint.o debugPrintSD.o\
emitBranch.o emitStuff.o encode.o errorStuff.o expressionSemantics.o fixups.o\
garbage.o globals.o initialize.o lexer.o listing.o lookups.o macrossTables.o main.o\
object.o operandStuffSD.o parserMisc.o semanticMisc.o\
statementSemantics.o structSemantics.o tokenStrings.o
SOURCES = macross_$(PROC).y actions_$(PROC).c buildStuff1.c buildStuff2.c\
buildStuff3.c builtInFunctions.c builtInFunsSD_$(PROC).c debugPrint.c\
debugPrintSD_$(PROC).c emitBranch_$(PROC).c emitStuff.c encode.c errorStuff.c\
expressionSemantics.c fixups.c garbage.c globals.c initialize.c lexer.c listing.c\
lookups.c macrossTables_$(PROC).c main.c object.c\
operandStuffSD_$(PROC).c parserMisc.c semanticMisc.c statementSemantics.c\
structSemantics.c tokenStrings_$(PROC).c lexerTables.h macrossGlobals.h\
macrossTypes.h operandDefs_$(PROC).h operandBody_$(PROC).h\
conditionDefs_$(PROC).h driver.c slinkyExpressions.h\
operandStuff.h statementSemantics.h listing.h parserMisc.h\
emitBranch.h semanticMisc.h expressionSemantics.h
HEADERS = macrossTypes.h macrossGlobals.h
MACROSS_OBJECTS = actions_$(PROC).o buildStuff1.o buildStuff2.o \
buildStuff3.o builtInFunctions.o \
builtInFunsSD_$(PROC).o debugPrint.o \
debugPrintSD_$(PROC).o emitBranch_$(PROC).o \
emitStuff.o encode.o errorStuff.o \
expressionSemantics.o fixups.o garbage.o globals.o \
initialize.o lexer.o listing.o lookups.o \
macrossTables_$(PROC).o main.o object.o \
operandStuffSD_$(PROC).o parserMisc.o \
semanticMisc.o statementSemantics.o \
structSemantics.o tokenStrings_$(PROC).o y.tab.o
# Macross is not 64-bit clean and it does a lot of silent downcasting
# to simulate subclasses and uses int and void * interchangably a
# bunch. gcc calls these the int-conversion and
# incompatible-pointer-types warnings.
CFLAGS=-m32
CFLAGS=-m32 -O2 -ansi -DYYDEBUG -DTARGET_CPU=CPU_$(PROC)
LDFLAGS=-m32
# If yacc is notionally present on a system, it's usually actually
# bison in a compatibility mode. bison is available by name more often
@ -37,104 +27,34 @@ CFLAGS=-m32
YACC=bison -y
#YACC=yacc
.c.o:
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) $*.c
# Pick a compiler if you have one in particular you want.
CC=cc
#CC=gcc
#CC=clang
.c.run:
cc $(CFLAGS) -o $* $*.c
macross: $(MACROSS_OBJECTS)
$(CC) $(LDFLAGS) -o macross $(MACROSS_OBJECTS)
macross: $(OBJECTS)
cc $(CFLAGS) -g -o macross $(OBJECTS)
driver: driver.c
cc $(CFLAGS) -o driver driver.c
macrossTypes.h: operandDefs_$(PROC).h operandBody_$(PROC).h\
conditionDefs_$(PROC).h
actions.o: actions_$(PROC).c $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) actions_$(PROC).c
mv actions_$(PROC).o actions.o
buildStuff1.o: buildStuff1.c $(HEADERS)
buildStuff2.o: buildStuff2.c $(HEADERS)
buildStuff3.o: buildStuff3.c $(HEADERS)
builtInFunctions.o: builtInFunctions.c $(HEADERS) expressionSemantics.h operandStuff.h semanticMisc.h
builtInFunsSD.o: builtInFunsSD_$(PROC).c $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) builtInFunsSD_$(PROC).c
mv builtInFunsSD_$(PROC).o builtInFunsSD.o
debugPrint.o: debugPrint.c y.tab.h $(HEADERS)
debugPrintSD.o: debugPrintSD_$(PROC).c y.tab.h $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) debugPrintSD_$(PROC).c
mv debugPrintSD_$(PROC).o debugPrintSD.o
emitBranch.o: emitBranch_$(PROC).c $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) emitBranch_$(PROC).c
mv emitBranch_$(PROC).o emitBranch.o
emitStuff.o: emitStuff.c $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) emitStuff.c
encode.o: encode.c $(HEADERS) y.tab.h semanticMisc.h slinkyExpressions.h
errorStuff.o: errorStuff.c $(HEADERS)
expressionSemantics.o: expressionSemantics.c y.tab.h $(HEADERS) expressionSemantics.h semanticMisc.h
fixups.o: fixups.c $(HEADERS)
garbage.o: garbage.c y.tab.h $(HEADERS)
initialize.o: initialize.c $(HEADERS)
lexer.o: lexer.c lexerTables.h y.tab.h $(HEADERS) parserMisc.h
listing.o: listing.c $(HEADERS) listing.h
lookups.o: lookups.c $(HEADERS)
macrossTables.o: macrossTables_$(PROC).c y.tab.h macrossTypes.h
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) macrossTables_$(PROC).c
mv macrossTables_$(PROC).o macrossTables.o
main.o: main.c $(HEADERS)
object.o: object.c $(HEADERS)
operandStuffSD.o: operandStuffSD_$(PROC).c $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) operandStuffSD_$(PROC).c
mv operandStuffSD_$(PROC).o operandStuffSD.o
parserMisc.o: parserMisc.c y.tab.h $(HEADERS) parserMisc.h
semanticMisc.o: semanticMisc.c $(HEADERS) semanticMisc.h expressionSemantics.h
statementSemantics.o: statementSemantics.c $(HEADERS) emitBranch.h expressionSemantics.h operandStuff.h parserMisc.h semanticMisc.h statementSemantics.h
structSemantics.o: structSemantics.c $(HEADERS)
tokenStrings.o: tokenStrings_$(PROC).c $(HEADERS)
cc $(CFLAGS) -c -g -DTARGET_CPU=CPU_$(PROC) tokenStrings_$(PROC).c
mv tokenStrings_$(PROC).o tokenStrings.o
y.tab.o: y.tab.c $(HEADERS)
cc $(CFLAGS) -c -g -DYYDEBUG -DTARGET_CPU=CPU_$(PROC) y.tab.c
# This is a switcher program between multiple versions of Macross, not
# really a build product
# driver: driver.c
# cc $(CFLAGS) -o driver driver.c
y.tab.c y.tab.h: macross_$(PROC).y
$(YACC) -d macross_$(PROC).y
y.output: macross_$(PROC).y
$(YACC) -vd macross_$(PROC).y
clean:
/bin/rm -f *.o y.output y.tab.c y.tab.h macross
rm -f *.o y.tab.c y.tab.h macross
love:
@echo "Not war?"
.c.o:
$(CC) $(CFLAGS) -c $<
Makefile.depend:
makedepend -Y -DTARGET_CPU=CPU_$(PROC) -f - *.c > Makefile.depend
depend: Makefile.depend
include Makefile.depend

78
Makefile.depend Normal file
View File

@ -0,0 +1,78 @@
# DO NOT DELETE
actions_6502.o: macrossTypes.h operandDefs_6502.h conditionDefs_6502.h
actions_6502.o: macrossGlobals.h actions.h macrossTypes.h emitStuff.h
actions_6502.o: errorStuff.h semanticMisc.h
actions_68000.o: macrossTypes.h macrossGlobals.h
buildStuff1.o: macrossTypes.h macrossGlobals.h errorStuff.h lookups.h
buildStuff1.o: parserMisc.h
buildStuff2.o: macrossTypes.h macrossGlobals.h lookups.h parserMisc.h
buildStuff3.o: macrossTypes.h macrossGlobals.h lookups.h
builtInFunctions.o: macrossTypes.h macrossGlobals.h buildStuff.h errorStuff.h
builtInFunctions.o: expressionSemantics.h garbage.h lexer.h lookups.h
builtInFunctions.o: operandStuff.h semanticMisc.h statementSemantics.h
builtInFunsSD_6502.o: macrossTypes.h macrossGlobals.h builtInFunctions.h
builtInFunsSD_6502.o: operandStuff.h
builtInFunsSD_68000.o: macrossTypes.h macrossGlobals.h
debugPrint.o: macrossTypes.h macrossGlobals.h debugPrint.h y.tab.h
debugPrintSD_6502.o: macrossTypes.h macrossGlobals.h debugPrint.h y.tab.h
debugPrintSD_68000.o: macrossTypes.h macrossGlobals.h y.tab.h
emitBranch_6502.o: macrossTypes.h macrossGlobals.h buildStuff.h emitStuff.h
emitBranch_6502.o: parserMisc.h semanticMisc.h
emitBranch_68000.o: macrossTypes.h macrossGlobals.h
emitStuff.o: macrossTypes.h macrossGlobals.h actions.h debugPrint.h
emitStuff.o: errorStuff.h semanticMisc.h
encode.o: macrossTypes.h macrossGlobals.h y.tab.h encode.h debugPrint.h
encode.o: errorStuff.h parserMisc.h semanticMisc.h slinkyExpressions.h
errorStuff.o: macrossTypes.h macrossGlobals.h errorStuff.h initialize.h
expressionSemantics.o: macrossTypes.h macrossGlobals.h y.tab.h
expressionSemantics.o: builtInFunctions.h errorStuff.h expressionSemantics.h
expressionSemantics.o: fixups.h listing.h lookups.h operandStuff.h
expressionSemantics.o: parserMisc.h semanticMisc.h statementSemantics.h
expressionSemantics.o: tokenStrings.h
fixups.o: macrossTypes.h macrossGlobals.h errorStuff.h expressionSemantics.h
fixups.o: fixups.h listing.h operandStuff.h parserMisc.h semanticMisc.h
fixups.o: tokenStrings.h
garbage.o: macrossTypes.h macrossGlobals.h garbage.h operandStuff.h
garbage.o: parserMisc.h y.tab.h
globals.o: macrossTypes.h macrossGlobals.h
initialize.o: macrossTypes.h macrossGlobals.h initialize.h errorStuff.h
initialize.o: lexer.h lookups.h semanticMisc.h
lexer.o: macrossTypes.h macrossGlobals.h y.tab.h debugPrint.h errorStuff.h
lexer.o: lexer.h lexerTables.h listing.h lookups.h parserMisc.h
listing.o: macrossTypes.h macrossGlobals.h emitStuff.h lexer.h listing.h
listing.o: semanticMisc.h
lookups.o: macrossTypes.h macrossGlobals.h buildStuff.h errorStuff.h
lookups.o: garbage.h listing.h lookups.h operandStuff.h parserMisc.h
lookups.o: semanticMisc.h
macrossTables_6502.o: macrossTypes.h actions.h builtInFunctions.h y.tab.h
macrossTables_68000.o: macrossTypes.h y.tab.h
main.o: macrossTypes.h macrossGlobals.h initialize.h semanticMisc.h y.tab.h
object.o: macrossTypes.h macrossGlobals.h debugPrint.h encode.h
object.o: expressionSemantics.h fixups.h garbage.h lookups.h object.h
object.o: semanticMisc.h
operandStuffSD_6502.o: macrossTypes.h macrossGlobals.h errorStuff.h
operandStuffSD_6502.o: expressionSemantics.h fixups.h garbage.h listing.h
operandStuffSD_6502.o: operandStuff.h parserMisc.h semanticMisc.h
operandStuffSD_6502.o: statementSemantics.h
operandStuffSD_68000.o: macrossTypes.h macrossGlobals.h
parserMisc.o: macrossTypes.h macrossGlobals.h y.tab.h buildStuff.h fixups.h
parserMisc.o: initialize.h errorStuff.h parserMisc.h
semanticMisc.o: macrossTypes.h macrossGlobals.h y.tab.h semanticMisc.h
semanticMisc.o: buildStuff.h debugPrint.h emitStuff.h errorStuff.h
semanticMisc.o: expressionSemantics.h fixups.h listing.h lookups.h object.h
semanticMisc.o: operandStuff.h parserMisc.h
statementSemantics.o: macrossTypes.h macrossGlobals.h actions.h debugPrint.h
statementSemantics.o: emitBranch.h emitStuff.h errorStuff.h
statementSemantics.o: expressionSemantics.h fixups.h garbage.h lexer.h
statementSemantics.o: listing.h lookups.h operandStuff.h parserMisc.h
statementSemantics.o: semanticMisc.h statementSemantics.h structSemantics.h
statementSemantics.o: tokenStrings.h
structSemantics.o: macrossTypes.h macrossGlobals.h emitStuff.h errorStuff.h
structSemantics.o: listing.h parserMisc.h semanticMisc.h statementSemantics.h
structSemantics.o: structSemantics.h
tokenStrings_6502.o: macrossTypes.h macrossGlobals.h
tokenStrings_68000.o: macrossTypes.h macrossGlobals.h
y.tab.o: macrossTypes.h macrossGlobals.h buildStuff.h errorStuff.h lexer.h
y.tab.o: lookups.h operandStuff.h parserMisc.h semanticMisc.h
y.tab.o: statementSemantics.h

View File

@ -1,51 +1,28 @@
.SUFFIXES: .o .c .h .run
# to make for another target CPU, redefine PROC to the name of the target
# processor, e.g., 68000
PROC =6502
OBJECTS = builtins.o debugPrint.o errorStuff.o expr.o globals.o initialize.o\
instantiate.o link.o main.o map.o poke.o read.o relocate.o slinkyTables.o\
write.o
SLINKY_OBJECTS = builtins.o debugPrint.o errorStuff.o expr.o \
globals.o initialize.o instantiate.o link.o main.o \
map.o poke.o read.o relocate.o slinkyTables.o \
write.o
SOURCES = builtins.c debugPrint.c errorStuff.c expr.c globals.c initialize.c\
instantiate.c link.c main.c map.c poke.c read.c relocate.c slinkyTables.c\
write.c slinkyExpressions.h slinkyGlobals.h slinkyTypes.h y.tab.h
CFLAGS=-m32 -g -ansi -DYYDEBUG -DTARGET_CPU=CPU_$(PROC)
LDFLAGS=-m32
CFLAGS= -m32 # slinky is not 64 bit clean
# If yacc is notionally present on a system, it's usually actually
# bison in a compatibility mode. bison is available by name more often
# than yacc itself is.
YACC=bison -y
#YACC=yacc
.c.o:
cc $(CFLAGS) -c $*.c
# Pick a compiler if you have one in particular you want.
CC=cc
#CC=gcc
#CC=clang
.c.run:
cc $(CFLAGS) -o $* $*.c
slinky: $(OBJECTS)
cc $(CFLAGS) -g -o slinky $(OBJECTS)
builtins.o: builtins.c slinkyGlobals.h slinkyTypes.h slinkyExpressions.h
debugPrint.o: debugPrint.c slinkyGlobals.h slinkyTypes.h
errorStuff.o: errorStuff.c slinkyGlobals.h slinkyTypes.h
expr.o: expr.c slinkyExpressions.h slinkyGlobals.h slinkyTypes.h y.tab.h
initialize.o: initialize.c slinkyGlobals.h slinkyTypes.h
instantiate.o: instantiate.c slinkyGlobals.h slinkyTypes.h slinkyExpressions.h
link.o: link.c slinkyGlobals.h slinkyTypes.h
main.o: main.c slinkyGlobals.h slinkyTypes.h
map.o: map.c slinkyGlobals.h slinkyTypes.h
poke.o: poke.c slinkyGlobals.h slinkyTypes.h
read.o: read.c slinkyGlobals.h slinkyTypes.h
relocate.o: relocate.c slinkyGlobals.h slinkyTypes.h
slinkyTables.o: slinkyTables.c slinkyTypes.h
write.o: write.c slinkyGlobals.h slinkyTypes.h
slinky: $(SLINKY_OBJECTS)
$(CC) $(LDFLAGS) -o slinky $(SLINKY_OBJECTS)
clean:
/bin/rm -f *.o slinky
@ -53,3 +30,17 @@ clean:
love:
@echo "Not war?"
# Slinky needs to use the parser headers created by Macross. If they
# aren't available, we dip down and make them ourselves.
../y.tab.h: ../macross_$(PROC).y
cd .. && $(YACC) -d macross_$(PROC).y && cd slinky
.c.o:
$(CC) $(CFLAGS) -c $<
Makefile.depend:
makedepend -Y -f - *.c > Makefile.depend
depend: Makefile.depend
include Makefile.depend

23
slinky/Makefile.depend Normal file
View File

@ -0,0 +1,23 @@
# DO NOT DELETE
builtins.o: slinkyTypes.h slinkyGlobals.h slinkyExpressions.h builtins.h
builtins.o: errorStuff.h expr.h link.h relocate.h
debugPrint.o: slinkyTypes.h slinkyGlobals.h debugPrint.h
errorStuff.o: slinkyTypes.h slinkyGlobals.h errorStuff.h
expr.o: slinkyTypes.h slinkyGlobals.h slinkyExpressions.h expr.h errorStuff.h
expr.o: initialize.h ../y.tab.h
globals.o: slinkyTypes.h slinkyGlobals.h
initialize.o: slinkyTypes.h slinkyGlobals.h initialize.h errorStuff.h main.h
instantiate.o: slinkyTypes.h slinkyGlobals.h slinkyExpressions.h errorStuff.h
instantiate.o: expr.h instantiate.h ../y.tab.h
link.o: slinkyTypes.h slinkyGlobals.h link.h debugPrint.h errorStuff.h
link.o: instantiate.h poke.h read.h relocate.h write.h
main.o: slinkyTypes.h slinkyGlobals.h main.h initialize.h link.h
map.o: slinkyTypes.h slinkyGlobals.h map.h debugPrint.h link.h
poke.o: slinkyTypes.h slinkyGlobals.h poke.h debugPrint.h errorStuff.h expr.h
read.o: slinkyTypes.h slinkyGlobals.h read.h debugPrint.h errorStuff.h
read.o: initialize.h instantiate.h link.h
relocate.o: slinkyTypes.h slinkyGlobals.h relocate.h debugPrint.h
relocate.o: errorStuff.h link.h map.h
slinkyTables.o: slinkyTypes.h builtins.h
write.o: slinkyTypes.h slinkyGlobals.h write.h

View File

@ -33,7 +33,7 @@
#include "expr.h"
#include "errorStuff.h"
#include "initialize.h"
#include "y.tab.h"
#include "../y.tab.h"
#define overSymbol() (pc+=sizeof(symbolType *))
#define getSymbol() ((symbolType *)getNumber())

View File

@ -34,7 +34,7 @@
#include "errorStuff.h"
#include "expr.h"
#include "instantiate.h"
#include "y.tab.h"
#include "../y.tab.h"
#define overFunction() (pc+=sizeof(functionType *))
#define overNumber() (pc+=sizeof(addressType))

View File

@ -1,80 +0,0 @@
# define A 257
# define ALIGN 258
# define ASSERT 259
# define BLOCK 260
# define BYTE 261
# define CONSTRAIN 262
# define DBYTE 263
# define DEFINE 264
# define DO 265
# define ELSE 266
# define ELSEIF 267
# define ENDFILE 268
# define EOL 269
# define EXTERN 270
# define FRETURN 271
# define FUNCTION 272
# define HERE 273
# define IF 274
# define INCLUDE 275
# define LONG 276
# define MACRO 277
# define MCASE 278
# define MDEFAULT 279
# define MDEFINE 280
# define MDO 281
# define MELSE 282
# define MELSEIF 283
# define MFOR 284
# define MIF 285
# define MSWITCH 286
# define MUNTIL 287
# define MVARIABLE 288
# define MWHILE 289
# define ORG 290
# define REL 291
# define START 292
# define STRING 293
# define STRUCT 294
# define TARGET 295
# define UNDEFINE 296
# define UNTIL 297
# define VARIABLE 298
# define WHILE 299
# define WORD 300
# define X 301
# define Y 302
# define ConditionCode 303
# define Identifier 304
# define MacroName 305
# define Number 306
# define Opcode 307
# define TextString 308
# define ASSIGN 309
# define LOGICAL_OR 310
# define LOGICAL_XOR 311
# define LOGICAL_AND 312
# define BITWISE_OR 313
# define BITWISE_XOR 314
# define BITWISE_AND 315
# define EQUAL_TO 316
# define NOT_EQUAL_TO 317
# define LESS_THAN 318
# define LESS_THAN_OR_EQUAL_TO 319
# define GREATER_THAN 320
# define GREATER_THAN_OR_EQUAL_TO 321
# define LEFT_SHIFT 322
# define RIGHT_SHIFT 323
# define ADD 324
# define SUB 325
# define MUL 326
# define DIV 327
# define MOD 328
# define UNARY_MINUS 329
# define LOGICAL_NOT 330
# define BITWISE_NOT 331
# define HI_BYTE 332
# define LO_BYTE 333
# define SELECT 334
# define INCREMENT 335
# define DECREMENT 336