Updated makefile to be more portable
authorLukas Krickl <lukas@krickl.dev>
Tue, 29 Oct 2024 08:56:14 +0000 (09:56 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 29 Oct 2024 08:56:14 +0000 (09:56 +0100)
.gitignore
doc/ulas.1 [deleted file]
makefile
man/ulas.1 [new file with mode: 0644]

index c7e8574fd7db157791cb3513e156f8046b1bafdc..2571b1964549c76d0a78dafa000c9ac909c3c3eb 100644 (file)
@@ -62,3 +62,6 @@ compile_commands.json
 .clang_complete
 # .clangd
 .session
+
+ulas
+testulas
diff --git a/doc/ulas.1 b/doc/ulas.1
deleted file mode 100644 (file)
index 83a566b..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Manpage for ulas.
-.\" Contact lukas@krickl.dev to correct errors or typos.
-
-.TH man 1 "21 August 2023" "0.0.1" "ulas manual"
-
-.SH NAME
-  ulas
-.SH SYNOPSIS
-  ulas [-hvV] 
-.SH DESCRIPTION
-  ulas
-
-  -h                    
-    display this help and exit
-  -v                 
-    display version info and exit
-  -v, --verbose             
-    verbose output
-.SH PREPROCESSOR 
-
-The preprocessor is a text based way of modifying the input before 
-the assembly step. Stray tokens after a directive are ignored!
-
-Preprocessor directives start with a # and have to be the first non-space character in a line.
-All lines that are not a preprocessor directive, or are not part of a preprocessor block (macro, or if)
-will be output as-is. If a line contains the name of a preprocessot define or macro 
-,surrounded by token any character that is not alphanumeric or an underscore,
-the define or macro will be expanded.
-
-Withing preprocessor macros 
-- $0 will expand to the literal argument string 
-- $1 to $9 will expand to the comma separated arguments of the macro 
-- $$ will insert a unique numeric literal 
-
-Macros:
-
-#macro my_macro
-label$$:
-  adc $1, $2
-#endmacro
-
-my_macro a, b
-
-Define:
-
-#define name value 
-name ; will be replaced with 'value'
-#undefine name
-
-.SH ASSEMBLY SYNTAX
-
-
-
-.SH EXPRESSION SYNTAX
-
-Expressions are written in Reverse Polish Notation style and evaluated based on their expected data type.
-For example when an expression expects an int type the expression will assume all values that are pushed to it 
-are integers.
-
-.SH ASSEMBLY DIRECTIVES 
-
-During assembly sometimes it is required to set certain parameters of the assembler such as the base address (represented by the $@ symbol in expressions).
-
-Valid directives:
-
-  \.org <expression>  
-    Sets the base address
-
-.SH EXAMPLES
-.SH SEE ALSO
-
-.SH BUGS
-
-.SH AUTHOR
-  Lukas Krickl (lukas@krickl.dev)
-
-.SH COPYRIGHT
-  Copyright 2023 Lukas Krickl (lukas@krickl.dev)
index 501f9f213a1241c7b2dae3639d5d03cb7f82d34a..b923c1940b9a37681afa60f08c9c11551b376fb9 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,76 +1,67 @@
 NAME=ulas
-IDIR=./src
-SDIR=./src 
-CC=gcc
+TEST_NAME=test$(NAME)
 DBGCFLAGS=-g -fsanitize=address
 DBGLDFLAGS=-fsanitize=address 
-CFLAGS=-I$(IDIR) -Wall -pedantic $(DBGCFLAGS) -std=gnu99
+CFLAGS=-Wall -pedantic $(DBGCFLAGS) -std=gnu99
 LIBS=
-TEST_LIBS=
 LDFLAGS=$(DBGLDFLAGS) $(LIBS)
 
-TAG_LIBS=/usr/include/unistd.h /usr/include/stdio.h /usr/include/stdlib.h /usr/include/assert.h /usr/include/errno.h /usr/include/ctype.h
+INSTALL_DIR=/usr/local
+OBJS:=ulas.o archs.o uldas.o 
 
-ODIR=obj
-TEST_ODIR=obj/test
-BDIR=bin
-BNAME=$(NAME)
-MAIN=main.o
-TEST_MAIN=test.o
-TEST_BNAME=testulas
-
-BIN_INSTALL_DIR=/usr/local/bin
-MAN_INSTALL_DIR=/usr/local/man
-
-OBJ = $(ODIR)/$(MAIN) $(ODIR)/ulas.o $(ODIR)/archs.o $(ODIR)/uldas.o
+CCOBJ=$(CC) -c -o $@ $< $(CFLAGS) $(LDFLAGS)
 
 all: bin test
 
 release: 
        make DBGCFLAGS="" DBGLDFLAGS=""
 
-$(ODIR)/%.o: src/%.c src/*.h
-       mkdir -p $(@D)
-       $(CC) -c -o $@ $< $(CFLAGS) $(LDFLAGS)
 
-bin: $(OBJ)
-       mkdir -p $(BDIR)
-       $(CC) -o $(BDIR)/$(BNAME) $^ $(CFLAGS) $(LDFLAGS)
+main.o: src/main.c
+       $(CCOBJ)
+test.o: src/test.c
+       $(CCOBJ)
+ulas.o: src/ulas.c
+       $(CCOBJ)
+uldas.o: src/uldas.c
+       $(CCOBJ)
+archs.o: src/archs.c
+       $(CCOBJ)
+       
 
-test:
-       echo "building tests"
-       make bin MAIN=$(TEST_MAIN) BNAME=$(TEST_BNAME) ODIR=$(TEST_ODIR) LIBS=$(TEST_LIBS)
+bin: main.o $(OBJS) 
+       $(CC) -o $(NAME) main.o $(OBJS) $(CFLAGS) $(LDFLAGS)
 
-.PHONY: clean
+test: test.o $(OBJS) 
+       $(CC) -o $(TEST_NAME) test.o $(OBJS) $(CFLAGS) $(LDFLAGS)
 
+.PHONY: clean
 clean:
-       rm -f ./$(ODIR)/*.o
-       rm -f ./$(TEST_ODIR)/*.o
-       rm -f ./$(BDIR)/$(BNAME)
-       rm -f ./$(BDIR)/$(TEST_BNAME)
+       rm -f ./*.o
+       rm -f ./$(NAME)
+       rm -f ./$(TEST_NAME)
 
 .PHONY: install 
-
 install:
-       cp ./$(BDIR)/$(BNAME) $(BIN_INSTALL_DIR)
-       cp ./doc/$(BNAME).1 $(MAN_INSTALL_DIR)
+       cp ./$(NAME) $(INSTALL_DIR)/bin
+       cp ./man/$(NAME).1 $(INSTALL_DIR)/man
 
 .PHONY: tags 
 tags:
-       ctags --recurse=yes --exclude=.git --exclude=bin --exclude=obj --extras=*  --fields=*  --c-kinds=* --language-force=C  $(TAG_LIBS) .
+       ctags --recurse=yes --exclude=.git --exclude=bin --exclude=obj --extras=*  --fields=*  --c-kinds=* --language-force=C  .
 
-.PHONY:
+.PHONY: ccmds
 ccmds:
        bear -- make SHELL="sh -x -e" --always-make
 
 .PHONY: format
 format:
-       clang-format -i ./src/*.c ./src/*.h
+       clang-format -i src/*.c src/*.h
 
 .PHONY: lint 
 lint:
-       clang-tidy ./src/*.h ./src/*.c
+       clang-tidy src/*.h src/*.c
 
-buildtests:
-       ./$(BDIR)/$(BNAME) tests/t0.s -l - -o tests/t0.bin
-       ./$(BDIR)/$(BNAME) tests/t0.bin -d - -o tests/t0_dasm.s
+buildtests: $(NAME)
+       ./$(NAME) tests/t0.s -l - -o tests/t0.bin
+       ./$(NAME) tests/t0.bin -d - -o tests/t0_dasm.s
diff --git a/man/ulas.1 b/man/ulas.1
new file mode 100644 (file)
index 0000000..83a566b
--- /dev/null
@@ -0,0 +1,80 @@
+.\" Manpage for ulas.
+.\" Contact lukas@krickl.dev to correct errors or typos.
+
+.TH man 1 "21 August 2023" "0.0.1" "ulas manual"
+
+.SH NAME
+  ulas
+.SH SYNOPSIS
+  ulas [-hvV] 
+.SH DESCRIPTION
+  ulas
+
+  -h                    
+    display this help and exit
+  -v                 
+    display version info and exit
+  -v, --verbose             
+    verbose output
+.SH PREPROCESSOR 
+
+The preprocessor is a text based way of modifying the input before 
+the assembly step. Stray tokens after a directive are ignored!
+
+Preprocessor directives start with a # and have to be the first non-space character in a line.
+All lines that are not a preprocessor directive, or are not part of a preprocessor block (macro, or if)
+will be output as-is. If a line contains the name of a preprocessot define or macro 
+,surrounded by token any character that is not alphanumeric or an underscore,
+the define or macro will be expanded.
+
+Withing preprocessor macros 
+- $0 will expand to the literal argument string 
+- $1 to $9 will expand to the comma separated arguments of the macro 
+- $$ will insert a unique numeric literal 
+
+Macros:
+
+#macro my_macro
+label$$:
+  adc $1, $2
+#endmacro
+
+my_macro a, b
+
+Define:
+
+#define name value 
+name ; will be replaced with 'value'
+#undefine name
+
+.SH ASSEMBLY SYNTAX
+
+
+
+.SH EXPRESSION SYNTAX
+
+Expressions are written in Reverse Polish Notation style and evaluated based on their expected data type.
+For example when an expression expects an int type the expression will assume all values that are pushed to it 
+are integers.
+
+.SH ASSEMBLY DIRECTIVES 
+
+During assembly sometimes it is required to set certain parameters of the assembler such as the base address (represented by the $@ symbol in expressions).
+
+Valid directives:
+
+  \.org <expression>  
+    Sets the base address
+
+.SH EXAMPLES
+.SH SEE ALSO
+
+.SH BUGS
+
+.SH AUTHOR
+  Lukas Krickl (lukas@krickl.dev)
+
+.SH COPYRIGHT
+  Copyright 2023 Lukas Krickl (lukas@krickl.dev)