Skip to content

Commit 5093c78

Browse files
author
philmoz
committed
Makefiles cleanup part 3 - tools directory.
1 parent f5fc83c commit 5093c78

File tree

8 files changed

+244
-88
lines changed

8 files changed

+244
-88
lines changed

host_rules.inc

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Host GCC rules for tools
2+
3+
HOSTCC=gcc
4+
HOSTAR=ar
5+
HOSTCFLAGS=-g -O2 -Wall -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -I$(modules)
6+
7+
ifdef OPT_WARNINGS
8+
ifeq ($(GCC_VERSION_MAJOR),3)
9+
HOSTCFLAGS+=-Wwrite-strings -Wsign-compare -Wunused -Wno-unused-parameter
10+
endif
11+
ifeq ($(GCC_VERSION_MAJOR),4)
12+
#HOSTCFLAGS+=-Wextra -fdiagnostics-show-option -Wno-missing-field-initializers -Wunused -Wno-unused-parameter
13+
endif
14+
endif
15+
16+
%.o: %.c
17+
@echo $< \-\> $@
18+
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
19+
20+
%.o: $(modules)/%.c
21+
@echo $< \-\> $@
22+
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
23+
24+
%.o: $(llua)/%.c
25+
@echo $< \-\> $@
26+
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
27+
28+
.dep/%.d: %.c .dep
29+
$(HOSTCC) $(HOSTCFLAGS) -MM $< > $@.$$$$; \
30+
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
31+
rm -f $@.$$$$
32+
33+
.dep/%.d: $(llua)/%.c .dep
34+
$(HOSTCC) $(HOSTCFLAGS) -MM $< > $@.$$$$; \
35+
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
36+
rm -f $@.$$$$
37+
38+
# Define empty recipes for source files (including the makefiles)
39+
# to prevent make from trying implicit rules to create them. Speeds up build process
40+
$(topdir)host_rules.inc: ;

