-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b559114
commit 6c6d1e6
Showing
2 changed files
with
64 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This Makefile is used for compiling C sources generated by Nim | ||
CC ?= gcc | ||
|
||
SOURCES := $(shell ls -S *.c) | ||
OBJECTS = $(SOURCES:.c=.o) | ||
TOTAL = $(words $(SOURCES)) | ||
EXECUTABLE = frameos | ||
LIBS = -pthread -lm -lm -lrt -ldl | ||
CFLAGS = -w -fmax-errors=3 -pthread -O3 -fno-strict-aliasing -fno-ident -fno-math-errno | ||
|
||
all: $(EXECUTABLE) | ||
|
||
$(EXECUTABLE): $(OBJECTS) | ||
@echo "Linking frameos" | ||
@$(CC) -o $(EXECUTABLE) $(OBJECTS) $(LIBS) | ||
|
||
clean: | ||
rm -f *.o $(EXECUTABLE) | ||
|
||
pre-build: | ||
mkdir -p ../cache | ||
|
||
$(OBJECTS): pre-build | ||
|
||
%.o: %.c | ||
@if [ ! -e $@ ]; then \ | ||
md5sum=$$(md5sum $< | awk '{print $1}'); \ | ||
file=$$(echo '$<' | sed 's/@s/\//g' | sed 's/@m//g' | sed 's/.*nimble\/pkgs2\/\(.*\)/\1/' | sed 's/.*\/\(nim\/lib\/.*\)/\1/'); \ | ||
cache_obj=../cache/$$md5sum.c.o; \ | ||
if [ -f "$$cache_obj" ]; then \ | ||
ln -s "$$cache_obj" $@; \ | ||
else \ | ||
$(CC) -c $(CFLAGS) $< -o $@; \ | ||
cp $@ "$$cache_obj"; \ | ||
echo "[$$(ls *.o | wc -l)/$(TOTAL)] $$file"; \ | ||
fi; \ | ||
fi | ||
|
||
.PHONY: all clean pre-build |