-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile.gen.py
More file actions
65 lines (47 loc) · 1.72 KB
/
makefile.gen.py
File metadata and controls
65 lines (47 loc) · 1.72 KB
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
62
63
64
#!/usr/bin/python
import sys, getopt
try:
opts, args = getopt.getopt(sys.argv[1:], '', ['module=','defines='])
opts = dict(opts)
except getopt.GetoptError, err:
print >> sys.stderr, 'Could not parse command line options.'
sys.exit(1)
if '--module' not in opts:
print >> sys.stderr, 'Module parameter must be defined.'
sys.exit(1)
if '--defines' not in opts:
opts['--defines'] = ''
filename = '%s/build.cfg' % (opts['--module'])
with open(filename) as fp:
print >> sys.stdout, fp.read(),
print >> sys.stdout, '''
OBJS = $(SRCS:.c=.o)
TARGET = %(module)s.mo
DEFINES += %(defines)s -DMODULE
INCLUDES += -I. -Iinclude -I/usr/include/maxkernel -I/usr/include/max $(foreach dep,$(DEPENDS),-I../$(dep)/include)
LIBS += $(shell [ -n "$(PACKAGES)" ] && pkg-config --libs $(PACKAGES))
CFLAGS = -pipe -ggdb3 -Wall -std=gnu99 -fpic $(shell [ -n "$(PACKAGES)" ] && pkg-config --cflags $(PACKAGES))
LFLAGS = -shared
.PHONY: install clean depend
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS)
[ ! -f compile.part.bash ] || bash compile.part.bash
install:
[ -n "$(INSTALL)" ] || ( echo "INSTALL variable must be set" 1>&2 && false )
cp -f $(TARGET) $(INSTALL)/modules
( cp -f include/* /usr/include/max 2>/dev/null ) || true
[ ! -f install.part.bash ] || bash install.part.bash $(INSTALL)
clean:
rm -f $(TARGET) $(OBJS)
( [ -f clean.part.bash ] && bash clean.part.bash ) || true
depend: $(SRCS)
makedepend $(DEFINES) $(INCLUDES) $^ 2>/dev/null
rm -f Makefile.bak
.c.o:
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@
# DO NOT DELETE THIS LINE -- make depend needs it
''' % {
'module' : opts['--module'],
'defines' : opts['--defines'],
},