/[dynamips]/trunk/Makefile
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (11 years, 11 months ago) by dpavlin
File size: 9239 byte(s)
make working copy

1 # Makefile for Dynamips 0.2.8
2 # Copyright (c) 2005-2006 Christophe Fillot.
3
4 # Replace x86 by amd64 for a build on x86_64.
5 # Use "nojit" for architectures that are not x86 or x86_64.
6 DYNAMIPS_ARCH?=x86
7
8 # Change this to 0 if your system doesn't support RFC 2553 extensions
9 HAS_RFC2553?=1
10
11 # Change this to 1 if your system has libpcap-0.9.4 or better
12 # (WinPcap is used for Cygwin)
13 HAS_PCAP?=1
14
15 # Change this to 1 if your system has posix_memalign
16 HAS_POSIX_MEMALIGN?=0
17
18 # Current dynamips release
19 VERSION_TRAIN=0.2.8
20 VERSION_SUB=-RC1
21
22 VERSION=$(VERSION_TRAIN)$(VERSION_SUB)
23 VERSION_DEV=$(VERSION_TRAIN)-$(shell date +%Y%m%d-%H)
24
25 # Executable binary extension
26 DESTDIR?=/usr
27 BIN_EXT?=
28
29 CC?=gcc
30 LD=ld
31 RM=rm
32 TAR=tar
33 CP=cp
34 LEX=flex
35 MIPS64_ARCH_INC_FILE=\"mips64_$(DYNAMIPS_ARCH)_trans.h\"
36 PPC32_ARCH_INC_FILE=\"ppc32_$(DYNAMIPS_ARCH)_trans.h\"
37
38 CFLAGS+=-g -Wall -O3 -fomit-frame-pointer \
39 -DJIT_ARCH=\"$(DYNAMIPS_ARCH)\" -DJIT_CPU=CPU_$(DYNAMIPS_ARCH) \
40 -DMIPS64_ARCH_INC_FILE=$(MIPS64_ARCH_INC_FILE) \
41 -DPPC32_ARCH_INC_FILE=$(PPC32_ARCH_INC_FILE) \
42 -DDYNAMIPS_VERSION=\"$(VERSION)\" \
43 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
44 -DHAS_RFC2553=$(HAS_RFC2553) \
45 -DHAS_POSIX_MEMALIGN=$(HAS_POSIX_MEMALIGN)
46
47 #PCAP_LIB=/usr/local/lib/libpcap.a
48 PCAP_LIB=-lpcap
49
50 ifeq ($(shell uname), FreeBSD)
51 PTHREAD_LIBS?=-pthread
52 LOCALBASE?=/usr/local
53 CFLAGS+=-I$(LOCALBASE)/include -I$(LOCALBASE)/include/libelf \
54 $(PTHREAD_CFLAGS) -D_FILE_OFFSET_BITS=64
55 LIBS=-L$(LOCALBASE)/lib -L. -ldl -lelf $(PTHREAD_LIBS) $(LDFLAGS)
56 else
57 ifeq ($(shell uname), Linux)
58 PTHREAD_LIBS?=-lpthread
59 # PCAP_LIB=-lpcap
60 CFLAGS+=-I/usr/include -I. $(PTHREAD_CFLAGS)
61 LIBS=-L/usr/lib -L. -ldl /usr/lib/libelf.a $(PTHREAD_LIBS)
62 DESTDIR=/usr
63 else
64 ifeq ($(shell uname -s), Darwin)
65 CFLAGS+=-I/usr/local/include -mdynamic-no-pic -D_FILE_OFFSET_BITS=64
66 LIBS=-L/usr/local/lib -L. -ldl -lelf -lpthread
67 else
68 ifeq ($(shell uname -s), SunOS)
69 CFLAGS+=-I/usr/local/include -DINADDR_NONE=0xFFFFFFFF \
70 -I /opt/csw/include -DSUNOS
71 LIBS=-L/usr/local/lib -L. -ldl -lelf -lpthread -L/opt/csw/lib \
72 -lsocket -lnsl -lresolv
73 PCAP_LIB=/opt/csw/lib/libpcap.a
74 else
75 ifeq ($(shell uname -o), Cygwin)
76 CFLAGS+=-I/usr/local/include -I/usr/local/include/libelf -DCYGWIN \
77 -D_FILE_OFFSET_BITS=64
78 LIBS=-L/usr/local/lib -L. -lelf -lpthread
79 PCAP_LIB=-lpacket -lwpcap
80 else
81 CFLAGS+=-I/usr/include/libelf -D_FILE_OFFSET_BITS=64
82 LIBS=-L. -ldl /usr/lib/libelf.a -lpthread
83 endif
84 endif
85 endif
86 endif
87 endif
88
89 PROG=dynamips$(BIN_EXT)
90 PACKAGE=$(PROG)-$(VERSION)
91 ARCHIVE=$(PACKAGE).tar.gz
92
93 PACKAGE_DEV=$(PROG)-$(VERSION_DEV)
94 ARCHIVE_DEV=$(PACKAGE_DEV).tar.gz
95
96 # Header and source files
97 HDR=mempool.h registry.h rbtree.h hash.h utils.h parser.h plugin.h \
98 crc.h sbox.h base64.h net.h net_io.h net_io_bridge.h net_io_filter.h \
99 atm.h frame_relay.h eth_switch.h \
100 ptask.h timer.h dev_vtty.h hypervisor.h dynamips.h insn_lookup.h \
101 vm.h cpu.h jit_op.h memory.h device.h \
102 mips64.h mips64_mem.h mips64_exec.h mips64_jit.h mips64_cp0.h \
103 ppc32.h ppc32_mem.h ppc32_exec.h ppc32_jit.h ppc32_vmtest.h \
104 nmc93cX6.h cisco_eeprom.h cisco_card.h ds1620.h dev_rom.h \
105 pci_dev.h pci_io.h dev_mpc860.h dev_gt.h dev_mv64460.h dev_plx.h \
106 dev_dec21140.h dev_am79c971.h dev_i8254x.h dev_i8255x.h \
107 dev_mueslix.h dev_nm_16esw.h dev_wic_serial.h \
108 dev_c7200.h dev_c7200_mpfpga.h \
109 dev_c3600.h dev_c3600_iofpga.h dev_c3600_bay.h \
110 dev_c2691.h dev_c2691_iofpga.h \
111 dev_c3725.h dev_c3725_iofpga.h \
112 dev_c3745.h dev_c3745_iofpga.h \
113 dev_c2600.h dev_c2600_iofpga.h \
114 dev_c1700.h dev_c1700_iofpga.h \
115 dev_c6msfc1.h dev_c6msfc1_mpfpga.h \
116 dev_c6sup1.h dev_c6sup1_mpfpga.h \
117 rommon_var.h
118
119 SOURCES=mempool.c registry.c rbtree.c hash.c sbox.c utils.c parser.c \
120 plugin.c ptask.c timer.c crc.c base64.c \
121 net.c net_io.c net_io_bridge.c net_io_filter.c \
122 atm.c frame_relay.c eth_switch.c \
123 dynamips.c insn_lookup.c vm.c cpu.c jit_op.c \
124 mips64.c mips64_mem.c mips64_cp0.c mips64_jit.c mips64_exec.c \
125 ppc32.c ppc32_mem.c ppc32_jit.c ppc32_exec.c ppc32_vmtest.c \
126 memory.c device.c nmc93cX6.c cisco_eeprom.c cisco_card.c \
127 pci_dev.c pci_io.c \
128 dev_zero.c dev_bswap.c dev_vtty.c dev_ram.c dev_rom.c dev_nvram.c \
129 dev_bootflash.c dev_flash.c dev_mpc860.c \
130 dev_remote.c dev_clpd6729.c dev_pcmcia_disk.c dev_gt.c dev_mv64460.c \
131 dev_plx.c dev_dec21x50.c dev_pericom.c dev_ti2050b.c dev_ap1011.c \
132 dev_plx6520cb.c dev_ns16552.c \
133 dev_dec21140.c dev_am79c971.c dev_i8254x.c dev_i8255x.c \
134 dev_mueslix.c dev_wic_serial.c \
135 dev_c3600.c dev_c3600_bay.c dev_c3600_iofpga.c \
136 dev_c3600_eth.c dev_c3600_serial.c \
137 dev_c7200.c dev_c7200_iofpga.c dev_c7200_mpfpga.c \
138 dev_c7200_sram.c dev_c7200_eth.c dev_c7200_serial.c dev_c7200_pos.c \
139 dev_c7200_bri.c \
140 dev_c2691.c dev_c2691_iofpga.c dev_c2691_eth.c dev_c2691_serial.c \
141 dev_c2691_wic.c dev_c2691_pcmod.c \
142 dev_c3725.c dev_c3725_iofpga.c dev_c3725_eth.c dev_c3725_serial.c \
143 dev_c3725_wic.c dev_c3725_pcmod.c \
144 dev_c3745.c dev_c3745_iofpga.c dev_c3745_eth.c dev_c3745_serial.c \
145 dev_c3745_wic.c dev_c3745_pcmod.c \
146 dev_c2600.c dev_c2600_pci.c dev_c2600_iofpga.c \
147 dev_c2600_eth.c dev_c2600_pcmod.c dev_c2600_wic.c \
148 dev_c1700.c dev_c1700_iofpga.c dev_c1700_eth.c dev_c1700_wic.c \
149 dev_c6msfc1.c dev_c6msfc1_iofpga.c dev_c6msfc1_mpfpga.c \
150 dev_c6sup1.c dev_c6sup1_iofpga.c dev_c6sup1_mpfpga.c \
151 dev_nm_16esw.c dev_pa_a1.c dev_pa_mc8te1.c \
152 dev_sb1.c dev_sb1_io.c dev_sb1_pci.c hypervisor.c \
153 hv_nio.c hv_nio_bridge.c hv_frsw.c hv_atmsw.c hv_ethsw.c \
154 hv_vm.c hv_vm_debug.c \
155 hv_c7200.c hv_c3600.c hv_c2691.c hv_c3725.c hv_c3745.c \
156 hv_c2600.c hv_c1700.c \
157 rommon_var.c
158
159 # Profiling
160 #SOURCES += profiler.c
161 #CFLAGS += -p -DPROFILE -DPROFILE_FILE=\"$(PROG).profile\"
162
163 ifeq ($(DYNAMIPS_ARCH),x86)
164 HDR += x86-codegen.h mips64_x86_trans.h ppc32_x86_trans.h
165 SOURCES += mips64_x86_trans.c ppc32_x86_trans.c
166 endif
167
168 ifeq ($(DYNAMIPS_ARCH),amd64)
169 HDR += x86-codegen.h amd64-codegen.h mips64_amd64_trans.h ppc32_amd64_trans.h
170 SOURCES += mips64_amd64_trans.c ppc32_amd64_trans.c
171 endif
172
173 ifeq ($(DYNAMIPS_ARCH),nojit)
174 HDR += mips64_nojit_trans.h ppc32_nojit_trans.h
175 SOURCES += mips64_nojit_trans.c ppc32_nojit_trans.c
176 endif
177
178 # RAW Ethernet support for Linux
179 ifeq ($(shell uname), Linux)
180 CFLAGS += -DLINUX_ETH
181 HDR += linux_eth.h
182 SOURCES += linux_eth.c
183 endif
184
185 # Generic Ethernet support with libpcap (0.9+)
186 ifeq ($(HAS_PCAP), 1)
187 CFLAGS += -DGEN_ETH
188 HDR += gen_eth.h
189 SOURCES += gen_eth.c
190
191 LIBS += $(PCAP_LIB)
192 endif
193
194 C_OBJS=$(SOURCES:.c=.o)
195 A_OBJS=$(ASMSRC:.S=.o)
196 LEX_C=$(LEX_SOURCES:.l=.c)
197
198 SUPPL=mips_mts.c Makefile ChangeLog COPYING README README.hypervisor TODO \
199 dynamips.1 nvram_export.1 hypervisor_mode.7 \
200 mips64_microcode ppc32_microcode debian/
201
202 FILE_LIST := $(HDR) $(SOURCES) $(SUPPL) \
203 x86-codegen.h amd64-codegen.h \
204 mips64_x86_trans.c mips64_x86_trans.h \
205 mips64_amd64_trans.c mips64_amd64_trans.h \
206 mips64_nojit_trans.c mips64_nojit_trans.h \
207 ppc32_x86_trans.c ppc32_x86_trans.h \
208 ppc32_amd64_trans.c ppc32_amd64_trans.h \
209 ppc32_nojit_trans.c ppc32_nojit_trans.h \
210 linux_eth.c linux_eth.h gen_eth.c gen_eth.h \
211 profiler.c profiler_resolve.pl bin2c.c rom2c.c \
212 nvram_export.c udp_send.c udp_recv.c
213
214 .PHONY: all
215 all: $(PROG) nvram_export
216
217 $(PROG): mips64_microcode_dump.inc ppc32_microcode_dump.inc \
218 $(LEX_C) $(C_OBJS) $(A_OBJS)
219 @echo "Linking $@"
220 @$(CC) -o $@ $(C_OBJS) $(A_OBJS) $(LIBS)
221
222 udp_send$(BIN_EXT): udp_send.c net.c
223 @echo "Linking $@"
224 @$(CC) -Wall $(CFLAGS) -o $@ udp_send.c net.c $(LIBS)
225
226 udp_recv$(BIN_EXT): udp_recv.c net.c
227 @echo "Linking $@"
228 @$(CC) -Wall $(CFLAGS) -o $@ udp_recv.c net.c $(LIBS)
229
230 rom2c$(BIN_EXT): rom2c.c
231 @echo "Linking $@"
232 @$(CC) -Wall $(CFLAGS) -o $@ rom2c.c $(LIBS)
233
234 mips64_microcode_dump.inc: rom2c$(BIN_EXT) mips64_microcode
235 @./rom2c mips64_microcode mips64_microcode_dump.inc 0xbfc00000
236
237 ppc32_microcode_dump.inc: rom2c$(BIN_EXT) ppc32_microcode
238 @./rom2c ppc32_microcode ppc32_microcode_dump.inc 0xfff00000
239
240 asmdefs$(BIN_EXT): asmdefs.c mips64.h
241 @echo "Linking $@"
242 @$(CC) -Wall $(CFLAGS) -o $@ asmdefs.c
243
244 asmdefs.h: asmdefs$(BIN_EXT)
245 @echo "Building assembly definitions header file"
246 @./asmdefs
247
248 nvram_export$(BIN_EXT): nvram_export.c
249 @echo "Linking $@"
250 @$(CC) -Wall $(CFLAGS) -o $@ nvram_export.c
251
252 install: $(PROG) nvram_export
253 @echo "Installing"
254 install -d $(DESTDIR)/bin $(DESTDIR)/man/man1 $(DESTDIR)/man/man7 $(DESTDIR)/etc
255 install dynamips nvram_export $(DESTDIR)/bin
256 install -m644 dynamips.1 $(DESTDIR)/man/man1
257 install -m644 nvram_export.1 $(DESTDIR)/man/man1
258 install -m644 hypervisor_mode.7 $(DESTDIR)/man/man7
259 # install -m644 example $(DESTDIR)/etc/dynamips
260
261
262 .PHONY: clean
263 clean:
264 $(RM) -f rom2c$(BIN_EXT) microcode_dump.inc asmdefs$(BIN_EXT) \
265 asmdefs.h $(C_OBJS) $(A_OBJS) $(PROG)
266 $(RM) -f *~
267
268 .PHONY: package
269 package:
270 @mkdir -p distrib/$(PACKAGE)
271 @$(CP) -r $(FILE_LIST) distrib/$(PACKAGE)
272 @cd distrib ; $(TAR) czf $(ARCHIVE) $(PACKAGE)
273
274 .PHONY: packdev
275 packdev:
276 @mkdir -p distrib/$(PACKAGE_DEV)
277 @$(CP) -r $(FILE_LIST) distrib/$(PACKAGE_DEV)
278 @cd distrib ; $(TAR) czf $(ARCHIVE_DEV) $(PACKAGE_DEV)
279
280 .SUFFIXES: .c .h .S .l .y .o
281
282 .S.o:
283 @echo "Assembling $<"
284 @$(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $<
285
286 .c.o:
287 @echo "Compiling $<"
288 @$(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $<
289
290 .l.c:
291 $(LEX) -o$*.c $<

  ViewVC Help
Powered by ViewVC 1.1.26