• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Commit MetaInfo

Revision705d5edabb0e4137dc76247bbb390e546136e7c7 (tree)
Time2014-02-18 17:55:02
AuthorYoshinori Sato <ysato@sa76...>
CommiterYoshinori Sato

Log Message

autotools

Change Summary

Incremental Difference

--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
1+Yoshinori Sato <ysato@users.sourceforge.jp>
--- a/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1-CC = gcc
2-CFLAGS = -Wall -O2 -g
3-OBJS = main.o comm.o serial.o usb.o
4-TARGET= h8flash
5-
6-all: h8flash
7-
8-$(TARGET): $(OBJS)
9- $(CC) -o $(TARGET) $(OBJS) -lusb
10-
11-main.o: main.c h8flash.h
12-
13-comm.o: comm.c h8flash.h
14-
15-serial.o: serial.c h8flash.h
16-
17-usb.o: usb.c
18-
19-.phony: clean
20-
21-clean:
22- rm -f *.o *~ $(TARGET)
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,3 @@
1+bin_PROGRAMS = h8flash
2+h8flash_SOURCES = main.c comm.c serial.c usb.c
3+h8flash_LDADD = $(LIBOBJS)
--- a/README
+++ b/README
@@ -2,13 +2,16 @@ Renesas CPU on-chip flash memory writer
22
33 1. Requirement
44 - Standard POSIX library
5-- libusb
5+- libusb (optional)
6+- libelf (optional)
67
78 2. Build and Install
8-please run "make".
9+ 1. ./configure
10+ 2. make
11+ 3. make install
912
1013 3. Usage
11-h8flash [-p port] [-f freq] [-b] [-l] [-V] filename
14+h8flash -f freq[-p port] [-b] [-l] [-V] filename
1215 -p
1316 commnunication port setting.
1417 'usb' is using usb. others using serial port.
@@ -27,7 +30,7 @@ h8flash [-p port] [-f freq] [-b] [-l] [-V] filename
2730 verbose mode
2831
2932 filename
30- S-Record file or binary image.
33+ S-Record file, ELF binary or raw binary image.
3134
3235 4. Licenses
33-This program license is GPL v3 or later.
36+This program license is GPL v2.1 or later.
--- /dev/null
+++ b/compile
@@ -0,0 +1 @@
1+/usr/share/automake-1.14/compile
\ No newline at end of file
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,103 @@
1+/* config.h.in. Generated from configure.ac by autoheader. */
2+
3+/* Define to 1 if you have the <fcntl.h> header file. */
4+#undef HAVE_FCNTL_H
5+
6+/* Define to 1 if you have the `ftruncate' function. */
7+#undef HAVE_FTRUNCATE
8+
9+/* Define to 1 if you have the <gelf.h> header file. */
10+#undef HAVE_GELF_H
11+
12+/* Define to 1 if you have the <inttypes.h> header file. */
13+#undef HAVE_INTTYPES_H
14+
15+/* Define to 1 if you have the `malloc' function. */
16+#undef HAVE_MALLOC
17+
18+/* Define to 1 if you have the `memchr' function. */
19+#undef HAVE_MEMCHR
20+
21+/* Define to 1 if you have the <memory.h> header file. */
22+#undef HAVE_MEMORY_H
23+
24+/* Define to 1 if you have the `memset' function. */
25+#undef HAVE_MEMSET
26+
27+/* Define to 1 if you have the `mmap' function. */
28+#undef HAVE_MMAP
29+
30+/* Define to 1 if you have the `munmap' function. */
31+#undef HAVE_MUNMAP
32+
33+/* Define to 1 if you have the `select' function. */
34+#undef HAVE_SELECT
35+
36+/* Define to 1 if you have the <stddef.h> header file. */
37+#undef HAVE_STDDEF_H
38+
39+/* Define to 1 if you have the <stdint.h> header file. */
40+#undef HAVE_STDINT_H
41+
42+/* Define to 1 if you have the <stdlib.h> header file. */
43+#undef HAVE_STDLIB_H
44+
45+/* Define to 1 if you have the <strings.h> header file. */
46+#undef HAVE_STRINGS_H
47+
48+/* Define to 1 if you have the <string.h> header file. */
49+#undef HAVE_STRING_H
50+
51+/* Define to 1 if you have the `strncasecmp' function. */
52+#undef HAVE_STRNCASECMP
53+
54+/* Define to 1 if you have the `strtoul' function. */
55+#undef HAVE_STRTOUL
56+
57+/* Define to 1 if you have the <sys/stat.h> header file. */
58+#undef HAVE_SYS_STAT_H
59+
60+/* Define to 1 if you have the <sys/time.h> header file. */
61+#undef HAVE_SYS_TIME_H
62+
63+/* Define to 1 if you have the <sys/types.h> header file. */
64+#undef HAVE_SYS_TYPES_H
65+
66+/* Define to 1 if you have the <termios.h> header file. */
67+#undef HAVE_TERMIOS_H
68+
69+/* Define to 1 if you have the <unistd.h> header file. */
70+#undef HAVE_UNISTD_H
71+
72+/* Define to 1 if you have the <usb.h> header file. */
73+#undef HAVE_USB_H
74+
75+/* Name of package */
76+#undef PACKAGE
77+
78+/* Define to the address where bug reports for this package should be sent. */
79+#undef PACKAGE_BUGREPORT
80+
81+/* Define to the full name of this package. */
82+#undef PACKAGE_NAME
83+
84+/* Define to the full name and version of this package. */
85+#undef PACKAGE_STRING
86+
87+/* Define to the one symbol short name of this package. */
88+#undef PACKAGE_TARNAME
89+
90+/* Define to the home page for this package. */
91+#undef PACKAGE_URL
92+
93+/* Define to the version of this package. */
94+#undef PACKAGE_VERSION
95+
96+/* Define to 1 if you have the ANSI C header files. */
97+#undef STDC_HEADERS
98+
99+/* Version number of package */
100+#undef VERSION
101+
102+/* Define to `int' if <sys/types.h> does not define. */
103+#undef pid_t
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,51 @@
1+# -*- Autoconf -*-
2+# Process this file with autoconf to produce a configure script.
3+
4+AC_PREREQ([2.69])
5+AC_INIT([h8flash], [2.00], [ysato@users.sourceforge.jp])
6+AM_INIT_AUTOMAKE
7+AC_CONFIG_SRCDIR([usb.c])
8+AC_CONFIG_HEADERS([config.h])
9+
10+# Checks for programs.
11+AC_PROG_CC
12+
13+# Checks for libraries.
14+AC_CHECK_LIB(usb, usb_bulk_write,has_usb=1,has_usb=0)
15+AC_CHECK_LIB(usb, usb_bulk_read,has_usb=1,has_usb=0)
16+AC_CHECK_LIB(usb, usb_init,has_usb=1,has_usb=0)
17+AC_CHECK_LIB(usb, usb_get_busses,has_usb=1,has_usb=0)
18+AC_CHECK_LIB(usb, usb_find_devices,has_usb=1,has_usb=0)
19+AC_CHECK_LIB(usb, usb_get_busses,has_usb=1,has_usb=0)
20+AC_CHECK_LIB(usb, usb_open,has_usb=1,has_usb=0)
21+AC_CHECK_LIB(usb, usb_strerr,has_usb=1,has_usb=0)
22+AC_CHECK_LIB(usb, usb_claim_interface,has_usb=1,has_usb=0)
23+AC_CHECK_LIB(elf, elf_version,has_elf=1,has_elf=0)
24+AC_CHECK_LIB(elf, elf_begin,has_elf=1,has_elf=0)
25+AC_CHECK_LIB(elf, elf_kind,has_elf=1,has_elf=0)
26+AC_CHECK_LIB(elf, elf_getphdrnum,has_elf=1,has_elf=0)
27+AC_CHECK_LIB(elf, gelf_getphdr,has_elf=1,has_elf=0)
28+AC_CHECK_LIB(elf, elf_end,has_elf=1,has_elf=0)
29+if test $has_usb = 0; then
30+ AC_MSG_WARN("WARNING: can not found libusb.")
31+ AC_MSG_WARN("disabled usb functions');
32+else
33+ LIBS="-lusb"
34+fi
35+if test $has_elf = 0; then
36+ AC_MSG_WARN("WARNING: can not found libelf.")
37+ AC_MSG_WARN("disabled elf handle.');
38+else
39+ LIBS="$LIBS -lelf"
40+fi
41+# Checks for header files.
42+AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/time.h termios.h unistd.h usb.h gelf.h])
43+
44+# Checks for typedefs, structures, and compiler characteristics.
45+AC_TYPE_PID_T
46+
47+# Checks for library functions.
48+AC_CHECK_FUNCS([ftruncate memchr memset munmap select strncasecmp strtoul malloc mmap])
49+
50+AC_CONFIG_FILES([Makefile])
51+AC_OUTPUT
--- a/main.c
+++ b/main.c
@@ -8,6 +8,10 @@
88 * General Public License version 2.1 (or later).
99 */
1010
11+#ifdef HAVE_CONFIG_H
12+#include "config.h"
13+#endif
14+
1115 #include <stdio.h>
1216 #include <getopt.h>
1317 #include <stddef.h>
@@ -403,12 +407,13 @@ int main(int argc, char *argv[])
403407 }
404408 }
405409
406- if (optind >= argc && !config_list) {
410+ if (optind >= argc || !config_list || input_freq == 0) {
407411 usage();
408412 return 1;
409413 }
410414
411415 r = 1;
416+#ifdef HAVE_USB_H
412417 if (strncasecmp(port, "usb", 3) == 0) {
413418 unsigned short vid = DEFAULT_VID;
414419 unsigned short pid = DEFAULT_PID;
@@ -421,6 +426,9 @@ int main(int argc, char *argv[])
421426 p = open_usb(vid, pid);
422427 } else
423428 p = open_serial(port);
429+#else
430+ p = open_serial(port);
431+#endif
424432 if (p == NULL)
425433 goto error;
426434
--- a/usb.c
+++ b/usb.c
@@ -8,8 +8,13 @@
88 * General Public License version 2.1 (or later).
99 */
1010
11-#include <usb.h>
11+#ifdef HAVE_CONFIG_H
12+#include "config.h"
13+#endif
14+
1215 #include <stdio.h>
16+#ifdef HAVE_USB_H
17+#include <usb.h>
1318 #include "h8flash.h"
1419
1520 #define USB_TIMEOUT 100000
@@ -118,3 +123,9 @@ found:
118123 snprintf(target, sizeof(target), "USB(%04x:%04x)", vid, pid);
119124 return &usb_port;
120125 }
126+#else
127+struct port_t *open_usb(unsigned short vid, unsigned short pid)
128+{
129+ return NULL;
130+}
131+#endif