Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ build
obj
lux

# autotools
autom4te.cache

# Linux executables (files without extensions)
*
!*/
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
# override LDFLAGS += $(LLVM_LDFLAGS)

# # Detect platform and define commands
include config.mk
include config.default.mk

# Detect platform and define commands
ifeq ($(OS),Windows_NT)
SHELL := cmd.exe
SHELL ?= cmd.exe
MKDIR = if not exist "$(subst /,\,$1)" mkdir "$(subst /,\,$1)"
RMDIR = if exist "$(subst /,\,$1)" rmdir /s /q "$(subst /,\,$1)"
DEL = if exist "$(subst /,\,$1)" del /q "$(subst /,\,$1)"
EXE = .exe
PATHSEP = \\
else
SHELL := /bin/sh
SHELL ?= /bin/sh
MKDIR = mkdir -p $1
RMDIR = rm -rf $1
DEL = rm -f $1
Expand All @@ -30,7 +30,11 @@ endif

BIN := luma$(EXE)

.PHONY: all clean debug test llvm-test
ifneq ($(wildcard config.mk),)
include config.mk
endif

.PHONY: all clean debug test check llvm-test

all: $(BIN)

Expand All @@ -48,7 +52,10 @@ debug: all
# Test targets
test: $(BIN)
@echo "Running basic tests..."
./$(BIN) --help
./$(BIN) --help || true # non-zero exit code expected

# Alias
check: test

llvm-test: $(BIN)
@echo "Testing LLVM IR generation..."
Expand Down
10 changes: 5 additions & 5 deletions config.mk → config.default.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# config.mk
# config.default.mk

CC = g++
CFLAGS = -Wall -Wextra -std=c17 -Wno-unused-variable -O2 -x c # -x c tells g++ to treat files as C code
LDFLAGS =
INCLUDES = -Isrc
CC ?= g++
CFLAGS ?= -Wall -Wextra -std=c17 -Wno-unused-variable -O2 -x c # -x c tells g++ to treat files as C code
LDFLAGS ?=
INCLUDES ?= -Isrc

# LLVM configuration - request all necessary components
LLVM_CFLAGS := $(shell llvm-config --cflags)
Expand Down
14 changes: 14 additions & 0 deletions config.mk.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CC = @CXX@
CFLAGS += @CXXFLAGS@
LDFLAGS += @LDFLAGS@
PREFIX = @prefix@

INSTALL ?= install
DESTDIR ?= $(PREFIX)/bin

.PHONY: install

install: $(BIN)
$(INSTALL) -d $(DESTDIR)
$(INSTALL) -s -m 0755 $(BIN) $(DESTDIR)/$(BIN)
@echo "Installed to $(DESTDIR)/$(BIN)"
21 changes: 21 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
AC_INIT([luma], [git], [https://github.com/TheDevConnor/Luma])
AC_PREREQ([2.69])
AC_CONFIG_SRCDIR([src/main.c]) # sanity check to make sure someone didn't pass a garbage --srcdir
#AM_INIT_AUTOMAKE([foreign 1.16 dist-bzip2])

AC_PROG_CXX
AC_LANG(C++)
AC_SUBST(CXX)
# connor, i have no idea why you're expecting CC to be a C++ compiler.
# that's what CXX is for.

CXXFLAGS="$CXXFLAGS $CFLAGS $CPPFLAGS" # grab any env for flags
LDFLAGS="$LDFLAGS"
AC_SUBST(CXXFLAGS)
AC_SUBST(LDFLAGS)

AC_PREFIX_DEFAULT(/usr/local)
AC_SUBST(prefix)

AC_CONFIG_FILES([config.mk])
AC_OUTPUT
41 changes: 41 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ stdenv
, pkg-config
, llvmPackages
, autoconf
, doxygen
, graphviz-nox
}:

llvmPackages.stdenv.mkDerivation {
pname = "luma";
version = "0.0.0"; # TODO: versioning

src = ./.;

nativeBuildInputs = [
pkg-config
autoconf
doxygen
graphviz-nox
];

outputs = [
"out"
"doc"
];

preConfigure = ''
autoconf
'';

postInstall = ''
doxygen Doxyfile
mv docs/doxygen $doc
'';

buildInputs = [
llvmPackages.libllvm
];

doCheck = true;
}
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
description = "Luma";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = rec {
default = luma;
luma = pkgs.callPackage ./default.nix { };
};
}
);
}