Created
November 24, 2014 10:29
-
-
Save ElectricCoffee/00b2c22d489c83409f7c to your computer and use it in GitHub Desktop.
convenience functions for dealing with c compilation
This file contains hidden or 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
#!/bin/bash | |
function compile-c() { | |
if [ $# -eq 0 ] | |
then INPUT="*.c" | |
else INPUT="$1.c" | |
fi | |
gcc -ansi -pedantic -Wall -Werror $INPUT -o program | |
} | |
function make-makefile() { | |
if [ -f makefile ] | |
then echo "makefile already exists." | |
else | |
echo "creating makefile..." | |
touch makefile | |
echo "# Basic makefile for the project" > makefile | |
echo "CC = gcc" >> makefile | |
echo "CFLAGS = -ansi -pedantic -Wall -Werror" >> makefile | |
echo ".PHONY: clean" >> makefile | |
echo -en '\n' >> makefile | |
echo "program: %.o" >> makefile | |
echo -e '\t$(CC) *.o -o program\n' >> makefile | |
echo "%.o:" >> makefile | |
echo -e '\t$(CC) $(CFLAGS) *.c -c\n' >> makefile | |
echo "clean:" >> makefile | |
echo -e '\trm -f *.o *~ program' >> makefile | |
echo "makefile created." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment