Initial commit to 'Modern C Template For PDP-11' repository.
[pdp11-modern-c] / Makefile
CommitLineData
846f4d60
AT
1#############################################################
2# (c) 2020 Aaron Taylor <ataylor at subgeniuskitty dot com> #
3# See LICENSE.txt file for copyright and license details. #
4#############################################################
5
6
7####################################################################################################
8# GNU Executables & Flags
9
10CC = pdp11-aout-gcc
11LD = pdp11-aout-ld
12AS = pdp11-aout-as
13OC = pdp11-aout-objcopy
14OD = pdp11-aout-objdump
15
16CC_FLAGS = -c -Wall -Wno-unused-function -O0 -ffreestanding -fomit-frame-pointer -fno-builtin-alloca -std=c99
17LD_FLAGS = -T pdp11.ld --entry _start
18AS_FLAGS =
19OC_FLAGS = --only-section=.text --output-target binary
20
21
22####################################################################################################
23# Misc Configuration
24
25# Physical serial port connected to a PDP-11 for transfering program into memory.
26SERIAL_PORT = /dev/cuau0
27
28# Commands for converting raw binary into SIMH or real PDP compatible formats.
29SIM_LOAD = bin2load
30PDP_LOAD = bin2pdp
31
32# Commands for running the SIMH PDP-11 simulation.
33SIMH_CMD = pdp11
34SIMH_CFG = simh.conf
35
36# List of all source files in PDP-11 library.
37PDPLIB_SRC != ls pdp11/*.c
38
39
40####################################################################################################
41# Targets
42
43all: aout
44
45aout:
46 $(AS) $(AS_FLAGS) -o init.o init.s
47 $(CC) $(CC_FLAGS) -o pdp11.o $(PDPLIB_SRC)
48
49 ##############################################
50 # Insert your program's build commands here. #
51 $(CC) $(CC_FLAGS) -o hello.o hello.c
52 ##############################################
53
54 $(LD) $(LD_FLAGS) init.o pdp11.o hello.o -o program.out
55
56clean:
57 @rm -rf *.o *.out *.pdp11 *.bin *.core
58
59sim: aout
60 $(OC) $(OC_FLAGS) program.out program.bin
61 $(SIM_LOAD) -i program.bin -o program.pdp11 -a 01000
62 $(SIMH_CMD) $(SIMH_CFG)
63
64pdp: aout
65 $(OC) $(OC_FLAGS) program.out program.bin
66 $(PDP_LOAD) -i program.bin -o $(SERIAL_PORT)
67
68examine: aout
69 @$(OD) -d program.out