From 1eb382f72510d50b3636fb88c4bfaf17183672b6 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 7 Dec 2013 18:48:25 -0500 Subject: [PATCH] Separate cli and gtk sources into separate directories Also added a common directory to hold common files to both interfaces, and compiled into a static library. --- .gitignore | 1 + Makefile.am | 5 ++- configure.ac | 14 ++++++- src/Makefile.am | 75 ------------------------------------ src/cli/Makefile.am | 22 +++++++++++ src/{ => cli}/emuconsole.c | 0 src/{ => cli}/keyboard.c | 0 src/{ => cli}/keyboard.h | 0 src/common/Makefile.am | 38 ++++++++++++++++++ src/{ => common}/common.h | 0 src/{ => common}/cpu8051.c | 0 src/{ => common}/cpu8051.h | 0 src/{ => common}/hexfile.c | 0 src/{ => common}/hexfile.h | 0 src/{ => common}/log.c | 0 src/{ => common}/log.h | 0 src/{ => common}/memory.c | 0 src/{ => common}/memory.h | 0 src/{ => common}/opcode2c.pl | 0 src/{ => common}/opcodes.lst | 0 src/{ => common}/options.c | 0 src/{ => common}/options.h | 0 src/{ => common}/psw.c | 0 src/{ => common}/psw.h | 0 src/{ => common}/reg8051.h | 0 src/{ => common}/sfr.c | 0 src/{ => common}/sfr.h | 0 src/{ => common}/timers.c | 0 src/{ => common}/timers.h | 0 src/gtk/Makefile.am | 38 ++++++++++++++++++ src/{ => gtk}/app-config.c | 0 src/{ => gtk}/app-config.h | 0 src/{ => gtk}/emugtk.c | 0 src/{ => gtk}/emugtk.h | 0 src/{ => gtk}/filemenu.c | 0 src/{ => gtk}/filemenu.h | 0 src/{ => gtk}/helpmenu.c | 0 src/{ => gtk}/helpmenu.h | 0 src/{ => gtk}/memwin.c | 0 src/{ => gtk}/memwin.h | 0 src/{ => gtk}/messagebox.c | 0 src/{ => gtk}/messagebox.h | 0 src/{ => gtk}/pgmwin.c | 0 src/{ => gtk}/pgmwin.h | 0 src/{ => gtk}/pswwin.c | 0 src/{ => gtk}/pswwin.h | 0 src/{ => gtk}/regwin.c | 0 src/{ => gtk}/regwin.h | 0 src/{ => gtk}/viewmenu.c | 0 src/{ => gtk}/viewmenu.h | 0 tests/opcodes.sh | 2 +- 51 files changed, 115 insertions(+), 80 deletions(-) delete mode 100644 src/Makefile.am create mode 100644 src/cli/Makefile.am rename src/{ => cli}/emuconsole.c (100%) rename src/{ => cli}/keyboard.c (100%) rename src/{ => cli}/keyboard.h (100%) create mode 100644 src/common/Makefile.am rename src/{ => common}/common.h (100%) rename src/{ => common}/cpu8051.c (100%) rename src/{ => common}/cpu8051.h (100%) rename src/{ => common}/hexfile.c (100%) rename src/{ => common}/hexfile.h (100%) rename src/{ => common}/log.c (100%) rename src/{ => common}/log.h (100%) rename src/{ => common}/memory.c (100%) rename src/{ => common}/memory.h (100%) rename src/{ => common}/opcode2c.pl (100%) rename src/{ => common}/opcodes.lst (100%) rename src/{ => common}/options.c (100%) rename src/{ => common}/options.h (100%) rename src/{ => common}/psw.c (100%) rename src/{ => common}/psw.h (100%) rename src/{ => common}/reg8051.h (100%) rename src/{ => common}/sfr.c (100%) rename src/{ => common}/sfr.h (100%) rename src/{ => common}/timers.c (100%) rename src/{ => common}/timers.h (100%) create mode 100644 src/gtk/Makefile.am rename src/{ => gtk}/app-config.c (100%) rename src/{ => gtk}/app-config.h (100%) rename src/{ => gtk}/emugtk.c (100%) rename src/{ => gtk}/emugtk.h (100%) rename src/{ => gtk}/filemenu.c (100%) rename src/{ => gtk}/filemenu.h (100%) rename src/{ => gtk}/helpmenu.c (100%) rename src/{ => gtk}/helpmenu.h (100%) rename src/{ => gtk}/memwin.c (100%) rename src/{ => gtk}/memwin.h (100%) rename src/{ => gtk}/messagebox.c (100%) rename src/{ => gtk}/messagebox.h (100%) rename src/{ => gtk}/pgmwin.c (100%) rename src/{ => gtk}/pgmwin.h (100%) rename src/{ => gtk}/pswwin.c (100%) rename src/{ => gtk}/pswwin.h (100%) rename src/{ => gtk}/regwin.c (100%) rename src/{ => gtk}/regwin.h (100%) rename src/{ => gtk}/viewmenu.c (100%) rename src/{ => gtk}/viewmenu.h (100%) diff --git a/.gitignore b/.gitignore index f8db576..0ec666a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /build-aux/install-sh /build-aux/missing /build-aux/test-driver +/build-aux/ar-lib /config.cache /config.log /config.status diff --git a/Makefile.am b/Makefile.am index 0304f0a..df08920 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = src data doc tests +SUBDIRS = src/common src/cli src/gtk data doc tests ## We want these in the dist tarball EXTRA_DIST = autogen.sh \ @@ -20,4 +20,5 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config-h.in \ $(ac_aux_dir)/mkinstalldirs $(ac_aux_dir)/config.guess \ $(ac_aux_dir)/config.sub $(ac_aux_dir)/ltmain.sh \ $(ac_aux_dir)/compile \ - $(ac_aux_dir)/test-driver + $(ac_aux_dir)/test-driver \ + $(ac_aux_dir)/ar-lib diff --git a/configure.ac b/configure.ac index 8b7ed65..d39a607 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl Initialization stuff. AC_INIT([emu8051], [1.1.2], [hugo@hugovil.com], [emu8051], [http://www.hugovil.com/fr/emu8051/]) AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_SRCDIR(src/cpu8051.c) +AC_CONFIG_SRCDIR(src/common/cpu8051.c) AM_CONFIG_HEADER(config.h:config-h.in) dnl Checking if the NEWS file has been updated to reflect the current version. AM_INIT_AUTOMAKE(check-news -Wall std-options color-tests parallel-tests) @@ -13,6 +13,10 @@ AM_SILENT_RULES([yes]) dnl Testing the C compiler. AC_LANG_C +dnl Testing for libtool support. +AC_PROG_RANLIB +AM_PROG_AR + dnl Checking for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T @@ -83,4 +87,10 @@ AC_SUBST(LIBS) AC_SUBST(ac_aux_dir) dnl Creating output file(s) -AC_OUTPUT(Makefile src/Makefile data/Makefile doc/Makefile tests/Makefile) +AC_OUTPUT(Makefile + src/common/Makefile + src/cli/Makefile + src/gtk/Makefile + data/Makefile + doc/Makefile + tests/Makefile) diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 1bb89bb..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,75 +0,0 @@ -# This file is processed by GNU automake to generate Makefile.in - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - $(GLIB_CFLAGS) - -LDADD = $(GLIB_LIBS) - -bin_PROGRAMS = emu8051-cli -if USE_GTK - bin_PROGRAMS += emu8051-gtk -endif - -# instructions_8051.c must be first, because it and other files -# (instructions_8051.h and disasm.h) are automatically generated by a perl -# script, and other source files include them (the .h). -common_SOURCES = \ - instructions_8051.c \ - options.c options.h \ - log.c log.h \ - app-config.c app-config.h \ - hexfile.c hexfile.h \ - cpu8051.c cpu8051.h \ - memory.c memory.h \ - psw.c psw.h \ - sfr.c sfr.h \ - timers.c timers.h \ - common.h \ - reg8051.h - -emu8051_cli_SOURCES = \ - $(common_SOURCES) \ - emuconsole.c \ - keyboard.c keyboard.h - -if USE_GTK - emu8051_gtk_SOURCES = \ - $(common_SOURCES) \ - emugtk.c emugtk.h \ - memwin.c memwin.h \ - pgmwin.c pgmwin.h \ - regwin.c regwin.h \ - pswwin.c pswwin.h \ - filemenu.c filemenu.h \ - viewmenu.c viewmenu.h \ - helpmenu.c helpmenu.h \ - messagebox.c messagebox.h - - emu8051_gtk_CPPFLAGS = \ - -I$(top_srcdir)/pixmaps \ - $(GTK_CFLAGS) \ - $(AM_CPPFLAGS) - - emu8051_gtk_LDADD = $(GTK_LIBS) -endif - -# These files are generated automatically by a perl script. -instructions_8051.c instructions_8051.h disasm.h : opcode2c.pl opcodes.lst - ./opcode2c.pl - -CLEANFILES = *~ - -DISTCLEANFILES = .deps/*.P - -MAINTAINERCLEANFILES = \ - Makefile.in \ - instructions_8051.c \ - instructions_8051.h \ - disasm.h - -EXTRA_DIST = \ - opcode2c.pl \ - opcodes.lst \ - instructions_8051.h \ - disasm.h diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am new file mode 100644 index 0000000..deaae8a --- /dev/null +++ b/src/cli/Makefile.am @@ -0,0 +1,22 @@ +# This file is processed by GNU automake to generate Makefile.in + +AM_CPPFLAGS = \ + -Wall \ + -I@top_srcdir@ \ + -I@top_srcdir@/src/common + +LDADD = \ + $(top_builddir)/src/common/libemu8051.a + +bin_PROGRAMS = emu8051-cli + +emu8051_cli_SOURCES = \ + emuconsole.c \ + keyboard.c keyboard.h + +# we want these in the dist tarball +EXTRA_DIST = + +CLEANFILES = *~ + +MAINTAINERCLEANFILES = Makefile.in diff --git a/src/emuconsole.c b/src/cli/emuconsole.c similarity index 100% rename from src/emuconsole.c rename to src/cli/emuconsole.c diff --git a/src/keyboard.c b/src/cli/keyboard.c similarity index 100% rename from src/keyboard.c rename to src/cli/keyboard.c diff --git a/src/keyboard.h b/src/cli/keyboard.h similarity index 100% rename from src/keyboard.h rename to src/cli/keyboard.h diff --git a/src/common/Makefile.am b/src/common/Makefile.am new file mode 100644 index 0000000..2d0df82 --- /dev/null +++ b/src/common/Makefile.am @@ -0,0 +1,38 @@ +# This file is processed by GNU automake to generate Makefile.in + +AM_CPPFLAGS = \ + -Wall \ + -I$(top_srcdir) + +noinst_LIBRARIES = libemu8051.a + +libemu8051_a_SOURCES = \ + instructions_8051.c \ + options.c options.h \ + log.c log.h \ + hexfile.c hexfile.h \ + cpu8051.c cpu8051.h \ + memory.c memory.h \ + psw.c psw.h \ + sfr.c sfr.h \ + timers.c timers.h \ + common.h \ + reg8051.h + +# These files are generated automatically by a perl script. +instructions_8051.c instructions_8051.h disasm.h : opcode2c.pl opcodes.lst + ./opcode2c.pl + +CLEANFILES = *~ + +MAINTAINERCLEANFILES = \ + Makefile.in \ + instructions_8051.c \ + instructions_8051.h \ + disasm.h + +EXTRA_DIST = \ + opcode2c.pl \ + opcodes.lst \ + instructions_8051.h \ + disasm.h diff --git a/src/common.h b/src/common/common.h similarity index 100% rename from src/common.h rename to src/common/common.h diff --git a/src/cpu8051.c b/src/common/cpu8051.c similarity index 100% rename from src/cpu8051.c rename to src/common/cpu8051.c diff --git a/src/cpu8051.h b/src/common/cpu8051.h similarity index 100% rename from src/cpu8051.h rename to src/common/cpu8051.h diff --git a/src/hexfile.c b/src/common/hexfile.c similarity index 100% rename from src/hexfile.c rename to src/common/hexfile.c diff --git a/src/hexfile.h b/src/common/hexfile.h similarity index 100% rename from src/hexfile.h rename to src/common/hexfile.h diff --git a/src/log.c b/src/common/log.c similarity index 100% rename from src/log.c rename to src/common/log.c diff --git a/src/log.h b/src/common/log.h similarity index 100% rename from src/log.h rename to src/common/log.h diff --git a/src/memory.c b/src/common/memory.c similarity index 100% rename from src/memory.c rename to src/common/memory.c diff --git a/src/memory.h b/src/common/memory.h similarity index 100% rename from src/memory.h rename to src/common/memory.h diff --git a/src/opcode2c.pl b/src/common/opcode2c.pl similarity index 100% rename from src/opcode2c.pl rename to src/common/opcode2c.pl diff --git a/src/opcodes.lst b/src/common/opcodes.lst similarity index 100% rename from src/opcodes.lst rename to src/common/opcodes.lst diff --git a/src/options.c b/src/common/options.c similarity index 100% rename from src/options.c rename to src/common/options.c diff --git a/src/options.h b/src/common/options.h similarity index 100% rename from src/options.h rename to src/common/options.h diff --git a/src/psw.c b/src/common/psw.c similarity index 100% rename from src/psw.c rename to src/common/psw.c diff --git a/src/psw.h b/src/common/psw.h similarity index 100% rename from src/psw.h rename to src/common/psw.h diff --git a/src/reg8051.h b/src/common/reg8051.h similarity index 100% rename from src/reg8051.h rename to src/common/reg8051.h diff --git a/src/sfr.c b/src/common/sfr.c similarity index 100% rename from src/sfr.c rename to src/common/sfr.c diff --git a/src/sfr.h b/src/common/sfr.h similarity index 100% rename from src/sfr.h rename to src/common/sfr.h diff --git a/src/timers.c b/src/common/timers.c similarity index 100% rename from src/timers.c rename to src/common/timers.c diff --git a/src/timers.h b/src/common/timers.h similarity index 100% rename from src/timers.h rename to src/common/timers.h diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am new file mode 100644 index 0000000..22bb895 --- /dev/null +++ b/src/gtk/Makefile.am @@ -0,0 +1,38 @@ +# This file is processed by GNU automake to generate Makefile.in + +AM_CPPFLAGS = \ + -Wall \ + -I@top_srcdir@ \ + -I@top_srcdir@/src/common \ + -I$(top_srcdir)/pixmaps \ + @GTK_CFLAGS@ \ + @GLIB_CFLAGS@ \ + -DDATADIR=\"$(datadir)\" \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + +LDADD = \ + $(top_builddir)/src/common/libemu8051.a \ + @GTK_LIBS@ \ + @GLIB_LIBS@ + +bin_PROGRAMS = emu8051-gtk + +emu8051_gtk_SOURCES = \ + emugtk.c emugtk.h \ + app-config.c app-config.h \ + memwin.c memwin.h \ + pgmwin.c pgmwin.h \ + regwin.c regwin.h \ + pswwin.c pswwin.h \ + filemenu.c filemenu.h \ + viewmenu.c viewmenu.h \ + helpmenu.c helpmenu.h \ + messagebox.c messagebox.h + +EXTRA_DIST = + +CLEANFILES = *~ + +MAINTAINERCLEANFILES = Makefile.in diff --git a/src/app-config.c b/src/gtk/app-config.c similarity index 100% rename from src/app-config.c rename to src/gtk/app-config.c diff --git a/src/app-config.h b/src/gtk/app-config.h similarity index 100% rename from src/app-config.h rename to src/gtk/app-config.h diff --git a/src/emugtk.c b/src/gtk/emugtk.c similarity index 100% rename from src/emugtk.c rename to src/gtk/emugtk.c diff --git a/src/emugtk.h b/src/gtk/emugtk.h similarity index 100% rename from src/emugtk.h rename to src/gtk/emugtk.h diff --git a/src/filemenu.c b/src/gtk/filemenu.c similarity index 100% rename from src/filemenu.c rename to src/gtk/filemenu.c diff --git a/src/filemenu.h b/src/gtk/filemenu.h similarity index 100% rename from src/filemenu.h rename to src/gtk/filemenu.h diff --git a/src/helpmenu.c b/src/gtk/helpmenu.c similarity index 100% rename from src/helpmenu.c rename to src/gtk/helpmenu.c diff --git a/src/helpmenu.h b/src/gtk/helpmenu.h similarity index 100% rename from src/helpmenu.h rename to src/gtk/helpmenu.h diff --git a/src/memwin.c b/src/gtk/memwin.c similarity index 100% rename from src/memwin.c rename to src/gtk/memwin.c diff --git a/src/memwin.h b/src/gtk/memwin.h similarity index 100% rename from src/memwin.h rename to src/gtk/memwin.h diff --git a/src/messagebox.c b/src/gtk/messagebox.c similarity index 100% rename from src/messagebox.c rename to src/gtk/messagebox.c diff --git a/src/messagebox.h b/src/gtk/messagebox.h similarity index 100% rename from src/messagebox.h rename to src/gtk/messagebox.h diff --git a/src/pgmwin.c b/src/gtk/pgmwin.c similarity index 100% rename from src/pgmwin.c rename to src/gtk/pgmwin.c diff --git a/src/pgmwin.h b/src/gtk/pgmwin.h similarity index 100% rename from src/pgmwin.h rename to src/gtk/pgmwin.h diff --git a/src/pswwin.c b/src/gtk/pswwin.c similarity index 100% rename from src/pswwin.c rename to src/gtk/pswwin.c diff --git a/src/pswwin.h b/src/gtk/pswwin.h similarity index 100% rename from src/pswwin.h rename to src/gtk/pswwin.h diff --git a/src/regwin.c b/src/gtk/regwin.c similarity index 100% rename from src/regwin.c rename to src/gtk/regwin.c diff --git a/src/regwin.h b/src/gtk/regwin.h similarity index 100% rename from src/regwin.h rename to src/gtk/regwin.h diff --git a/src/viewmenu.c b/src/gtk/viewmenu.c similarity index 100% rename from src/viewmenu.c rename to src/gtk/viewmenu.c diff --git a/src/viewmenu.h b/src/gtk/viewmenu.h similarity index 100% rename from src/viewmenu.h rename to src/gtk/viewmenu.h diff --git a/tests/opcodes.sh b/tests/opcodes.sh index f6ff764..3ae17fd 100755 --- a/tests/opcodes.sh +++ b/tests/opcodes.sh @@ -12,7 +12,7 @@ name=$(basename ${test_name} .sh) hexfile=${name}.hex echo "Testing ${name}.hex" > ${lf} -../src/emu8051-cli -d 2 --xram=${XRAM_SIZE} -s ${STOP_ADDRESS} ${hexfile} >> ${lf} +../src/cli/emu8051-cli -d 2 --xram=${XRAM_SIZE} -s ${STOP_ADDRESS} ${hexfile} >> ${lf} if test $? -ne 0 ; then return 1 fi -- 2.20.1