makefile_base.inc

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Base makefile rules
2+
3+
# Define default target (place this first so it is always selected if no target on command line)
4+
.PHONY: default
5+
default: all
6+
7+
MEMISOSIZE="(&_end-&_start)"
8+
# override this on the command line or in buildconf to use PRIMARY.BIN from a different tree
9+
# should be an absolute path
10+
PRIMARY_ROOT=$(topdir)platform
11+
include $(topdir)buildconf.inc
12+
# optional local version of buildconf.inc, not in SVN so it can be used in autobuilds
13+
# and to avoid getting accidentally included in svn diffs
14+
# you may also set your default camera here
15+
-include $(topdir)localbuildconf.inc
16+
include $(topdir)version.inc
17+
-include $(topdir)revision.inc
18+
19+
# Sub-directory for object and dump files
20+
# used by modules build
21+
O=.o/
22+
23+
ifndef OPT_DE_VERSION
24+
VER=CHDK
25+
ifndef OPT_DEFAULT_LANG
26+
OPT_DEFAULT_LANG=english
27+
endif
28+
else
29+
VER=CHDK_DE
30+
ifndef OPT_DEFAULT_LANG
31+
OPT_DEFAULT_LANG=german
32+
endif
33+
endif
34+
35+
# Define some shorthand file & directory locations
36+
bin=$(topdir)bin
37+
chdk=$(topdir)CHDK
38+
core=$(topdir)core
39+
doc=$(topdir)doc
40+
include=$(topdir)include
41+
loader=$(topdir)loader/$(PLATFORM)
42+
lib=$(topdir)lib
43+
larmutil=$(lib)/armutil
44+
lcore=$(lib)/core
45+
lfont=$(lib)/font
46+
llang=$(lib)/lang
47+
llibc=$(lib)/libc
48+
llua=$(lib)/lua
49+
lmath=$(lib)/math
50+
lubasic=$(lib)/ubasic
51+
modules=$(topdir)modules
52+
platform=$(topdir)platform
53+
tools=$(topdir)tools
54+
cam=$(platform)/$(PLATFORM)
55+
camfw=$(cam)/sub/$(PLATFORMSUB)
56+
TARGET_PRIMARY=$(PRIMARY_ROOT)/$(PLATFORM)/sub/$(PLATFORMSUB)/PRIMARY.BIN
57+
PAKWIF=$(tools)/pakwif$(EXE)
58+
PAKFI2=$(tools)/packfi2/fi2enc$(EXE)
59+
ENCODE_DISKBOOT=$(tools)/dancingbits$(EXE)
60+
61+
SILENT=SILENT
62+
63+
##########################################################################
64+
65+
include $(topdir)makefile_env.inc
66+
67+
##########################################################################
68+
69+
.PHONY: all
70+
all: all-recursive
71+
72+
.PHONY: clean
73+
clean: clean-recursive
74+
75+
.PHONY: distclean
76+
distclean: distclean-recursive
77+
78+
.dep:
79+
mkdir .dep
80+
81+
clean-recursive:
82+
@for i in $(SUBDIRS); do \
83+
echo \>\> Cleaning in $(FOLDER)$$i; \
84+
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" clean || exit 1; \
85+
done
86+
87+
distclean-recursive:
88+
@for i in $(SUBDIRS); do \
89+
echo \>\> Distcleaning in $(FOLDER)$$i; \
90+
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" distclean || exit 1; \
91+
done
92+
93+
all-recursive:
94+
@for i in $(SUBDIRS); do \
95+
echo \>\> Entering to $(FOLDER)$$i; \
96+
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" || exit 1; \
97+
echo \<\< Leaving $(FOLDER)$$i; \
98+
done
99+
100+
depend-recursive:
101+
@for i in $(SUBDIRS); do \
102+
echo \>\> Entering to $(FOLDER)$$i; \
103+
$(MAKE) -C $$i FOLDER="$(FOLDER)$$i/" depend || exit 1; \
104+
echo \<\< Leaving $(FOLDER)$$i; \
105+
done
106+
107+
ifdef SILENT
108+
.SILENT:
109+
endif
110+
111+
112+
# Define empty recipes for source files (including the makefiles)
113+
# to prevent make from trying implicit rules to create them. Speeds up build process
114+
Makefile: ;
115+
makefile: ;
116+
$(topdir)makefile_base.inc: ;
117+
$(topdir)buildconf.inc: ;
118+
$(topdir)localbuildconf.inc: ;
119+
$(topdir)version.inc: ;
120+
$(topdir)revision.inc: ;
121+
*.c: ;
122+
*.txt: ;
123+
*.sh: ;
124+
reversebytes.S: ;
125+
callfunc.S: ;
126+
setjmp.S: ;
127+
stubs_min.S: ;
128+
stubs_entry_2.S: ;

makefile_env.inc

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# OS environment config
2+
3+
ESED = sed -r
4+
5+
# keep sort order consistent
6+
export LC_ALL=C
7+
8+
ifndef OSTYPE
9+
HOSTPLATFORM:=$(patsubst MINGW%,MINGW,$(shell uname -s))
10+
ifeq ($(HOSTPLATFORM),MINGW)
11+
OSTYPE = Windows
12+
EXE = .exe
13+
SH = sh
14+
DEVNULL = NUL
15+
OLDSEPARATOR = \\\\
16+
NEWSEPARATOR = /
17+
SORT := $(dir $(shell which uniq.exe | sed 's_$(OLDSEPARATOR)_$(NEWSEPARATOR)_g'))/sort.exe
18+
else
19+
ifeq ($(HOSTPLATFORM),Linux)
20+
OSTYPE = Linux
21+
EXE =
22+
SH =
23+
DEVNULL = /dev/null
24+
SORT = sort
25+
else
26+
ifeq ($(HOSTPLATFORM),Darwin)
27+
OSTYPE = Darwin
28+
EXE =
29+
SH =
30+
DEVNULL = /dev/null
31+
SORT = sort
32+
ESED = sed -E
33+
else
34+
OSTYPE = Other
35+
EXE =
36+
SH =
37+
DEVNULL = /dev/null
38+
SORT = sort
39+
endif
40+
endif
41+
endif
42+
else
43+
EXE =
44+
SH =
45+
DEVNULL = /dev/null
46+
SORT = sort
47+
endif
48+
49+
# Define empty recipes for source files (including the makefiles)
50+
# to prevent make from trying implicit rules to create them. Speeds up build process
51+
$(topdir)makefile_env.inc: ;

