Skip to content

Commit

Permalink
build and license
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean committed Dec 6, 2016
1 parent e4d552d commit ad26e05
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 2 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2016 Sean
Copyright (c) 2016 Sean Connelly (@voidqk, web: syntheti.cc)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
84 changes: 84 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

set -e

pushd "$(dirname "$0")" > /dev/null
SCRIPT_DIR="$(pwd)"
popd > /dev/null
SRC_DIR=$SCRIPT_DIR/src
TGT_DIR=$SCRIPT_DIR/tgt

#
# change these functions if you want to build the C files differently
#

compile_c() { # production compile
# $1 : the input .c file
# $2 : the output .o file
if which clang > /dev/null; then
clang -c -o "$2" -fwrapv -Werror "$1"
else
echo 'ERROR:'
echo 'Missing "clang" which is required for building.'
echo ''
echo 'Aborting build.'
echo ''
echo 'You can install "clang" by visiting:'
echo ' http://llvm.org/'
echo ''
exit 1
fi
}

compile_c_debug() { # debug compile (should define SINK_DEBUG)
# $1 : the input .c file
# $2 : the output .o file
clang -c -o "$2" -fwrapv -g -DSINK_DEBUG "$1"
}

link_c() { # production link
# $1 : the input .o files (space separated list)
# $2 : the output binary file
clang -o "$2" $1
}

link_c_debug() { # debug link
# $1 : the input .o files (space separated list)
# $2 : the output binary file
clang -o "$2" $1
}

#
# ---
#

LINK_FILES=()
BUILD_DEBUG=0
comp_and_link() {
# $1 : the input .c file
# $2 : the output .o file
if [ "$BUILD_DEBUG" = "1" ]; then
echo "Compiling $(basename "$1") (debug)..."
compile_c_debug "$1" "$2"
else
echo "Compiling $(basename "$1")..."
compile_c "$1" "$2"
fi
LINK_FILES=("${LINK_FILES[@]}" "$2")
}

link_finish() {
# $1 : the output binary
if [ "$BUILD_DEBUG" = "1" ]; then
echo 'Linking (debug)...'
link_c_debug "${LINK_FILES[*]}" "$1"
else
echo 'Linking...'
link_c "${LINK_FILES[*]}" "$1"
fi
}

mkdir -p $TGT_DIR

comp_and_link src/main.c $TGT_DIR/main.o
link_finish $TGT_DIR/sndfilter
12 changes: 12 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc
// MIT License
// Project Home: https://github.com/voidqk/sndfilter

// main entry point, responsible for parsing command line parameters

#include <stdio.h>

int main(int argc, char **argv){
printf("hello, world\n");
return 0;
}

0 comments on commit ad26e05

Please sign in to comment.