vfnmake - a relatively simple Makefile generator
vfnmake [ -f file ] [ -d dir ] [ options ]
vfnmake --version
vfnmake works on fire-and-forget basis with as few configuration as possible. It does not try to compete with CMake or Autotools (yet ;) ). I wrote it because writing Makefiles, while not difficult, can be really tedious even for the simple projects. Some features may seem strange but keep in mind that I write it mostly for myself.
To enable linking with Assembly, use --asm32/--asm64 options.
Qt4 is kind of supported (--qt option) but you have to rename your headers that use QObject so they will end with _qt.hpp.
For the complete list of arguments, see below.
- -h, --help
-
Display the brief version of this help.
- --man
-
Display the full version of this help.
- --name name
-
Specify the name of the executable file. Default: a.out
- --src dir
-
Specify the directory with the source. Default: src/ or ./
- --objs dir
-
Specify the directory for the *.o files. Default: objs/
- --bin dir
-
Specify the directory for the executable file. Default: ./
- -c flag, --cflag flag (add)
- -C flag, --Cflag flag (remove)
-
Add/remove a compilation flag.
- --cflags comma_separated_list_of_flags
-
Overwrite the previous cflags.
- -O n
-
Set the optimization level.
- -l library, --lib library (add)
- -L library, --Lib library (remove)
-
Add/remove a library to link.
- --libs comma_separated_list_of_libraries
-
Overwrite the previous libraries.
- -p package, --pkg package (add)
- -P package, --Pkg package (remove)
-
Add/remove a package for pkg-config.
- --pkgs comma_separated_list_of_packages
-
Overwrite the previous packages.
- --lflag flag (add)
- --Lflag flag (remove)
-
Add/remove a linker flag.
- --lflags comma_separated_list_of_flags
-
Overwrite the previous lflags.
- --noe, --no-echo
- -e, --echo
-
Print the executed commands or not. Default: --no-echo
- --no-std
- --std standard
-
Set language standard (-std compiler flag, see your compiler's manpage for list of available options).
- --c99
-
Use C99 standard (alias to --std=c99).
- --c11
-
Use C11 standard (alias to --std=c11).
- --cpp0x
-
(deprecated) Use C++11 standard (alias to --std=c++11).
- --cpp11
-
Use C++11 standard (alias to --std=c++11).
- --cpp1y
-
Use C++1y standard (alias to --std=c++1y).
- --no-asm32
- --asm32
-
Enable 32-bit Assembly support (only nasm). Default: --no-asm
- --no-asm64
- --asm64
-
Enable 64-bit Assembly support (only nasm). Default: --no-asm64
- --no-asm
- --asm
-
alias to --asm32
- --no-qt
- --qt
-
Enable Qt4 meta-object support for files named *_qt.hpp and add some useful flags. Default: --no-qt
- -v, --verbose
-
Do print the config variables.
- --stdout
-
Print the Makefile to the stdout instead of saving in the file so it can be piped directly to make ("vfnmake --stdout | make -f -").
- -f file, --file file
-
Use file instead of vfnmake.conf as the config file. Default: vfnmake.conf
- -d dir, --chdir dir
-
Use dir as the working directory.
- -r, --run
-
Run make automatically. It can do various other things depending on the times it is specified:
-r - just run make
-rr - run make and then the compiled program
-rrr - run make clean and make
-rrrr - run make clean, make, and the compiled program
You can specify the arguments for make after "--" to override this behavior.
- -g, --force-generate
-
Generate the Makefile even if there are no C/C++ files (used mainly with vfnmake.begin/end).
- --no-legacy
- --legacy
-
Enable/disable compatibility mode with the older versions of GNU Make and older software in general. It effectively disables debugging options and explicitly uses gcc/g++.
- --configure
-
Generates the configure.pl script. To be specific, it just copies itself to the current directory.
- all
-
default options
- debug (d)
-
compile with -g3 flag, O0 optimization and DEBUG macro
- clean (c)
-
delete all compilation results
- fresh (f)
-
force full recompilation (equivalent of 'make clean && make')
- run (r)
-
compile and run
The config files are read from /etc/vfnmake.conf, ~/.vfnmake.conf and vfnmake.conf in that order. The vfnmake.conf in the working directory is automatically modified on each run. Additionaly there are two other files - vfnmake.begin and vfnmake.end. Their role is described below.
#version: version
libs: lib1 lib2 ...
pkgs: pkg1 pkg2 ...
O: 0|1|2|3|s
std: c99|c++11|...
cflags: flag1 flag2 ...
debug_cflags: flag1 flag2 ...
lflags: flag1 flag2 ...
name: name
src_directory: dir
bin_directory: dir
objs_directory: dir
echo: 0|1
asm: 0|32|64
qt: 0|1
To use the default value, leave the field empty.
Currently there is no way to set custom "debug_cflags" without modifying the config file manually.
Whatever is in this file, will be in the Makefile right after the initialization of the variables. Can be used to override the variables or the default target.
Just like vfnmake.begin but is put at the end of the Makefile. Can be used to add some custom targets without affecting the default one.
To generate a Makefile for a program not using any external libraries with no compilation flags just type:
vfnmake
You can add -r to turn vfnmake into the automagic make - it will run the generated Makefile afterwards:
vfnmake -r
You can specify the make target (for example debug) for the -r flag in the following way (note the space after "--"!):
vfnmake -r -- debug
If you need to link the ncurses library and want to use the -Wall flag, use this:
vfnmake --lib=ncurses --cflag=-Wall
IMPORTANT:
THE CONFIG FILES FROM 1.2.0 ARE *NOT* COMPATIBLE
the compiler is not selected by vfnmake; use "export CC=your_C_compiler" and "export CXX=your_C++_compiler" before running make
CXXFLAGS; CFLAGS are used for both C and C++
THE GLORIOUS RETURN OF SIMPLICITY!!!
If you do need any of the removed features, email me, I'll see what I can do.
vfnmake was written by Wojciech 'vifon' Siewierski <darkvifon at gmail dot com>.
Thanks to Tadeusz Sośnierz for some advices and fixes, Maciej Grzybek for some ideas and Mateusz Makowski for bug reports.
make(1)
Copyright (C) 2011-2013 Wojciech Siewierski, Aleksander Nitecki
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.