-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from rajamukherji/dev
Dev
- Loading branch information
Showing
8 changed files
with
319 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,6 @@ | ||
-- ROOT -- | ||
:< ROOT >: | ||
|
||
PLATFORM := defined("PLATFORM") or shell("uname"):trim | ||
OS := defined("OS") | ||
DEBUG := defined("DEBUG") | ||
|
||
CFLAGS := ['-g'] | ||
LDFLAGS := ['-g'] | ||
ARFLAGS := [] | ||
PREBUILDS := [] | ||
|
||
if not DEBUG then | ||
CFLAGS := old + ['-O2'] | ||
end | ||
|
||
c_compile := fun(Object) do | ||
var Source := Object % "c" | ||
execute('gcc -c {CFLAGS} -o{Object} {Source}') | ||
end | ||
|
||
c_includes := fun(Target) do | ||
var Files := [] | ||
var Lines := shell('gcc -c {CFLAGS} -M -MG {Target:source}') | ||
var Files := Lines:trim:replace(r"\\\n ", "") / r"[^\\]( +)" | ||
Files:pop | ||
for File in Files do | ||
File := file(File:replace(r"\\ ", " ")) | ||
end | ||
return Files | ||
end | ||
|
||
SourceTypes := { | ||
"c" is [c_includes, c_compile] | ||
} | ||
|
||
c_program := fun(Executable, Objects, Libraries) do | ||
Objects := Objects or [] | ||
Libraries := Libraries or [] | ||
var Sources := [] | ||
for Object in Objects do | ||
for Extension, Functions in SourceTypes do | ||
var Source := Object % Extension | ||
if Source:exists then | ||
Sources:put(Source) | ||
var Scan := Source:scan("INCLUDES", :true)[PREBUILDS] => Functions[1] | ||
Object[Source, Scan] => Functions[2] | ||
exit | ||
end | ||
end | ||
end | ||
Executable[Objects, Libraries] => fun(Executable) do | ||
execute('gcc', '-o', Executable, Objects, Libraries, LDFLAGS) | ||
DEBUG or execute('strip', Executable) | ||
end | ||
DEFAULT[Executable] | ||
end | ||
|
||
c_library := fun(Library, Headers, Objects) do | ||
Objects := Objects or [] | ||
var Sources := [] | ||
for Object in Objects do | ||
for Extension, Functions in SourceTypes do | ||
var Source := Object % Extension | ||
if Source:exists then | ||
Sources:put(Source) | ||
var Scan := Source:scan("INCLUDES", :true)[PREBUILDS] => Functions[1] | ||
Object[Source, Scan] => Functions[2] | ||
exit | ||
end | ||
end | ||
end | ||
Library[Objects] => fun(Library) do | ||
execute('ar rcs', Library, Objects, ARFLAGS) | ||
end | ||
DEFAULT[Library] | ||
for var Header in Headers do | ||
var Target := (INC_DIR / (Header - PATH))[Header] => fun(Target) do | ||
Header:copy(Target) | ||
end | ||
DEFAULT[Target] | ||
end | ||
end | ||
|
||
PREFIX := old or PATH | ||
|
||
print('PREFIX = {PREFIX}\n') | ||
|
||
BIN_DIR := old or (PREFIX / "bin"):mkdir | ||
LIB_DIR := old or (PREFIX / "lib"):mkdir | ||
INC_DIR := old or (PREFIX / "include"):mkdir | ||
%include common.rabs | ||
|
||
vmount("obj", "src") | ||
subdir("obj") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
PLATFORM := defined("PLATFORM") or shell("uname"):trim | ||
DEBUG := defined("DEBUG") | ||
|
||
CFLAGS := [] | ||
LDFLAGS := [] | ||
PREBUILDS := [] | ||
|
||
pkgconfig := fun(Args) do | ||
expr('pkg-config {Args}') => fun() shell('pkg-config', Args):trim | ||
end | ||
|
||
c_compile := fun(Source, Object) do | ||
execute('cc -c {CFLAGS} -o{Object} {Source}') | ||
end | ||
|
||
c_includes := fun(Target) do | ||
var Lines := shell('cc -c {CFLAGS} -M -MG {Target:source}') | ||
Lines := Lines:replace(r"\\\n ", "") | ||
Lines := Lines[Lines:find(": ") + 2, 0]:trim | ||
var Files := Lines / r"[^\\]( +)" | ||
for File in Files do | ||
File := file(File:replace(r"\\ ", " ")) | ||
end | ||
return Files | ||
end | ||
|
||
var SourceTypes := { | ||
"c" is [c_includes, c_compile] | ||
} | ||
|
||
c_program := fun(Executable, Objects, Libraries) do | ||
Objects := Objects or [] | ||
Libraries := Libraries or [] | ||
var Sources := [] | ||
for Object in Objects do | ||
for Extension, Functions in SourceTypes do | ||
var Source := Object % Extension | ||
if Source:exists then | ||
Sources:put(Source) | ||
var Scan := Source:scan("INCLUDES")[PREBUILDS] => Functions[1] | ||
Object[Source, Scan] => (Functions[2] !! [Source]) | ||
exit | ||
end | ||
end | ||
end | ||
Executable[Objects, Libraries] => fun(Executable) do | ||
execute('cc', '-o', Executable, Objects, Libraries, LDFLAGS) | ||
end | ||
DEFAULT[Executable] | ||
ret Executable | ||
end | ||
|
||
c_library := fun(Library, Objects, Libraries) do | ||
Objects := Objects or [] | ||
Libraries := Libraries or [] | ||
var Sources := [] | ||
for Object in Objects do | ||
for Extension, Functions in SourceTypes do | ||
var Source := Object % Extension | ||
if Source:exists then | ||
Sources:put(Source) | ||
var Scan := Source:scan("INCLUDES")[PREBUILDS] => Functions[1] | ||
Object[Source, Scan] => (Functions[2] !! [Source]) | ||
exit | ||
end | ||
end | ||
end | ||
Library[Objects, Libraries] => fun(Executable) do | ||
execute('ar', 'rcs', Library, Objects, Libraries) | ||
end | ||
DEFAULT[Library] | ||
ret Library | ||
end | ||
|
||
PREFIX := old or file('{getenv("DESTDIR") or ""}{defined("PREFIX") or "/usr/local"}') | ||
INSTALL := meta("install") | ||
|
||
install := fun(Source, Target, Mode) do | ||
Target[Source] => fun(Target) do | ||
print(Source, " -> ", Target, "\n") | ||
Target:dir:mkdir | ||
Source:copy(Target) | ||
Mode and execute("chmod", Mode, Target) | ||
end | ||
INSTALL[Target] | ||
ret Target | ||
end | ||
|
||
TEST := meta("test") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
c_library(LIB_DIR / "libramp.a", [file("ramp.h")], [file("ramp.o")]) | ||
CFLAGS := old + ["-g"] | ||
LDFLAGS := old + ["-g"] | ||
|
||
if defined("DEBUG") then | ||
CFLAGS := old + ["-DDEBUG"] | ||
else | ||
CFLAGS := old + ["-O3"] | ||
end | ||
|
||
LIBRAMP := c_library(file("libramp.a"), [file("ramp.o")]) | ||
|
||
if defined("TEST_RAMP") then | ||
subdir("test") | ||
end | ||
|
||
var InstallBin := PREFIX / "bin" | ||
var InstallInclude := PREFIX / "include/ramp" | ||
var InstallLib := PREFIX / "lib" | ||
|
||
var InstallHeaders := [ | ||
"ramp.h" | ||
] | ||
|
||
for Header in InstallHeaders do | ||
install(file(Header), InstallInclude / Header) | ||
end | ||
|
||
install(file("libramp.a"), InstallLib / "libramp.a") |
Oops, something went wrong.