summaryrefslogtreecommitdiffstats
path: root/buildrun.cxx
blob: 151c5ecdf676b5203d45426e048623b53098b052 (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
// build/run probes
// Copyright (C) 2005 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.

#include "config.h"
#include "buildrun.h"

#include <fstream>

using namespace std;


int
compile_pass (systemtap_session& s)
{
  // fill in a quick Makefile
  if (1)
    {
      // Assumes linux 2.6 kbuild
      string makefile_nm = s.tmpdir + "/Makefile";
      ofstream o (makefile_nm.c_str());
      o << "CFLAGS += -Werror" << endl;
      if (s.test_mode)
        o << "CFLAGS += -I \"" << s.runtime_path << "/user\"" << endl;
      o << "CFLAGS += -I \"" << s.runtime_path << "\"" << endl;
      o << "CFLAGS += -I \"" << s.runtime_path << "/relayfs\"" << endl;
      o << "obj-m := " << s.module_name << ".o" << endl;
    }

  // run module make
  string module_dir = string("/lib/modules/") + s.kernel_release + "/build";
  string make_cmd = string("make")
    + string (" -C \"") + module_dir + string("\"");
  if (! s.verbose) make_cmd += " -s";
  make_cmd += string(" M=\"") + s.tmpdir + string("\" modules");

  if (s.verbose) clog << "Running " << make_cmd << endl;
  int rc = system (make_cmd.c_str());


  if (s.verbose) clog << "Pass 4: compiled into \""
                      << s.module_name << ".ko"
                      << "\"" << endl;

  return rc;
}


int
run_pass (systemtap_session& s)
{
  return 1;
}