-
Notifications
You must be signed in to change notification settings - Fork 19
/
makefile
212 lines (175 loc) · 5.6 KB
/
makefile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#
# Make file for compiling host app
#
# (C) Copyright 2008-2010
# Texas Instruments, <www.ti.com>
# Nishanth Menon <[email protected]>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation version 2.
#
# This program is distributed .as is. WITHOUT ANY WARRANTY of any kind,
# whether express or implied; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed -e "s/\(cygwin\).*/cygwin/")
srctree := $(if $(SRC),$(SRC),$(CURDIR))
ifeq ($(HOSTOS),windowsnt)
WINDOWS=1
endif
ifeq ($(HOSTOS),windows32)
WINDOWS=1
endif
# Windows Specific handling
ifdef WINDOWS
EXE_PREFIX=.exe
#Installation System specific
ifndef COMPILER_PREFIX
COMPILER_PREFIX=C:\\MinGW\\bin\\
endif
ifndef APP_PREFIX
APP_PREFIX=C:\\GnuWin32\\bin\\
endif
endif #windows
# Selective Library
ifdef WINDOWS
LIB_FILES=lib/serial_win32.c lib/file_win32.c
else
LIB_FILES=lib/serial_posix.c lib/file_posix.c
endif
LIB_FILES+=lib/f_status.c lib/lcfg/lcfg_static.c
#App source code
PSERIAL_FILES=src/pserial.c
SYSRQ_FILES=src/sysrq.c
KERMIT_FILES=src/ukermit.c
UCMD_FILES=src/ucmd.c
PUSB_FILES=src/pusb.c
GPSIGN_FILES=src/gpsign.c
TAGGER_FILES=src/tagger.c
# Add all SOC/platform specific sty files here
STY_FILES=src/asm/sty-omap3.S
DOCS=docs/html docs/latex
# Final output files
PSERIAL_EXE=pserial$(EXE_PREFIX)
SYSRQ_EXE=sysrq$(EXE_PREFIX)
KERMIT_EXE=ukermit$(EXE_PREFIX)
UCMD_EXE=ucmd$(EXE_PREFIX)
PUSB_EXE=pusb$(EXE_PREFIX)
GPSIGN_EXE=gpsign$(EXE_PREFIX)
TAGGER_EXE=tagger$(EXE_PREFIX)
# Object Files
PSERIAL_OBJ=$(PSERIAL_FILES:.c=.o)
SYSRQ_OBJ=$(SYSRQ_FILES:.c=.o)
KERMIT_OBJ=$(KERMIT_FILES:.c=.o)
UCMD_OBJ=$(UCMD_FILES:.c=.o)
PUSB_OBJ=$(PUSB_FILES:.c=.o)
GPSIGN_OBJ=$(GPSIGN_FILES:.c=.o)
TAGGER_OBJ=$(TAGGER_FILES:.c=.o)
LIB_OBJ=$(LIB_FILES:.c=.o)
STY_OBJS=$(STY_FILES:.S=.ao)
STY_BINS=$(STY_FILES:.S=.bin)
CLEANUPFILES=$(PSERIAL_OBJ) $(LIB_OBJ) $(PSERIAL_EXE) $(GWART_OBJ)\
$(KERMIT_EXE) $(KERMIT_OBJ) $(UCMD_OBJ) $(UCMD_EXE)\
$(PUSB_EXE) $(PUSB_OBJ) $(GPSIGN_EXE) $(GPSIGN_OBJ)\
$(TAGGER_EXE) $(TAGGER_OBJ) $(STY_OBJS) $(SYSRQ_OBJ)
CC=$(COMPILER_PREFIX)gcc
LD=$(COMPILER_PREFIX)gcc
RM=$(APP_PREFIX)rm$(EXE_PREFIX)
ECHO=$(APP_PREFIX)echo$(EXE_PREFIX)
DOXYGEN=$(APP_PREFIX)doxygen$(EXE_PREFIX)
CFLAGS=-Wall -O3 -Iinclude -Ilib/lcfg
LDFLAGS=
CFLAGS+=-fdata-sections -ffunction-sections
ifeq ($(HOSTOS),darwin)
LDFLAGS+=-Wl,-dead_strip
else
LDFLAGS+=-Wl,--gc-sections -Wl,--print-gc-sections -Wl,--no-print-gc-sections
endif
# should usually produce -lusb-1.0
LDFLAGS_USB=`pkg-config libusb-1.0 --libs`
CROSS_CC ?=$(CROSS_COMPILE)gcc
CROSS_OBJDUMP ?=$(CROSS_COMPILE)objdump
CROSS_OBJCOPY ?=$(CROSS_COMPILE)objcopy
ifdef DISABLE_COLOR
CFLAGS+=-DDISABLE_COLOR
endif
ifdef V
VERBOSE = $(V)
endif
ifndef VERBOSE
VERBOSE = 0
endif
%.ao: %.S
@$(ECHO) "Cross Compiling: " $<
$(if $(VERBOSE:1=),@)$(CROSS_CC) $(CFLAGS) -o $@ -c $<
%.bin: %.ao %.S
@$(ECHO) "Generating Crossbin: " $<
$(if $(VERBOSE:1=),@)$(CROSS_OBJCOPY) -O binary $< $@
%.o: %.c
@$(ECHO) "Compiling: " $<
$(if $(VERBOSE:1=),@)$(CC) $(CFLAGS) -o $@ -c $<
.PHONY : all
all: $(PSERIAL_EXE) $(KERMIT_EXE) $(UCMD_EXE) $(GPSIGN_EXE) $(TAGGER_EXE) $(SYSRQ_EXE)
usb: $(PUSB_EXE)
sty: $(STY_BINS)
@$(ECHO) "Completed all sty files"
$(SYSRQ_EXE): $(SYSRQ_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(SYSRQ_OBJ) $(LIB_OBJ) $(LDFLAGS) -o $@
@$(ECHO)
$(PSERIAL_EXE): $(PSERIAL_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(PSERIAL_OBJ) $(LIB_OBJ) $(LDFLAGS) -o $@
@$(ECHO)
$(KERMIT_EXE): $(KERMIT_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(KERMIT_OBJ) $(LIB_OBJ) $(LDFLAGS) -o $@
@$(ECHO)
$(UCMD_EXE): $(UCMD_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(UCMD_OBJ) $(LIB_OBJ) $(LDFLAGS) -o $@
@$(ECHO)
$(GPSIGN_EXE): $(GPSIGN_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(GPSIGN_OBJ) $(LIB_OBJ) $(LDFLAGS) -o $@
@$(ECHO)
$(TAGGER_EXE): $(TAGGER_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(TAGGER_OBJ) $(LIB_OBJ) $(LDFLAGS) -o $@
@$(ECHO)
$(PUSB_EXE): $(PUSB_OBJ) $(LIB_OBJ) makefile
@$(ECHO) "Generating: $@"
$(if $(VERBOSE:1=),@)$(LD) $(PUSB_OBJ) $(LIB_OBJ) $(LDFLAGS) $(LDFLAGS_USB) -o $@
@$(ECHO)
$(PUSB_OBJ): $(PUSB_FILES)
@$(ECHO) "Compiling: " $<
$(if $(VERBOSE:1=),@)$(CC) $(CFLAGS) `pkg-config libusb-1.0 --cflags` -o $@ -c $<
.PHONY : docs
docs:
@$(ECHO) "Generating Documentation:"
$(if $(VERBOSE:1=),@)-$(DOXYGEN) docs/doxyfile
$(if $(VERBOSE:1=),@)-$(MAKE) -C docs/latex
.PHONY : clean
clean:
@$(ECHO) "Cleaning:"
$(if $(VERBOSE:1=),@)-$(RM) -$(if $(VERBOSE:1=),,v)f $(CLEANUPFILES) core
.PHONY : distclean
distclean:
@$(ECHO) "Dist cleaning:"
$(if $(VERBOSE:1=),@)-$(RM) -$(if $(VERBOSE:1=),,v)f $(CLEANUPFILES)
$(if $(VERBOSE:1=),@)-$(RM) -r$(if $(VERBOSE:1=),,v)f $(DOCS)
ifndef WINDOWS
$(if $(VERBOSE:1=),@)find $(srctree) $(RCS_FIND_IGNORE) \
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
-o -name '.*.rej' -o -size 0 -o -name "*.ao"\
-o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
-type f -print | xargs rm -$(if $(VERBOSE:1=),,v)f
endif