Created
June 1, 2015 20:58
-
-
Save mortehu/d428b07d12953785a2ef to your computer and use it in GitHub Desktop.
Script to generate minimal Makefile.am and configure.ac for a C++ project
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
#!/bin/bash | |
echo "Press Ctrl-C at any time to abort Makefile generation" | |
echo | |
echo "The project name should start with a letter and contain nothing but " | |
echo "letters (A-z), digits (0-9) and dashes ('-'). Do not include the " | |
echo "version number." | |
echo | |
echo "Example: hello-world" | |
echo | |
echo -n "Project name: " | |
read NAME | |
echo | |
echo -n "Version number (example: 1.0.0): " | |
read VERSION | |
SOURCES=`find -name \*.h -or -name \*.hh -or -name \*.hpp -or -name \*.hxx -or -name \*.cc -or -iname \*.c -or -name \*.cpp -or -name \*.cxx -or -name \*.m -or -name \*.i -or -name \*.ii -or -iname \*.s -type f | sed 's,^\./,,' | tr '\n' ' '` | |
if [ x"$SOURCES" = x ] | |
then | |
echo "Error no sources were found (.cc, .c, .C, .cpp, .cxx, .m, .i, .ii, .s, .S)" | |
exit 1 | |
fi | |
echo | |
echo "The following sources will be included: " | |
echo "$SOURCES" | |
echo | |
echo -n "Press enter to continue..." | |
read | |
cat > configure.ac <<EOF | |
AC_INIT($NAME,$VERSION) | |
AM_INIT_AUTOMAKE([-Wall -Werror foreign]) | |
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) | |
AC_PROG_CC | |
AC_PROG_CXX | |
AC_PROG_INSTALL | |
AC_PROG_MAKE_SET | |
AC_OUTPUT(Makefile) | |
EOF | |
BNAME=`echo -n "$NAME"_SOURCES | sed 's/[-\.]/_/g'` | |
cat > Makefile.am <<EOF | |
bin_PROGRAMS = $NAME | |
$BNAME = $SOURCES | |
EOF | |
autoreconf -i -f || exit 1 | |
./configure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment