-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (36 loc) · 1.1 KB
/
Copy pathMakefile
File metadata and controls
48 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Source directories
SRC_DIR := src
BUILD_DIR := build
INSTALL_DIR := /usr/local/bin
# Compiler and flags
CC := gcc
CFLAGS := -ggdb -Wall -Wextra -I include -I $(SRC_DIR)
# Object files
OBJECTS := $(BUILD_DIR)/lasm2_tokenizer.o \
$(BUILD_DIR)/lasm2_macro.o \
$(BUILD_DIR)/lasm2_tokenreader.o \
$(BUILD_DIR)/lasm2_parser.o \
$(BUILD_DIR)/lasm2_assembler.o
# Main target
$(BUILD_DIR)/lasm2: $(BUILD_DIR) $(wildcard $(SRC_DIR)/*) $(OBJECTS)
$(CC) -o $@ $(SRC_DIR)/lasm2.c $(CFLAGS) $(OBJECTS)
# Generic rule for object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/%.h
$(CC) -c $< -o $@ $(CFLAGS)
# Create build directory
$(BUILD_DIR):
mkdir -p $@
# Phony targets
.PHONY: clean examples
all: clean $(BUILD_DIR)/lasm2
clean:
rm -rf $(BUILD_DIR)
install: all
touch $(INSTALL_DIR)
cp $(BUILD_DIR)/lasm2 $(INSTALL_DIR)
uninstall:
rm -f $(INSTALL_DIR)/lasm2
# Examples
examples: example_basic_syntax example_expressions example_namespaces example_fibonacci example_6502_addressing
example_%: $(BUILD_DIR)/lasm2 examples/%.l
./$(BUILD_DIR)/lasm2 examples/$*.l -m 6502 -o $(BUILD_DIR)/$*.out