Revision d85a58fe

View differences:

Makefile
5 5
BIN = $(MN)
6 6
PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN)
7 7
MNEXEC = mnexec
8
MANPAGE = mn.1
8
MANPAGES = mn.1 mnexec.1
9 9
P8IGN = E251,E201,E302,E202
10 10
BINDIR = /usr/bin
11 11
MANDIR = /usr/share/man/man1
......
13 13
all: codecheck test
14 14

  
15 15
clean:
16
	rm -rf build dist *.egg-info *.pyc $(MNEXEC) $(MANPAGE)
16
	rm -rf build dist *.egg-info *.pyc $(MNEXEC) $(MANPAGES)
17 17

  
18 18
codecheck: $(PYSRC)
19 19
	-echo "Running code check"
......
41 41
	install $(MANPAGE) $(MANDIR)
42 42
	python setup.py develop
43 43

  
44
man: $(MANPAGE)
44
man: $(MANPAGES)
45 45

  
46
$(MANPAGE): $(MN)
46
mn.1: $(MN)
47 47
	PYTHONPATH=. help2man -N -n "create a Mininet network." \
48
    --no-discard-stderr $(MN) \
49
    -o $@
48
	--no-discard-stderr $< -o $@
49

  
50
mnexec: mnexec.c $(MN) mininet/net.py
51
	cc -DVERSION=\"`$(MN) --version`\" $< -o $@
52

  
53
mnexec.1: mnexec
54
	help2man -N -n "execution utility for Mininet." \
55
	-h "-h" -v "-v" --no-discard-stderr ./$< -o $@ 
50 56

  
51 57
doc: man
52 58
	doxygen doxygen.cfg
bin/mn
89 89

  
90 90
def version( *_args ):
91 91
    "Print Mininet version and exit"
92
    print "mn (Mininet %s)" % VERSION
92
    print "%s" % VERSION
93 93
    exit()
94 94

  
95 95
class MininetRunner( object ):
mnexec.c
23 23
#include <limits.h>
24 24
#include <sched.h>
25 25

  
26
#if !defined(VERSION)
27
#define VERSION "(devel)"
28
#endif
29

  
26 30
void usage(char *name) 
27 31
{
28
    printf("Execution utility for Mininet.\n"
29
           "usage: %s [-cdnp] [-a pid] [-g group] [-r rtprio] cmd args...\n"
30
           "-c: close all file descriptors except stdin/out/error\n"
31
           "-d: detach from tty by calling setsid()\n"
32
           "-n: run in new network namespace\n"
33
           "-p: print ^A + pid\n"
34
           "-a pid: attach to pid's network namespace\n"
35
           "-g group: add to cgroup\n"
36
           "-r rtprio: run with SCHED_RR (usually requires -g)\n",
32
    printf("Execution utility for Mininet\n\n"
33
           "Usage: %s [-cdnp] [-a pid] [-g group] [-r rtprio] cmd args...\n\n"
34
           "Options:\n"
35
           "  -c: close all file descriptors except stdin/out/error\n"
36
           "  -d: detach from tty by calling setsid()\n"
37
           "  -n: run in new network namespace\n"
38
           "  -p: print ^A + pid\n"
39
           "  -a pid: attach to pid's network namespace\n"
40
           "  -g group: add to cgroup\n"
41
           "  -r rtprio: run with SCHED_RR (usually requires -g)\n"
42
           "  -v: print version\n",
37 43
           name);
38 44
}
39 45

  
......
92 98
    int nsid;
93 99
    int pid;
94 100
    static struct sched_param sp;
95
    while ((c = getopt(argc, argv, "+cdnpa:g:r:")) != -1)
101
    while ((c = getopt(argc, argv, "+cdnpa:g:r:vh")) != -1)
96 102
        switch(c) {
97 103
        case 'c':
98 104
            /* close file descriptors except stdin/out/error */
......
152 158
                return 1;
153 159
            }
154 160
            break;
161
        case 'v':
162
            printf("%s\n", VERSION);
163
            exit(0);
164
        case 'h':
165
            usage(argv[0]);
166
            exit(0);
155 167
        default:
156 168
            usage(argv[0]);
157
            break;
169
            exit(1); 
158 170
        }
159 171

  
160 172
    if (optind < argc) {

Also available in: Unified diff