makefile_tools.inc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Build rules for tools
2+
3+
include $(topdir)makefile_base.inc
4+
include $(topdir)host_rules.inc
5+
6+
# Define empty recipes for source files (including the makefiles)
7+
# to prevent make from trying implicit rules to create them. Speeds up build process
8+
$(topdir)makefile_tools.inc: ;

tools/Makefile

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
topdir=../
22

3-
SKIPBUILDRULES=1
4-
SKIPPLATFORMCHECK=1
3+
include $(topdir)makefile_tools.inc
54

6-
include $(topdir)makefile.inc
7-
include $(topdir)version.inc
8-
9-
OBJS=pakwif.o finsig_vxworks.o finsig_dryos.o gensig_vxworks.o gensig_dryos.o \
10-
dumpchk.o dancingbits.o rawconvert.o dumputil.o find_levent.o find_eventproc.o \
11-
yuvconvert.o font_8x16_pack.o makelang.o code_gen.o
12-
13-
ifdef OPT_FI2
14-
SUBDIRS=packfi2
15-
endif
16-
17-
SUBDIRS+=elf2flt
5+
SUBDIRS=packfi2 elf2flt
186

197
EXES=makeexport$(EXE) pakwif$(EXE) finsig_vxworks$(EXE) finsig_dryos$(EXE) gensig_vxworks$(EXE) gensig_dryos$(EXE) \
208
dancingbits$(EXE) font_8x16_pack$(EXE) makelang$(EXE) code_gen$(EXE) gen_conf_lua$(EXE)
@@ -24,15 +12,6 @@ all: $(EXES)
2412
# not needed by batch builds, not built by default
2513
extras: rawconvert$(EXE) yuvconvert$(EXE) find_levent$(EXE) find_eventproc$(EXE) dumpchk$(EXE)
2614

27-
%.o: %.c
28-
@echo $< \-\> $@
29-
$(HOSTCC) $(HOSTCFLAGS) -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -c -o $@ $<
30-
31-
.dep/%.d: %.c .dep
32-
$(HOSTCC) $(HOSTCFLAGS) -MM $< > $@.$$$$; \
33-
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
34-
rm -f $@.$$$$
35-
3615
makeexport$(EXE): makeexport.o
3716
@echo $< \-\> $@
3817
$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
@@ -171,3 +150,8 @@ font_8x16_pack.o: font_8x16_pack.c ../lib/font/font_8x16_uni.h
171150

172151
include $(topdir)bottom.inc
173152

153+
# Define empty recipes for source files (including the makefiles)
154+
# to prevent make from trying implicit rules to create them. Speeds up build process
155+
chdk_dasm.h: ;
156+
firmware_load.h: ;
157+
stubs_load.h: ;

tools/elf2flt/Makefile

+3-18
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
topdir=../../
22

3-
SKIPBUILDRULES=1
4-
SKIPPLATFORMCHECK=1
3+
include $(topdir)makefile_tools.inc
54

6-
include $(topdir)makefile.inc
7-
8-
# Add directory to find flt.h file.
9-
HOSTCFLAGS+=-I$(topdir)modules
10-
11-
OBJS= myio.o elf-arm.o elfflt.o main.o
5+
HOSTCFLAGS+=-Wno-format
126

137
all: elf2flt$(EXE) fltdump$(EXE)
148

