change compiler name

This commit is contained in:
Lorenzo Torres 2025-11-30 22:57:52 +01:00
parent abf1d7c066
commit 771994fece
3 changed files with 23 additions and 25 deletions

View file

@ -3,14 +3,14 @@
include config.mk include config.mk
SRC = cc.c utils.c lexer.c parser.c SRC = lc.c utils.c lexer.c parser.c
HDR = config.def.h utils.h lexer.h parser.h sema.h HDR = config.def.h utils.h lexer.h parser.h sema.h
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
all: options cc all: options lc
options: options:
@echo cc build options: @echo lc build options:
@echo "CFLAGS = ${CFLAGS}" @echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}" @echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}" @echo "CC = ${CC}"
@ -26,30 +26,30 @@ config.h:
users.h: users.h:
cp users.def.h $@ cp users.def.h $@
cc: ${OBJ} lc: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS} ${CC} -o $@ ${OBJ} ${LDFLAGS}
clean: clean:
rm -f cc ${OBJ} cc-${VERSION}.tar.gz rm -f lc ${OBJ} lc-${VERSION}.tar.gz
dist: clean dist: clean
mkdir -p cc-${VERSION} mkdir -p lc-${VERSION}
cp -R LICENSE Makefile README config.mk\ cp -R LICENSE Makefile README config.mk\
cc.1 ${HDR} ${SRC} cc-${VERSION} lc.1 ${HDR} ${SRC} lc-${VERSION}
tar -cf cc-${VERSION}.tar cc-${VERSION} tar -cf lc-${VERSION}.tar lc-${VERSION}
gzip cc-${VERSION}.tar gzip lc-${VERSION}.tar
rm -rf cc-${VERSION} rm -rf lc-${VERSION}
install: all install: all
mkdir -p ${DESTDIR}${PREFIX}/bin mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f cc ${DESTDIR}${PREFIX}/bin cp -f lc ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/cc chmod 755 ${DESTDIR}${PREFIX}/bin/lc
mkdir -p ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < cc.1 > ${DESTDIR}${MANPREFIX}/man1/cc.1 sed "s/VERSION/${VERSION}/g" < lc.1 > ${DESTDIR}${MANPREFIX}/man1/lc.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/cc.1 chmod 644 ${DESTDIR}${MANPREFIX}/man1/lc.1
uninstall: uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/cc\ rm -f ${DESTDIR}${PREFIX}/bin/lc\
${DESTDIR}${MANPREFIX}/man1/cc.1 ${DESTDIR}${MANPREFIX}/man1/lc.1
.PHONY: all options clean dist install uninstall .PHONY: all options clean dist install uninstall

12
README
View file

@ -1,19 +1,19 @@
cc - C compiler lc - L compiler
============================ ============================
cc is a C compiler. It can compile C code. lc is a L compiler. It can compile L code.
Requirements Requirements
------------ ------------
In order to build cc you need... a computer In order to build lc you need... a computer
Installation Installation
------------ ------------
Edit config.mk to match your local setup (cc is installed into Edit config.mk to match your local setup (lc is installed into
the /usr/local namespace by default). the /usr/local namespace by default).
Afterwards enter the following command to build and install cc (if Afterwards enter the following command to build and install lc (if
necessary as root): necessary as root):
make clean install make clean install
@ -21,4 +21,4 @@ necessary as root):
Usage Usage
----------- -----------
cc file lc file

View file

@ -4,12 +4,10 @@
#include "lexer.h" #include "lexer.h"
#include "parser.h" #include "parser.h"
// Helper to print indentation
void print_indent(int depth) { void print_indent(int depth) {
for (int i = 0; i < depth; i++) printf(" "); for (int i = 0; i < depth; i++) printf(" ");
} }
// Helper to convert Binary Op enum to string
const char* get_op_str(binary_op op) { const char* get_op_str(binary_op op) {
switch(op) { switch(op) {
case OP_PLUS: return "+"; case OP_PLUS: return "+";