summaryrefslogtreecommitdiff
path: root/README.md
blob: 36c12ec097d5131e9ca2e5442aa4051fe2a164d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Maje
====

Maje is a simple utility to generate basic Makefiles for simple utilities. Maje
scans a directory tree for C source code, and builds a Makefile with proper
dependency information based on that code. The Makefile in this source tree
is itself generated by Maje.

There are a few restrictions:

- Source files must be named ending with .c.

- Only one target per source tree: a binary (identified by the source file
  containing main(), which will have the same basename without .c), or a
  library (identified by the MAJE_LIB flag (see below), or the current
  directory name if MAJE_LIB is not specified).

Usage
=====

Run Maje with:

    maje [-n]

By default, Maje will execute `make` when it is done creating the Makefile. Use
the `-n` option to prevent this.

Maje creates Makefiles with prefixes $(SRCDIR) and $(OBJDIR) for the source
directory and object directory, respectively. By default these are set to
`.` (the current directory). An out-of-tree build can be accomplished by 
first generating the Makefile in the source directory and manually specifying
the object directory as an option to `make`:

    maje -n
    mkdir obj
    make OBDIR=obj

Or:

    maje -n
    mkdir ../build
    cd ../build
    make -f ${OLDPWD}/Makefile SRCDIR=${OLDPWD}


Setting Flags
=============

Maje recognizes some flags in source code that can be automatically added into
the resulting Makefile. The following, followed by an equal sign, are copied
up to the first white space character as indicated:

    MAJE_CFLAG		Added to the CFLAGS macro
    MAJE_LDFLAG		Added to the LDFLAGS macro
    MAJE_LDLIB		Added to the LDLIBS macro
    MAJE_LIB		Used as the library basename (e.g. MAJE_LIB=foo
				will create libfoo.a and libfoo.so)

Maje will find these strings anywhere in your source file, so long as they
are followed by an equal sign, one or more characters, and a whitespace
character. Comments are a good place for them.