15-
%.o: %.c
16-
@echo $< \-\> $@
17-
$(HOSTCC) $(HOSTCFLAGS) -Wno-format -c -o $@ $<
18-
19-
.dep/%.d: %.c .dep
20-
$(HOSTCC) $(HOSTCFLAGS) -MM $< > $@.$$$$; \
21-
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
22-
rm -f $@.$$$$
23-
24-
elf2flt$(EXE): $(OBJS)
9+
elf2flt$(EXE): myio.o elf-arm.o elfflt.o main.o
2510
@echo $< \-\> $@
2611
$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
2712

tools/hostlua/Makefile

+6-34
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,24 @@
11
topdir=../../
22

3-
SKIPBUILDRULES=1
4-
SKIPPLATFORMCHECK=1
3+
include $(topdir)makefile_tools.inc
54

6-
include $(topdir)makefile.inc
7-
8-
LUA_SRC=$(topdir)lib/lua
9-
CORE_SRC=$(topdir)modules
10-
11-
HOSTCFLAGS+=-DHOST_LUA -DLUA_ANSI -I./include -I$(CORE_SRC)
5+
HOSTCFLAGS+=-DHOST_LUA -DLUA_ANSI -I./include
126
HOSTLDOPTS=-lm
137

14-
%.o: $(CORE_SRC)/%.c
15-
@echo $< \-\> $@
16-
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
17-
18-
%.o: $(LUA_SRC)/%.c
19-
@echo $< \-\> $@
20-
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
21-
22-
.dep/%.d: $(LUA_SRC)/%.c .dep
23-
$(HOSTCC) $(HOSTCFLAGS) -MM $< > $@.$$$$; \
24-
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
25-
rm -f $@.$$$$
26-
278
%.a:
289
@echo $^ \-\> $@
2910
$(HOSTAR) rcs $@ $^
3011

3112
# these are always built for hostlua, you can hide them from scripts by setting
3213
# the corresponding globals to nil
33-
LUA_OPTLIB_OBJS=cordic_math.o
34-
35-
HOSTCFLAGS+=-DOPT_LUA_IOLIB
36-
LUA_OPTLIB_OBJS+=liolib.o
37-
38-
HOSTCFLAGS+=-DOPT_LUA_OSLIB
39-
LUA_OPTLIB_OBJS+=loslib.o
40-
41-
HOSTCFLAGS+=-DOPT_LUA_STRLIB
42-
LUA_OPTLIB_OBJS+=lstrlib.o
14+
LUA_OPTLIB_OBJS=cordic_math.o liolib.o loslib.o lstrlib.o
15+
HOSTCFLAGS+=-DOPT_LUA_IOLIB -DOPT_LUA_OSLIB -DOPT_LUA_STRLIB
4316

4417
COMMON_OBJS = lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
4518
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
4619
lundump.o lvm.o lzio.o \
47-
\
48-
lauxlib.o lbaselib.o ldblib.o ltablib.o lmathlib.o limathlib.o \
49-
$(LUA_OPTLIB_OBJS) loadlib.o linit.o
20+
lauxlib.o lbaselib.o ldblib.o ltablib.o lmathlib.o limathlib.o \
21+
$(LUA_OPTLIB_OBJS) loadlib.o linit.o
5022

5123
OBJS=$(COMMON_OBJS)
5224

tools/packfi2/Makefile

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
topdir=../../
22

3-
SKIPBUILDRULES=1
4-
SKIPPLATFORMCHECK=1
5-
6-
include $(topdir)makefile.inc
3+
include $(topdir)makefile_tools.inc
74

85
OBJS=fi2enc.o aes128.o compress.o deflate.o crc32.o zutil.o adler32.o trees.o
96

107
all: fi2enc$(EXE)
118

12-
%.o: %.c
13-
@echo $< \-\> $@
14-
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
15-
16-
.dep/%.d: %.c .dep
17-
$(HOSTCC) $(HOSTCFLAGS) -MM $< > $@.$$$$; \
18-
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
19-
rm -f $@.$$$$
20-
219
fi2enc$(EXE): $(OBJS)
2210
@echo $< \-\> $@
2311
$(HOSTCC) $(HOSTCFLAGS) -o $@ $^

0 commit comments

Comments
 (0)