updated makefile. Now the noja interpreter is build as a library and then linked to the cli
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
# Aux functions
|
||||
rwildcard = $(foreach d, $(wildcard $(1:=/*)), $(call rwildcard ,$d, $2) $(filter $(subst *, %, $2), $d))
|
||||
|
||||
# Compiler
|
||||
CXX = gcc
|
||||
CC = $(CROSS_COMPILE)$(CXX)
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS = -O3 -Wall -Wextra -g
|
||||
LFLAGS = -lm
|
||||
|
||||
# Files and directories
|
||||
SRCDIR = src
|
||||
OBJDIR = temp
|
||||
BINDIR = build
|
||||
OUTFILE = noja
|
||||
|
||||
# Find all files
|
||||
SRC = $(call rwildcard, $(SRCDIR), *.c)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
|
||||
|
||||
|
||||
# Compile everything to object files
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c
|
||||
@ echo $(shell tput setaf 3) [C] $(shell tput setaf 5) [SRC] $(shell tput setaf 7) $^
|
||||
@ mkdir -p $(@D)
|
||||
@ $(CC) $(CFLAGS) -c $^ -o $@
|
||||
|
||||
|
||||
|
||||
# Clean all artifacts and rebuild the whole thing
|
||||
all: clean $(OBJS) build
|
||||
|
||||
# Link all object files
|
||||
build:
|
||||
@ echo !==== LINKING
|
||||
@ mkdir -p $(BINDIR)
|
||||
@ $(CC) -o $(BINDIR)/$(OUTFILE) $(OBJS) $(LFLAGS)
|
||||
|
||||
clean:
|
||||
@ rm -rf $(BINDIR)
|
||||
@ rm -rf $(OBJDIR)
|
||||
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,87 @@
|
||||
|
||||
# ===================== #
|
||||
# === Configuration === #
|
||||
# ===================== #
|
||||
|
||||
# Destination folder of the final artifacts
|
||||
# (it must exist beforehand)
|
||||
OUTDIR = .
|
||||
|
||||
# Base folder of the source tree
|
||||
SRCDIR = src
|
||||
|
||||
# Temporary directory where all intermediary
|
||||
# artifacts will be stored (if it doesn't exist,
|
||||
# it will be created). It's important that this
|
||||
# folder isn't used for something other than
|
||||
# holding object files since it will be deleted
|
||||
# when doing `make clean`.
|
||||
OBJDIR = cache
|
||||
|
||||
# Source directory for each program to be build
|
||||
# They are relative to the SRCDIR folder.
|
||||
LIB_SUBDIR = noja
|
||||
CLI_SUBDIR = cli
|
||||
|
||||
# Resulting file names
|
||||
LIB_FNAME = libnoja.a
|
||||
CLI_FNAME = noja
|
||||
|
||||
# Default programs
|
||||
CC = gcc
|
||||
AR = ar
|
||||
|
||||
# Program flags
|
||||
CFLAGS = -Wall -Wextra
|
||||
LFLAGS = -lm
|
||||
|
||||
# ===================== #
|
||||
# === Variables ======= #
|
||||
# ===================== #
|
||||
|
||||
# Auxiliary function
|
||||
rwildcard = $(foreach d, $(wildcard $(1:=/*)), $(call rwildcard ,$d, $2) $(filter $(subst *, %, $2), $d))
|
||||
|
||||
# Absolute path of each program's source tree
|
||||
LIB_SRCDIR = $(SRCDIR)/$(LIB_SUBDIR)
|
||||
CLI_SRCDIR = $(SRCDIR)/$(CLI_SUBDIR)
|
||||
|
||||
# Each program that is being build uses as object
|
||||
# cache a subfolder of OBJDIR called like the it's
|
||||
# source tree base folder in SRCDIR.
|
||||
LIB_OBJDIR = $(OBJDIR)/$(LIB_SUBDIR)
|
||||
CLI_OBJDIR = $(OBJDIR)/$(CLI_SUBDIR)
|
||||
|
||||
LIB_CFILES = $(call rwildcard, $(LIB_SRCDIR), *.c)
|
||||
LIB_HFILES = $(call rwildcard, $(LIB_SRCDIR), *.h)
|
||||
LIB_OFILES = $(patsubst $(LIB_SRCDIR)/%.c, $(LIB_OBJDIR)/%.o, $(LIB_CFILES))
|
||||
|
||||
CLI_CFILES = $(call rwildcard, $(CLI_SRCDIR), *.c)
|
||||
CLI_HFILES = $(call rwildcard, $(CLI_SRCDIR), *.h)
|
||||
CLI_OFILES = $(patsubst $(CLI_SRCDIR)/%.c, $(CLI_OBJDIR)/%.o, $(CLI_CFILES))
|
||||
|
||||
# Useful abbreviations
|
||||
LIB = $(OUTDIR)/$(LIB_FNAME)
|
||||
CLI = $(OUTDIR)/$(CLI_FNAME)
|
||||
|
||||
# ===================== #
|
||||
# === Rules =========== #
|
||||
# ===================== #
|
||||
|
||||
all: $(LIB) $(CLI)
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c
|
||||
@ mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) -c $^ -o $@
|
||||
|
||||
$(LIB): $(LIB_OFILES)
|
||||
@ echo $(AR) rcs $@ ...
|
||||
@ $(AR) rcs $@ $(LIB_OFILES)
|
||||
|
||||
$(CLI): $(CLI_OFILES) $(LIB)
|
||||
$(CC) $^ -o $@ $(LFLAGS)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)
|
||||
rm -f $(LIB)
|
||||
rm -f $(CLI)
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "libnoja/noja.h"
|
||||
#include "../noja/noja.h"
|
||||
|
||||
static const char usage[] =
|
||||
"Usage patterns:\n"
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
typedef struct NOJA_Executable NOJA_Executable;
|
||||
char *NOJA_disassemble(NOJA_Executable *exe);
|
||||
NOJA_Executable *NOJA_assembleString(const char *str);
|
||||
NOJA_Executable *NOJA_assembleFile(const char *file);
|
||||
NOJA_Executable *NOJA_compileString(const char *str);
|
||||
NOJA_Executable *NOJA_compileFile(const char *file);
|
||||
bool NOJA_compareExecutables(NOJA_Executable *exe1, NOJA_Executable *exe2);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user