-
Notifications
You must be signed in to change notification settings - Fork 0
/
genmakefile
executable file
·50 lines (38 loc) · 959 Bytes
/
genmakefile
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
#!/bin/sh
# This file generates a recursive makefile, why?
# I created this script because the makefile got too big, because of the tall
# project structure.
FOLDERS=`find -type d -name "[0-9]*.[0-9]*" -printf "%p "`
# Prefix
MAKEFILE='.POSIX:
include config.mk
all: options section1
options:
@echo Build options:
@echo "CFLAGS = $(MYCFLAGS)"
@echo "LDFLAGS = $(MYLDFLAGS)"
@echo "CC = $(CC)"
section1: '
# Set rules to section 1
MAKEFILE="${MAKEFILE}${FOLDERS}
"
# Create rule for every subfolder.
for folder in $FOLDERS; do
MAKEFILE="${MAKEFILE}${folder}:
\$(MAKE) -C ${folder} CONFIG_MK=\`pwd\`/config.mk all
"
done
# Clean all subfolders.
MAKEFILE="${MAKEFILE}
clean:
"
for folder in $FOLDERS; do
MAKEFILE="${MAKEFILE} \$(MAKE) -C ${folder} CONFIG_MK=\`pwd\`/config.mk clean
"
done
# Apply phony to all subfolders.
MAKEFILE="${MAKEFILE}
.PHONY: all options section1 clean check \\
${FOLDERS}
"
printf "%s" "$MAKEFILE" > Makefile