Skip to content

Instantly share code, notes, and snippets.

@sebix
Created March 7, 2012 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sebix/1992299 to your computer and use it in GitHub Desktop.
Save sebix/1992299 to your computer and use it in GitHub Desktop.
Initialize empty cpp-project with sample Makefile
#!/bin/bash
# Version: 07.03.2012 11:00
# Author: sebix (https://github.com/sebix)
# URL: https://gist.github.com/gists/1992299
if [ $# -lt 1 ]; then
echo "Name not given!"
exit
fi
mkdir "$1"
cd "$1"
echo "NAME = $1
CFLAGS = -Wall -O3 -pedantic -pedantic-errors -std=c++0x
CC = g++
$1: clean
\$(CC) \$(NAME).cpp \$(CFLAGS) -o \$(NAME)
debug: clean
\$(CC) \$(NAME).cpp \$(CFLAGS) -o \$(NAME) -g
clean:
if [ -f \$(NAME) ]; then\
rm \$(NAME);\
fi" > Makefile
echo "#include <cstdio>
using namespace std;
int main ( void ) {
int n;
scanf(\"%d\", &n);
printf(\"%d\n\", n);
return 0;
}" > $1.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment